Example playbook that automates AWX REST API interactions to disable or remove a host from static inventory.
- Discover inventory id
- Discover host id
- Disable host in static inventory (if declared by variable)
- Remove host in static inventory (if declared by variable)
For inventory id, by default it uses internal variables from Ansible Tower and AWX (e.g. awx_inventory_name).
Ansible Tower/AWX access.
The awx-api-inventory playbook is configured over variables starting with api_
as the name prefix.
List of variables:
Variable | Type | Description |
---|---|---|
api_awx_url |
string (m) | AWX/Tower URL |
api_awx_username |
string (m) | AWX/Tower user name |
api_awx_password |
string (m) | AWX/Tower user password |
api_awx_inventory |
string (m) | AWX/Tower inventory name to be manage |
api_inventory_disable |
boolean (o) | Disable the managed host in inventory |
api_inventory_remove |
boolean (o) | Remove the managed host from inventory |
(m) - mandatory
(o) - optional
Explained list of variables:
-
api_awx_url
: AWX/Tower URLtype: string
affected files: n/a
example:
api_awx_url: "https://awx.example.com"
-
api_awx_username
: AWX/Tower user nametype: string
affected files: n/a
example:
api_awx_username: admin
-
api_awx_password
: AWX/Tower user passwordtype: string
affected files: n/a
example:
api_awx_password: mypassword
-
api_awx_inventory
: AWX/Tower inventory name to be managed, default value is dynamictype: string
affected files: n/a
example:
api_awx_inventory: Example Inventory
-
api_inventory_disable
: disable the managed node in inventorytype: boolean
affected files: n/a
example:
api_inventory_disable: no
-
api_inventory_remove
: remove the managed node from inventorytype: boolean
affected files: n/a
example:
api_inventory_remove: no
MIT
This playbook was created in 2019 by Cláudio Domingos