If I have a task
- name: foo
…
register: foo_result
can I interrogate that result in a when:
in pretty much any task or handler in my playbook that comes after or is the usage confined to the play I am in (or confined in some other way)?
I’d like to have a play upfront which runs a role on all hosts. I’m hoping that for each host, I will get foo_result for use in subsequent plays which invoke various roles.
- hosts: all
roles: - common
- hosts: some
roles: - some
- hosts: more
roles: - more
So, if I register foo_result in a task in roles/common/main.yml, can I do a when: foo_result.changed
in roles some
and more
?
Can I use foo_result.changed
in subsequent plays in handlers, post_tasks, etc, too?
Note that foo_result
can be different for each hosts. I’m hoping that this will all work as I want, that for each host I can use foo_result everywhere and that hosts’ specific value of foo_result will be available. Sorry if this is obvious or if I missed the answer in the docs somewhere.
Thanks,
Skylar