Problem:
Hello
Is it possible to execute an ansible playbook which exists on a smart proxy or foreman server?
I know that I can import a playbook/role to foreman, then assign that playbook to a host. Then execute them by using a Schedule a job button from which I select “Run Ansible Roles”
But this will execute ALL ansible roles which are associated with that host. I don’t want that.
Let’s suppose that I have some healthcheck playbook which checks if services are up, if not starts them, additionally it checks the configuration etc. Plus I have host reboot playbook.
I want to execute only one or another. It doesn’t make sense to execute them all if e.g. I want to only check the health of my vm by executing healthcheck playbook.
Plus, I don’t want to keep my playbook code in Foreman, without direct integration with source control, it’s error prone. I would like to execute imported playbook OR a playbook which exists on a smart proxy or foreman server. Is it possible ?
If not, can I create an input which will use imported playbook name as an argument, like following:
If yes, how can I use the playbook code in the template? By default Run playbook job has following code:
<%= input('playbook') %>
When I select my imported ansible playbook, it tries to execute Imported Ansible Job ID (an integer) rather than Ansible code.
Is there a field or method which I could use which would allow me to retrieve ansible playbook code, rather than id? By something like:
<%= input('playbook').code %>
<%= input('playbook').playbook %>
Is there anything like that?
Moreover, I know that in the job template I can select “Script” provider type and in the job template code just execute ansible-playbook binary. But selecting “Script” provider type forces me to select a smart proxy as a target host, not a host on which I would like to execute a playbook. Not all my hosts have ansible and its playbooks installed, and they shouldn’t. It doesn’t make sense of doing that.
Expected outcome:
Is it possible to select a host from the host line, click on schedule a job, and execute one playbook which exists on a smart proxy or foreman server.
Foreman and Proxy versions:
3.13