How can I force the process of fact gathering?

Hi!

Scenario:
An ansible play modifies the facts of a box (i.e., by configuring the
secondary interface of an AWS instance), rendering the previously
gathered facts for that box inaccurate (the IP address of the
secondary interface just configured won't be available).

How can I tell ansible to gather again the facts for this box? Is it
ok to call the setup module directly?

Thanks a bunch!

Cheers,

Sure, at any point in a playbook you can just do:

  • action: setup

To re-call the setup module, and that will do what you want.

Starting another play that has “gather_facts:” not specified (default is enabled) or enabled will also do the same thing.

Hope this helps!

–Michael

Use setup module in a task

Brian Coca

Works like a charm.

Thanks, Michael!

Thanks, Brian!