mirror of https://github.com/ansible/ansible.git
Add tests to validate vars_files first found behavior (#79386)
parent
ec3f6ed9b9
commit
7d35f70caf
@ -0,0 +1,2 @@
|
||||
shippable/posix/group3
|
||||
context/controller
|
@ -0,0 +1,3 @@
|
||||
[testgroup]
|
||||
testhost foo=bar
|
||||
testhost2 foo=baz
|
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ansible-playbook runme.yml -i inventory -v "$@"
|
@ -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
|
@ -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'
|
@ -0,0 +1 @@
|
||||
is_bar: yes
|
@ -0,0 +1 @@
|
||||
common: yes
|
@ -0,0 +1 @@
|
||||
is_bar: no
|
Loading…
Reference in New Issue