Can ansible fetch updated facts in middle of a playbook?
<p>I'm having trouble running a full playbook because some of the facts later plays depend on are modified in earlier plays, but ansible doesn't update facts mid-run.</p>

<p>Running <code>ansible somehost -m setup</code> when the whole playbook starts against a new VPS:</p>

<pre><code>"ansible_selinux": {
    "status": "disabled"
}, 
</code></pre>

<p>My playbook contains a play that installs SELinux and reboots the server (while ansible wait_for's), and a later task uses the conditional <code>when: ansible_selinux.status != 'disabled'</code>. However even though SELinux is now installed and enforcing (which required the reboot) the facts for the system still show SELinux is disabled so that conditional fails and the task is skipped.</p>

<p>Running the playbook again of course works because facts are updated and now return:</p>

<pre><code>"ansible_selinux": {
    "config_mode": "enforcing", 
    "mode": "enforcing", 
    "policyvers": 28, 
    "status": "enabled", 
    "type": "targeted"
}
</code></pre>

<p>Is there any way to make facts refresh mid-playbook? Maybe the hack is to <code>set_fact</code> on ansible_selinux.status myself after the reboot?</p>

<p><strong>Update</strong>:
Well that was too easy, thanks to BruceP I added this task to fetch updated facts at the end of my SELinux play</p>

<pre><code>- name: SELinux - Force ansible to regather facts
  setup: filter='ansible_selinux'
</code></pre>