Hi,
I need to integrate Ansible into our automation platform. I’m planning to create an Flask service that uses ansible-runner to run the playbooks. I’m wondering how I should implement the variable set of hosts where my playbook need to run? At the moment I see two solutions:
- Via the inventory. I can generate a custom inventory for every run and configure the ‘hosts’ in the playbook file as ‘all’. This way of working is okay but will cause problems when I’m using things like ‘delegate_to’, because you can’t delegate to a host which is not defined in the inventory. (I know there are workarounds but I like to do it properly.)
- Via the hosts parameter in the playbook file. I could modify the playbook before every run and set a custom value for the hosts parameter. Then I can use the same full (static) inventory for every run. This looks like a good solution but I never saw anyone using this on the internet and I’m not sure if this is the intended way of doing it?
I know both options could work, but I’m interested to know the proper way of doing it. Also if there are other ways to tackle this problem I’m interested to know how.
Kind Regards
Sander Descamps