meta: refresh_inventory to support conditions

Hi All,

We want to remove some duplicate code which is available in our custom Inventory as well as in Ansible Playbook.

meta: refresh_inventory is what we need but it lacks conditional support. Is there a specific reason for this?

Looking at the code one possible solution will be to add _evaluate_conditional(target_host) for the meta_action == ‘refresh_inventory’? I’m happy to create a PR for this functionality.

Hi George,

There is a way to skip the refresh_inventory meta action with dynamic include task statement.

All you have to do is:

  1. Create new file, for example: refresh_inventory.yml
  2. Add include statement with argument static: no and your condition

This will resolve the ‘refresh_inventory.yml’ just before it is included, but not at compile time.

You can check an example here: https://gist.github.com/cnicolov/0969a99809ec58a9df26024297067c38

Regards,
Kristiyan

понеделник, 6 март 2017 г., 15:10:28 UTC+2, George Yanev написа:

Thanks Kristiyan. Tested your solution and it’s working.