关于https://superuser.com/questions/1210215/how-to-bootstrap-windows-hosts-with-remote-powershell-for-use-with-ansible的建议我试图将自定义脚本扩展添加到现有VM。
以下是我的剧本
- name: Create VM playbook
hosts: localhost
connection: local
tasks:
- name: Custom Script Extension
azure_rm_deployment:
state: present
location: 'uk west'
resource_group_name: 'AnsibleRG'
template: "{{ lookup('file', '/etc/ansible/playbooks/extension.json') | from_json }}"
deployment_mode: incremental
这是extension.json
{
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.4",
"settings": {
"fileUris": [
"https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
],
"commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File ConfigureRemotingForAnsible.ps1"
}
}
当我运行剧本时,我在azure上得到以下错误
请求内容无效,无法反序列化:'可以 找不到会员'发布者'对象'模板'。路径 ' properties.template.publisher',第1行,第64位。'。
任何人都可以指出我正确的方向吗?
由于
答案 0 :(得分:1)
extensions
不是正确的类型示例:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('vmName'),'/ConfigureRemotingForAnsible')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.8",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
],
"commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File ConfigureRemotingForAnsible.ps1"
}
}
}
]
}