I’ve also just run into this. In my case though, I’m creating a “register:” variable in one play of a playbook (running on localhost and storing Volume IDs of created EC2 Volumes), and I want to refer to that variable in a subsequent play of the same playbook (which runs on the machine itself).
What’s the idiomatic ansible way of doing something like this?
I presume I could use the first play to store the info into a local temp file and then make use of that from the subsequent play to push up the data, but that seems fairly ugly.
(I’m new to and overall very happy with Ansible so far).
–Ben
P.S. the docs in “playbooks_variables.html” say “Registered variables are valid on the host the remainder of the playbook run”. IIUC in ansible, a ‘playbook’ is one “.yml” file, and it may contain many ‘plays’. If my understanding is correct, then this is a slight bug in the docs as it appears that registered variables are valid only for the rest of the ‘play’. (Unless the “on the host” part is what I’m missing and it’s the fact that the hosts are different which causes it not to be in scope…)
“P.S. the docs in “playbooks_variables.html” say “Registered variables are valid on the host the remainder of the playbook run”. IIUC in ansible, a ‘playbook’ is one “.yml” file, and it may contain many ‘plays’. If my understanding is correct, then this is a slight bug in the docs”
No, because this is not a variable that was saved as the result of a register keyword. Facts also work the same way.
“vars_files” pulls in variables only for the current play, by design, as do roles.