【发布时间】:2019-11-02 15:17:16
【问题描述】:
我正在尝试将“字符串”类型的数组参数从 ansible playbook 传递到 powershell 脚本,该脚本需要作为 vm 扩展运行在 azure cloud 中运行的 VM。下面是 ansible playbook 代码
- name: Create VM extension
azure_rm_virtualmachine_extension:
name: "Extension"
location: "{{ var_location }}"
resource_group: "{{ var_ResourceGroup }}"
virtual_machine_name: "{{ var_vmname }}"
publisher: Microsoft.Compute
state: present
virtual_machine_extension_type: CustomScriptExtension
type_handler_version: "1.9"
auto_upgrade_minor_version: true
settings: '{"fileUris": ["{{ var_powershellscriptUrl }}"]}'
protected_settings: '{"commandToExecute": "[powershell -ExecutionPolicy Unrestricted -File {{PowershellUserScriptFileName }} -arg1 {{ Arrayofstring1 }} -arg2 {{ Arrayofstring2 }} -arg3 {{ Arrayofstring3 }} ]"}'
ignore_errors: true
以下代码的输出
- debug:
msg: {{ Arrayofstring1 }}
is \"VM1\", \"VM2\", \"VM3\"
执行剧本时遇到的错误是
"msg": "argument protected_settings 是 'str' 类型,我们是 无法转换为字典:无法将字符串评估为字典"}
问题是我应该如何将这些参数的数组从 ansible 传递给 powershell 代码?
【问题讨论】:
标签: azure powershell ansible