I’d like to re-use reboot_hint in additional plays in the playbook via “when”, but the playbook ultimately fails after the first “when”, as in:
hosts: talk
gather_facts: false
tasks:
name: start Lyris services
win_service: name={{ item }} state=started start_mode=auto
with_items: [“ListManager”, “LyrisAlert”]
when: (lyris_hint.rc == 0) and (reboot_hint.reboot_required == true) # ie, the ListManager service is installed and reboot is required
I’ve found that my register variable only fails when applied to the play involving another host in my playbook. After having poured over lots of posts from various other sources, I saw one that says, “use hostvars to access the register variables from a different host”. If, indeed, that’s the solution, how do I use hostvars to achieve it?
Since “reboot_hint” is coming from the previous play, and since the host or group to run the playbook against is defined at the command line, as in: “ansible-playbook -l lyris myplaybook.yml -u myuser”, what do I specify in the [myhost] section? This must be a variable to accept the host name OR group name I specified at the command line, but I don’t know what that would be.
Further, and maybe another post altogether, how do I make the substitution in “with_items: “{{ groups[‘lyris’] }}”” so that I don’t have to change e.g. lyris is I’m specifying another host or group in running the playbook?