2020-02-29 00:49:55 +03:00
---
2020-03-17 21:49:09 +03:00
- name : Generate names
2020-01-20 06:15:14 +03:00
set_fact :
2020-03-31 19:11:53 +03:00
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') }}"
2020-03-17 21:49:09 +03:00
inv_name : "AWX-Collection-test-tower_group-inv-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
2020-03-31 19:11:53 +03:00
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') }}"
2020-01-20 06:15:14 +03:00
- name : Create an Inventory
tower_inventory :
name : "{{ inv_name }}"
organization : Default
state : present
- name : Create a Group
tower_group :
2020-03-31 19:11:53 +03:00
name : "{{ group_name1 }}"
2020-01-20 06:15:14 +03:00
inventory : "{{ inv_name }}"
state : present
2020-02-29 00:49:55 +03:00
variables :
foo : bar
2020-01-20 06:15:14 +03:00
register : result
- assert :
that :
- "result is changed"
- name : Delete a Group
tower_group :
2020-03-31 19:11:53 +03:00
name : "{{ group_name1 }}"
2020-01-20 06:15:14 +03:00
inventory : "{{ inv_name }}"
state : absent
register : result
- assert :
that :
- "result is changed"
- name : Check module fails with correct msg
tower_group :
name : test-group
description : Group Description
inventory : test-non-existing-inventory
state : present
register : result
ignore_errors : true
- assert :
that :
2020-02-29 00:49:55 +03:00
- "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'"
2020-03-31 19:11:53 +03:00
- 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