How do registered variables behave across plays and hosts?
IntermediateConceptVariables, Facts and Precedence
Answer
A registered variable is stored per host and stays available for the rest of the playbook run, including later plays on that host. It is not visible to other hosts directly, but you can read it through hostvars['web1']['result'].
It is lost when the run ends (unless set_fact with cacheable). A skipped task still registers a result with skipped: true, so check result is skipped or result.skipped before using result.stdout.
More on Variables, Facts and Precedence
Where can you define variables in Ansible?BeginnerHow do you reference a variable, and when must you quote it?BeginnerGive a summary of variable precedence.IntermediateWhat are the lowest and highest precedence sources, and why does that matter?IntermediateWhat is the difference between a role's `defaults/` and `vars/`?IntermediateWhat are facts and how are they gathered?Beginner