diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/lookup_varnames/tasks/main.yml | |
parent | Initial commit. (diff) | |
download | ansible-core-upstream/2.14.3.tar.xz ansible-core-upstream/2.14.3.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | test/integration/targets/lookup_varnames/tasks/main.yml | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_varnames/tasks/main.yml b/test/integration/targets/lookup_varnames/tasks/main.yml new file mode 100644 index 0000000..fec3efd --- /dev/null +++ b/test/integration/targets/lookup_varnames/tasks/main.yml @@ -0,0 +1,38 @@ +# Example copied from docs +- name: Set some variables + set_fact: + qz_1: hello + qz_2: world + qa_1: "I won't show" + qz_: "I won't show either" + +- name: Try various regexes and make sure they work + assert: + that: + - lookup('varnames', '^qz_.+', wantlist=True) == ['qz_1', 'qz_2'] + - lookup('varnames', '^qz_.+', '^qa.*', wantlist=True) == ['qz_1', 'qz_2', 'qa_1'] + - "'ansible_python_interpreter' in lookup('varnames', '^ansible_.*', wantlist=True)" + - lookup('varnames', '^doesnotexist.*', wantlist=True) == [] + - lookup('varnames', '^doesnotexist.*', '.*python_inter.*', wantlist=True) == ['ansible_python_interpreter'] + - lookup('varnames', '^q.*_\d', wantlist=True) == ['qz_1', 'qz_2', 'qa_1'] + - lookup('varnames', '^q.*_\d') == 'qz_1,qz_2,qa_1' + +- name: Make sure it fails successfully + set_fact: + fail1: "{{ lookup('varnames', True, wantlist=True) }}" + register: fail1res + ignore_errors: yes + +- name: Make sure it fails successfully + set_fact: + fail2: "{{ lookup('varnames', '*', wantlist=True) }}" + register: fail2res + ignore_errors: yes + +- assert: + that: + - fail1res is failed + - "'Invalid setting identifier' in fail1res.msg" + - fail2res is failed + - "'Unable to use' in fail2res.msg" + - "'nothing to repeat' in fail2res.msg" |