mirror of
https://github.com/zebrajr/ansible.git
synced 2025-12-06 00:19:48 +01:00
Add tests to validate vars_files first found behavior (#79386)
This commit is contained in:
parent
ec3f6ed9b9
commit
7d35f70caf
2
test/integration/targets/vars_files/aliases
Normal file
2
test/integration/targets/vars_files/aliases
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
shippable/posix/group3
|
||||
context/controller
|
||||
3
test/integration/targets/vars_files/inventory
Normal file
3
test/integration/targets/vars_files/inventory
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[testgroup]
|
||||
testhost foo=bar
|
||||
testhost2 foo=baz
|
||||
5
test/integration/targets/vars_files/runme.sh
Executable file
5
test/integration/targets/vars_files/runme.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ansible-playbook runme.yml -i inventory -v "$@"
|
||||
22
test/integration/targets/vars_files/runme.yml
Normal file
22
test/integration/targets/vars_files/runme.yml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
- hosts: testgroup
|
||||
gather_facts: no
|
||||
vars_files:
|
||||
- "vars/common.yml"
|
||||
-
|
||||
- "vars/{{ foo }}.yml"
|
||||
- "vars/defaults.yml"
|
||||
tasks:
|
||||
- import_tasks: validate.yml
|
||||
|
||||
- hosts: testgroup
|
||||
gather_facts: no
|
||||
vars:
|
||||
_vars_files:
|
||||
- 'vars/{{ foo }}.yml'
|
||||
- 'vars/defaults.yml'
|
||||
vars_files:
|
||||
- "vars/common.yml"
|
||||
- "{{ lookup('first_found', _vars_files) }}"
|
||||
tasks:
|
||||
- import_tasks: validate.yml
|
||||
11
test/integration/targets/vars_files/validate.yml
Normal file
11
test/integration/targets/vars_files/validate.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
- assert:
|
||||
that:
|
||||
- common is true
|
||||
- assert:
|
||||
that:
|
||||
- is_bar is true
|
||||
when: inventory_hostname == 'testhost'
|
||||
- assert:
|
||||
that:
|
||||
- is_bar is false
|
||||
when: inventory_hostname == 'testhost2'
|
||||
1
test/integration/targets/vars_files/vars/bar.yml
Normal file
1
test/integration/targets/vars_files/vars/bar.yml
Normal file
|
|
@ -0,0 +1 @@
|
|||
is_bar: yes
|
||||
1
test/integration/targets/vars_files/vars/common.yml
Normal file
1
test/integration/targets/vars_files/vars/common.yml
Normal file
|
|
@ -0,0 +1 @@
|
|||
common: yes
|
||||
1
test/integration/targets/vars_files/vars/defaults.yml
Normal file
1
test/integration/targets/vars_files/vars/defaults.yml
Normal file
|
|
@ -0,0 +1 @@
|
|||
is_bar: no
|
||||
Loading…
Reference in New Issue
Block a user