Add ability to look up inventory sources by org name/ID

This commit is contained in:
beeankha
2020-09-01 11:35:37 -04:00
parent 65e0ed8c77
commit 1ce5d7d539
4 changed files with 56 additions and 4 deletions

View File

@@ -9,13 +9,20 @@
inv_name: "AWX-Collection-tests-tower_inventory_source_update-inv-{{ test_id }}"
inv_source1: "AWX-Collection-tests-tower_inventory_source_update-source1-{{ test_id }}"
inv_source2: "AWX-Collection-tests-tower_inventory_source_update-source2-{{ test_id }}"
org_name: "AWX-Collection-tests-tower_inventory_source_update-org-{{ test_id }}"
- block:
- name: "Create a new organization"
tower_organization:
name: "{{ org_name }}"
register: created_org
- name: Create a git project without credentials
tower_project:
name: "{{ project_name }}"
organization: Default
organization: "{{ org_name }}"
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
wait: true
@@ -23,7 +30,14 @@
- name: Create an Inventory
tower_inventory:
name: "{{ inv_name }}"
organization: Default
organization: "{{ org_name }}"
state: present
register: created_inventory
- name: Create another inventory w/ same name
tower_inventory:
name: "{{ inv_name }}"
organization: "{{ org_name }}"
state: present
register: created_inventory
@@ -34,21 +48,24 @@
source_project: "{{ project_name }}"
source_path: inventories/inventory.ini
description: Source for Test inventory
organization: "{{ created_org.id }}"
inventory: "{{ inv_name }}"
- name: Create Another Inventory Source
- name: Create Another Inventory Source (for testing org-based lookup)
tower_inventory_source:
name: "{{ inv_source2 }}"
source: scm
source_project: "{{ project_name }}"
source_path: inventories/create_10_hosts.ini
description: Source for Test inventory
organization: Default
inventory: "{{ inv_name }}"
- name: Test Inventory Source Update
tower_inventory_source_update:
inventory: "{{ inv_name }}"
inventory_source: "{{ inv_source1 }}"
organization: Default
register: result
- assert:
@@ -59,6 +76,7 @@
tower_inventory_source_update:
inventory: "{{ inv_name }}"
inventory_source: "{{ item }}"
organization: "{{ created_org.id }}"
loop: "{{ query('awx.awx.tower_api', 'inventory_sources', query_params={ 'inventory': created_inventory.id }, return_ids=True ) }}"
register: result
@@ -78,3 +96,8 @@
name: "{{ project_name }}"
organization: Default
state: absent
- name: "Remove the organization"
tower_organization:
name: "{{ org_name }}"
state: absent