mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add integration tests for group_by precedence.
Test that, when a group is created with group_by, variables from the corresponding group_vars/ file are correctly pulled in, and override variables specified in group_vars/all. See ansible/ansible#8664.
This commit is contained in:
parent
0715430829
commit
7fb1519035
4 changed files with 66 additions and 1 deletions
1
test/integration/targets/group_by/group_vars/camelus
Normal file
1
test/integration/targets/group_by/group_vars/camelus
Normal file
|
@ -0,0 +1 @@
|
|||
dos: 'two'
|
1
test/integration/targets/group_by/group_vars/vicugna
Normal file
1
test/integration/targets/group_by/group_vars/vicugna
Normal file
|
@ -0,0 +1 @@
|
|||
tres: 'three'
|
|
@ -1,3 +1,6 @@
|
|||
# ungrouped
|
||||
camel genus=camelus ansible_connection=local
|
||||
|
||||
[lamini]
|
||||
alpaca genus=vicugna
|
||||
llama genus=lama
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: Create overall groups
|
||||
hosts: lamini
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- debug: var=genus
|
||||
|
@ -51,6 +51,15 @@
|
|||
- name: set a fact to check that we ran this play
|
||||
set_fact: genus_lama=true
|
||||
|
||||
- name: Camelus group validation
|
||||
hosts: camelus
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: verify that only the camel is in this group
|
||||
assert: { that: "inventory_hostname == 'camel'" }
|
||||
- name: set a fact to check that we ran this play
|
||||
set_fact: genus_camelus=true
|
||||
|
||||
- name: Vic group validation
|
||||
hosts: vic
|
||||
gather_facts: false
|
||||
|
@ -69,6 +78,15 @@
|
|||
- name: set a fact to check that we ran this play
|
||||
set_fact: genus_lam=true
|
||||
|
||||
- name: Cam group validation
|
||||
hosts: cam
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: verify that only the camel is in this group
|
||||
assert: { that: "inventory_hostname == 'camel'" }
|
||||
- name: set a fact to check that we ran this play
|
||||
set_fact: genus_cam=true
|
||||
|
||||
- name: Vi group validation
|
||||
hosts: vi
|
||||
gather_facts: false
|
||||
|
@ -87,6 +105,15 @@
|
|||
- name: set a fact to check that we ran this play
|
||||
set_fact: genus_la=true
|
||||
|
||||
- name: Ca group validation
|
||||
hosts: ca
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: verify that only the camel is in this group
|
||||
assert: { that: "inventory_hostname == 'camel'" }
|
||||
- name: set a fact to check that we ran this play
|
||||
set_fact: genus_ca=true
|
||||
|
||||
- name: VICUGNA group validation
|
||||
hosts: VICUGNA
|
||||
gather_facts: false
|
||||
|
@ -105,6 +132,15 @@
|
|||
- name: set a fact to check that we ran this play
|
||||
set_fact: genus_LAMA=true
|
||||
|
||||
- name: CAMELUS group validation
|
||||
hosts: CAMELUS
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: verify that only the camel is in this group
|
||||
assert: { that: "inventory_hostname == 'camel'" }
|
||||
- name: set a fact to check that we ran this play
|
||||
set_fact: genus_CAMELUS=true
|
||||
|
||||
- name: genus group validation (expect skipped)
|
||||
hosts: 'genus'
|
||||
gather_facts: false
|
||||
|
@ -125,3 +161,27 @@
|
|||
tasks:
|
||||
- name: check that llama matched all four groups
|
||||
assert: { that: ["genus_lama", "genus_lam", "genus_la", "genus_LAMA"] }
|
||||
|
||||
- hosts: camel
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: check that camel matched all four groups
|
||||
assert: { that: ["genus_camelus", "genus_cam", "genus_ca", "genus_CAMELUS"] }
|
||||
|
||||
- hosts: vicugna
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: check group_vars variable overrides for vicugna
|
||||
assert: { that: ["uno == 1", "dos == 2", "tres == 'three'"] }
|
||||
|
||||
- hosts: lama
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: check group_vars variable overrides for lama
|
||||
assert: { that: ["uno == 1", "dos == 2", "tres == 3"] }
|
||||
|
||||
- hosts: camelus
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: check group_vars variable overrides for camelus
|
||||
assert: { that: ["uno == 1", "dos == 'two'", "tres == 3"] }
|
||||
|
|
Loading…
Reference in a new issue