summaryrefslogtreecommitdiff
path: root/test/integration/targets/lookup_first_found/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/lookup_first_found/tasks/main.yml')
-rw-r--r--test/integration/targets/lookup_first_found/tasks/main.yml53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_first_found/tasks/main.yml b/test/integration/targets/lookup_first_found/tasks/main.yml
index 9aeaf1d1..ba248bd5 100644
--- a/test/integration/targets/lookup_first_found/tasks/main.yml
+++ b/test/integration/targets/lookup_first_found/tasks/main.yml
@@ -94,3 +94,56 @@
- assert:
that:
- foo is defined
+
+# TODO: no 'terms' test
+- name: test first_found lookup with no terms
+ set_fact:
+ no_terms: "{{ query('first_found', files=['missing1', 'hosts', 'missing2'], paths=['/etc'], errors='ignore') }}"
+
+- assert:
+ that: "no_terms|first == '/etc/hosts'"
+
+- name: handle templatable dictionary entries
+ block:
+
+ - name: Load variables specific for OS family
+ assert:
+ that:
+ - "item is file"
+ - "item|basename == 'itworks.yml'"
+ with_first_found:
+ - files:
+ - "{{ansible_id}}-{{ansible_lsb.major_release}}.yml" # invalid var, should be skipped
+ - "{{ansible_lsb.id}}-{{ansible_lsb.major_release}}.yml" # does not exist, but should try
+ - "{{ansible_distribution}}-{{ansible_distribution_major_version}}.yml" # does not exist, but should try
+ - itworks.yml
+ - ishouldnotbefound.yml # this exist, but should not be found
+ paths:
+ - "{{role_path}}/vars"
+
+ - name: Load variables specific for OS family, but now as list of dicts, same options as above
+ assert:
+ that:
+ - "item is file"
+ - "item|basename == 'itworks.yml'"
+ with_first_found:
+ - files:
+ - "{{ansible_id}}-{{ansible_lsb.major_release}}.yml"
+ paths:
+ - "{{role_path}}/vars"
+ - files:
+ - "{{ansible_lsb.id}}-{{ansible_lsb.major_release}}.yml"
+ paths:
+ - "{{role_path}}/vars"
+ - files:
+ - "{{ansible_distribution}}-{{ansible_distribution_major_version}}.yml"
+ paths:
+ - "{{role_path}}/vars"
+ - files:
+ - itworks.yml
+ paths:
+ - "{{role_path}}/vars"
+ - files:
+ - ishouldnotbefound.yml
+ paths:
+ - "{{role_path}}/vars"