Use ansible-playbook as executor to include group_vars

We synced our Ansible repo including group_vars, inventory and roles into /etc/ansible of the smart proxy. It looks like this:
/group_vars/
/group_vars/all.yml
/inventory/int/
/inventory/int/group_vars/
/inventory/int/group_vars/all.yml
/inventory/int/host_vars/
/inventory/int/host_vars/tst01.yml
/inventory/int/hosts
/roles/
/roles/common/
/site-common.yml

Running Foreman Job to apply Ansible role (common) to VM tst01, it uses ansible-runner. It creates it’s environment unter working_dir (etc/ansible/foreman/).
Certainly, the play does not include variables located under /etc/ansible/group_vars/all.yml

I am looking for a way to switch from ansible-runner to ansible-playbook, to execute /etc/ansible/site-common.yml or to include those group variables into the ansible-runner job.

We are using Foreman v3.7.1 and Ansible v2.14.2

Hello, how many of such variables you have there? Would it be possible to rather define them in Foreman parametrization system (Ansible Variables)? Combining the two approaches feels a bit hard, though I can understand that editting vars in yaml may be easier to e.g. version.

Hi Marek,
thanks for answering.
There are quite a lot of variables including lists and dicts. Defining all those “global” parameters as role parameters (to have them imported via GUI) would be possible, but eliminates the thought of inheriting variables in our quite big environment.
The easiest approach is to execute playbook from /etc/ansible, but I don’t know how to tell Foreman job (template) to do so.
The workaround would be to trigger Jenkins or some other tool, to execute all relevant Ansible host roles. But wouldn’t it be nice to have Foreman done this automatically after the host is created? :slight_smile: