我编写了为1个虚拟机添加扩展的代码,但是我必须对所有计算机都进行扩展。
我试图提供虚拟机并从中获取资源组名称,但是我收到错误消息“ VARIABLE IS NOT DEFINED!”。 -我怀疑该行为是由于以下主机而引起的:localhost
---
- name: Add VM Custom Extension
hosts: localhost
tasks:
- name: Create VM Extension
vars:
password_encrypted: !vault |
$ANSIBLE_VAULT;1.1;AES256 xxx
azure_rm_virtualmachineextension:
name: EnableWinRM
location: westeurope
resource_group: "{{ resource_group }}"
virtual_machine_name: "{{ virtual_machine_name }}"
publisher: Microsoft.Compute
virtual_machine_extension_type: CustomScriptExtension
type_handler_version: "1.9"
settings: '{"fileUris": ["https://x.blob.core.windows.net/dxxx/script.ps1"]}'
protected_settings: '{"commandToExecute": "powershell -ExecutionPolicy Bypass -file script.ps1 -EnableCredSSP -Password {{ password_encrypted }}"}'
我想用一本剧本在所有机器上实现该扩展脚本。