How to re-enable gather_facts later in a playbook

Dear ansible users,

I have a playbook that install a VM, so at the beginning og the playbook I use “gather_facts: no” because the VM is not yet ready, then I install the vm on the cluster using delegate_to, then once the vm is up I would like to continue some tasks on the vm but I need facts now.

Is this possible?

Hi,

you can either use gather_facts: yes if you provision VM in another play, or just call an setup module like:

  • name: Get VM facts
    setup:

I just tried, but it doesn’t works:

error while evaluating conditional: ansible_os_family == “Debian”

If I split the playbook and put tasks that needs fact in the second one with gather_facts yes, it works. I’ll go this way. Thanks for your help!