mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
pycharm refactor rename files and class, linux rename tower_ controller_
This commit is contained in:
193
awx_collection/tests/integration/targets/group/tasks/main.yml
Normal file
193
awx_collection/tests/integration/targets/group/tasks/main.yml
Normal file
@@ -0,0 +1,193 @@
|
||||
---
|
||||
- name: Generate names
|
||||
set_fact:
|
||||
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:
|
||||
name: "{{ inv_name }}"
|
||||
organization: Default
|
||||
state: present
|
||||
register: result
|
||||
|
||||
- name: Create a Group
|
||||
tower_group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ result.id }}"
|
||||
state: present
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a Group
|
||||
tower_group:
|
||||
name: "{{ group_name2 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: present
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a Group
|
||||
tower_group:
|
||||
name: "{{ group_name3 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: present
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: add hosts
|
||||
tower_host:
|
||||
name: "{{ item }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
loop:
|
||||
- "{{ host_name1 }}"
|
||||
- "{{ host_name2 }}"
|
||||
- "{{ host_name3 }}"
|
||||
|
||||
- name: Create a Group with hosts and sub group
|
||||
tower_group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
hosts:
|
||||
- "{{ host_name1 }}"
|
||||
- "{{ host_name2 }}"
|
||||
children:
|
||||
- "{{ group_name2 }}"
|
||||
state: present
|
||||
variables:
|
||||
foo: bar
|
||||
register: result
|
||||
|
||||
- name: Create a Group with hosts and sub group
|
||||
tower_group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
hosts:
|
||||
- "{{ host_name3 }}"
|
||||
children:
|
||||
- "{{ group_name3 }}"
|
||||
state: present
|
||||
preserve_existing_hosts: true
|
||||
preserve_existing_children: true
|
||||
register: result
|
||||
|
||||
- name: "Find number of hosts in {{ group_name1 }}"
|
||||
set_fact:
|
||||
group1_host_count: "{{ lookup('awx.awx.tower_api', 'groups/{{result.id}}/all_hosts/') |length}}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- group1_host_count == "3"
|
||||
|
||||
- name: Delete a Group
|
||||
tower_group:
|
||||
name: "{{ group_name1 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete a Group
|
||||
tower_group:
|
||||
name: "{{ group_name2 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete a Group
|
||||
tower_group:
|
||||
name: "{{ group_name3 }}"
|
||||
inventory: "{{ inv_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is not 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:
|
||||
- "result is failed"
|
||||
- "result is not changed"
|
||||
- "'test-non-existing-inventory' in result.msg"
|
||||
- "result.total_results == 0"
|
||||
|
||||
- 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
|
||||
Reference in New Issue
Block a user