I have a playbook that checks to see if ansible can ssh to a VM. If it
cannot, it assigns a role of deploy_vm_from_template to the host. During
the process of deploying the VM the host gets booted, the network is
configured and I verify that ansible can ssh to the host before continuing
with other roles.
Everything worked fine, until I decided I needed to restart sssd after
verifying that I could ssh to the host. What I found is that once, I
could ssh to the host, every task in the role deploy_vm_from_template was
skipped. It appears that the "when: result|failed" triggers when "result"
is updated in my until loop in the role. I verified this by changing
"result" in the playbook to "result_in_playbook" and the tasks after the
until loop began running instead of being skipped.
My question, is this a bug or a feature? This seems like it could be a
very powerful feature. It seems like result is a widely used variable.
Should I be using more unique variables to avoid this situation?
# From the playbook
pre_tasks:
- name: "See if we can ssh to {{ inventory_hostname }} before
attempting to build it"
local_action: command ssh -o ConnectTimeout=10 servacct_ansible@{{
inventory_hostname }} hostname
register: result
ignore_errors: yes
roles:
- { role: deploy_vm_from_template, when: result|failed }
#From the role
- name: "Wait for {{ inventory_hostname }} to recognize
servacct_ansible account"
register: result
until: result.rc == 0
retries: 30
delay: 10
- name: Test ping module
ping:
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/d21e09b7-bdc6-4356-a680-635b117de76d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.