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]
|
[lamini]
|
||||||
alpaca genus=vicugna
|
alpaca genus=vicugna
|
||||||
llama genus=lama
|
llama genus=lama
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: Create overall groups
|
- name: Create overall groups
|
||||||
hosts: lamini
|
hosts: all
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
- debug: var=genus
|
- debug: var=genus
|
||||||
|
@ -51,6 +51,15 @@
|
||||||
- name: set a fact to check that we ran this play
|
- name: set a fact to check that we ran this play
|
||||||
set_fact: genus_lama=true
|
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
|
- name: Vic group validation
|
||||||
hosts: vic
|
hosts: vic
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
@ -69,6 +78,15 @@
|
||||||
- name: set a fact to check that we ran this play
|
- name: set a fact to check that we ran this play
|
||||||
set_fact: genus_lam=true
|
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
|
- name: Vi group validation
|
||||||
hosts: vi
|
hosts: vi
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
@ -87,6 +105,15 @@
|
||||||
- name: set a fact to check that we ran this play
|
- name: set a fact to check that we ran this play
|
||||||
set_fact: genus_la=true
|
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
|
- name: VICUGNA group validation
|
||||||
hosts: VICUGNA
|
hosts: VICUGNA
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
@ -105,6 +132,15 @@
|
||||||
- name: set a fact to check that we ran this play
|
- name: set a fact to check that we ran this play
|
||||||
set_fact: genus_LAMA=true
|
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)
|
- name: genus group validation (expect skipped)
|
||||||
hosts: 'genus'
|
hosts: 'genus'
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
@ -125,3 +161,27 @@
|
||||||
tasks:
|
tasks:
|
||||||
- name: check that llama matched all four groups
|
- name: check that llama matched all four groups
|
||||||
assert: { that: ["genus_lama", "genus_lam", "genus_la", "genus_LAMA"] }
|
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