ansible / ansible-runner

A tool and python library that helps when interfacing with Ansible directly or as part of another system whether that be through a container image interface, as a standalone tool, or as a Python module that can be imported. The goal is to provide a stable and consistent interface abstraction to Ansible.
Other
964 stars 355 forks source link

how to set host_vars with ansible-runner #881

Closed Drewolf closed 3 years ago

Drewolf commented 3 years ago

I have a playbook that uses variables in the host_vars directory。like this:

cat /etc/ansible/host_vars/foosball

ntp_server: acme.example.org
database_server: storage.example.org

so, how to set host_vars with ansible-runner ?

samdoran commented 3 years ago

Inventory variables for runner are no different than defining inventory variables in Ansible Core. The host_vars directory needs to be adjacent to the inventory file.

By default, Runner looks in <private_data_dir>/inventory for inventory. If it is somewhere else, specify the location:

ansible-runner run --inventory /etc/ansible/hosts ...

To discuss this further, please reach out on IRC #ansible-runner on irc.libera.chat.