From 04ccff0e3fe6b10d0da474b114d5f5d5d9d060e7 Mon Sep 17 00:00:00 2001 From: Caleb Boylan Date: Tue, 31 Mar 2020 09:11:53 -0700 Subject: [PATCH] Collection: add tower_group child group tests --- .../targets/tower_group/tasks/main.yml | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/awx_collection/tests/integration/targets/tower_group/tasks/main.yml b/awx_collection/tests/integration/targets/tower_group/tasks/main.yml index 8feffbfd28..38e76719cf 100644 --- a/awx_collection/tests/integration/targets/tower_group/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_group/tasks/main.yml @@ -1,8 +1,13 @@ --- - name: Generate names set_fact: - group_name: "AWX-Collection-tests-tower_group-group-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + group_name1: "AWX-Collection-tests-tower_group-group-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + group_name2: "AWX-Collection-tests-tower_group-group-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + group_name3: "AWX-Collection-tests-tower_group-group-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" inv_name: "AWX-Collection-test-tower_group-inv-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + host_name1: "AWX-Collection-test-tower_group-host-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + host_name2: "AWX-Collection-test-tower_group-host-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + host_name3: "AWX-Collection-test-tower_group-host-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - name: Create an Inventory tower_inventory: @@ -12,7 +17,7 @@ - name: Create a Group tower_group: - name: "{{ group_name }}" + name: "{{ group_name1 }}" inventory: "{{ inv_name }}" state: present variables: @@ -25,7 +30,7 @@ - name: Delete a Group tower_group: - name: "{{ group_name }}" + name: "{{ group_name1 }}" inventory: "{{ inv_name }}" state: absent register: result @@ -47,3 +52,47 @@ that: - "result.msg =='Failed to update the group, inventory not found: The requested object could not be found.' or result.msg =='The inventories test-non-existing-inventory was not found on the Tower server'" + +- name: add hosts + tower_host: + name: "{{ item }}" + inventory: "{{ inv_name }}" + loop: + - "{{ host_name1 }}" + - "{{ host_name2 }}" + - "{{ host_name3 }}" + +- name: add mid level group + tower_group: + name: "{{ group_name2 }}" + inventory: "{{ inv_name }}" + hosts: + - "{{ host_name3 }}" + +- name: add top group + tower_group: + name: "{{ group_name3 }}" + inventory: "{{ inv_name }}" + hosts: + - "{{ host_name1 }}" + - "{{ host_name2 }}" + children: + - "{{ group_name2 }}" + +- name: Delete the parent group + tower_group: + name: "{{ group_name3 }}" + inventory: "{{ inv_name }}" + state: absent + +- name: Delete the child group + tower_group: + name: "{{ group_name2 }}" + inventory: "{{ inv_name }}" + state: absent + +- name: Delete an Inventory + tower_inventory: + name: "{{ inv_name }}" + organization: Default + state: absent