Skip to content

Commit

Permalink
Adding changelog fragment and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tachyontec committed Jun 20, 2023
1 parent 6d9de88 commit d74edfb
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/80995-include-all-var-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- include_vars.py - Ensured that all files specified in the directory are included and that we iterate over all files (https://github.com/ansible/ansible/issues/80987).
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var1: sub1var1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insidevar11-2: config11-2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insidevar1: config11
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var12: sub1var2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var21: sub21
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insidevar2: config211
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insidervariable: config212
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
variable3: config3
19 changes: 19 additions & 0 deletions test/integration/targets/include_vars-ad-hoc/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- name: Include vars example
hosts: localhost

tasks:
- name: Include all yml configuration files from folder "{{ my_config_folder }}"
vars:
my_config_folder: "dir/"
ansible.builtin.include_vars:
dir: "{{ my_config_folder }}"
extensions:
- 'yml'
- 'yaml'
ignore_unknown_extensions: 'yes'
depth: 3
name: my_include_vars

- name: Print included params
debug:
var: my_include_vars
18 changes: 18 additions & 0 deletions test/integration/targets/include_vars-ad-hoc/runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,21 @@ set -eux

ansible testhost -i ../../inventory -m include_vars -a 'dir/inc.yml' "$@"
ansible testhost -i ../../inventory -m include_vars -a 'dir=dir' "$@"

ansible-playbook playbook.yml>output.txt
if grep -q '"insidervariable": "config212",' output.txt && \
grep -q '"insidevar1": "config11",' output.txt && \
grep -q '"insidevar11-2": "config11-2",' output.txt && \
grep -q '"insidevar2": "config211",' output.txt && \
grep -q '"porter": "cable",' output.txt && \
grep -q '"var1": "sub1var1",' output.txt && \
grep -q '"var12": "sub1var2",' output.txt && \
grep -q '"var21": "sub21",' output.txt && \
grep -q '"variable3": "config3"' output.txt; then
echo "All lines are present in output.txt"
rm output.txt
exit 0
fi
echo "One or more lines are missing from output.txt"
rm output.txt
exit 1

0 comments on commit d74edfb

Please sign in to comment.