--- - name: the first play hosts: localhost tasks: - name: show foobar fact before debug: var: ansible_foobar - name: set a persistent fact foobar set_fact: ansible_foobar: 'blippy' cacheable: true - name: show foobar fact after debug: var: ansible_foobar - name: assert ansible_foobar is correct value assert: that: - ansible_foobar == 'blippy' - name: set a non persistent fact that will not be cached set_fact: ansible_foobar_not_cached: 'this_should_not_be_cached' - name: show ansible_foobar_not_cached fact after being set debug: var: ansible_foobar_not_cached - name: assert ansible_foobar_not_cached is correct value assert: that: - ansible_foobar_not_cached == 'this_should_not_be_cached' - name: the second play hosts: localhost tasks: - name: show foobar fact after second play debug: var: ansible_foobar - name: assert ansible_foobar is correct value assert: that: - ansible_foobar == 'blippy'