我有部署虚拟机的剧本。我想要延迟运行剧本,直到 vm 获得 IP 地址。我尝试制作循环但有错误。
tasks:
- vsphere_guest:
vcenter_hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
guest: "{{ inventory_hostname }}"
vmware_guest_facts: yes
validate_certs: no
register: vsphere_facts
until: vsphere_facts.ansible_facts.hw_eth0.ipaddresses[0] = "192.168.250.*"
retries: 20
delay: 60
{"failed": true, "msg": "条件检查 'vsphere_facts.ansible_facts.hw_eth0.ipaddresses[0] = \"192.168.250。\"' 失败。错误是:模板化字符串时出现模板错误:预期令牌'语句块结束',得到'='。字符串:{% if vsphere_facts.ansible_facts.hw_eth0.ipaddresses[0] = \"192.168.250 . \" %} 真 {% else %} 假 {% endif %}"}