1
votes

I have playbook which deploy vitrual machine. I want delay run playbook until vm get ip-address. I try make loop but have error.

  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": "The conditional check 'vsphere_facts.ansible_facts.hw_eth0.ipaddresses[0] = \"192.168.250.\"' failed. The error was: template error while templating string: expected token 'end of statement block', got '='. String: {% if vsphere_facts.ansible_facts.hw_eth0.ipaddresses[0] = \"192.168.250.\" %} True {% else %} False {% endif %}"}

1
Try == instead of =... And this will not work because of *. You need to use match filter.Konstantin Suvorov
@KonstantinSuvorov yep, == working. Please, give an example match or give an URL, as i don't could not findNikita

1 Answers

3
votes

You should opt for:

until: vsphere_facts.ansible_facts.hw_eth0.ipaddresses[0] | match("192.168.250.")

Direct comparison (with ==) can't handle wildcards like *.