From 75443b209451ea448ee63d6d78bdf7bf05f2ef9a Mon Sep 17 00:00:00 2001 From: jaevans Date: Wed, 13 Jun 2018 10:00:05 -0700 Subject: [PATCH] Add support for Tower Smart inventories (#41458) * Support Smart Inventories Add kind and host_filter fields and pass through to tower_cli. * Add documentation for new Smart Inventories options * Add missing description header for host_filter documentation * Add version added tags to new options * Bumped vesion_added to 2.7 --- .../ansible_tower/tower_inventory.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py index c05d93e6657..dffbdc37c86 100644 --- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py +++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py @@ -37,6 +37,16 @@ options: variables: description: - Inventory variables. Use C(@) to get from file. + kind: + description: + - The kind field. Cannot be modified after created. + default: "" + choices: ["", "smart"] + version_added: "2.7" + host_filter: + description: + - The host_filter field. Only useful when C(kind=smart). + version_added: "2.7" state: description: - Desired state of the resource. @@ -75,6 +85,8 @@ def main(): description=dict(), organization=dict(required=True), variables=dict(), + kind=dict(choices=['', 'smart'], default=''), + host_filter=dict(), state=dict(choices=['present', 'absent'], default='present'), )) @@ -88,6 +100,8 @@ def main(): organization = module.params.get('organization') variables = module.params.get('variables') state = module.params.get('state') + kind = module.params.get('kind') + host_filter = module.params.get('host_filter') json_output = {'inventory': name, 'state': state} @@ -102,7 +116,8 @@ def main(): if state == 'present': result = inventory.modify(name=name, organization=org['id'], variables=variables, - description=description, create_on_missing=True) + description=description, kind=kind, host_filter=host_filter, + create_on_missing=True) json_output['id'] = result['id'] elif state == 'absent': result = inventory.delete(name=name, organization=org['id'])