Search code examples
ansibleansible-inventoryansible-awxansible-tower

How can I limit the hosts in a Template on AWX?


The hosts which I address in the Playbook maint-change.yml belong to two Groups (instancegroup1 & instancegroup2 with sveral hosts in each group) like this:

- hosts: "{{ server | default('instancegroup1 instancegroup2') }}"

So if I just want to run the Playbook against one host I will limit with (-e EXTRA_VARS) the variable server and the hostname from the instance:

ansible-playbook maint-change.yml -e server=test.instance2

In that Case the "test.instance2" is listet in the inventory file of instancegroup2 and the playbook will only run against the host "test.instance2" successfully.

But how is is that possible with awx? If I have created the template with the same Playbook "maint-change.yml" which is using the variable server as I mentioned above, it's not possible to paste the "server=test.instance2" in the EXTRA VARIABLES field of the Template. Is there any Solution to set the specific variable server from the Playbook in the EXTRA VARIABLES field from awx's Template?


Solution

  • I believe you are using AWX Job templates. You can use the limit check option in your templates. Here's a screenshot of that - enter image description here