@ -20,10 +20,14 @@
shell : echo hi
register : some_registered_var
- debug : var=some_registered_var
- debug:
var : some_registered_var
- name : Verify that we workaround a py26 json bug
template : src=py26json.j2 dest={{output_dir}}/py26json.templated mode=0644
template:
src : py26json.j2
dest : "{{ output_dir }}/py26json.templated"
mode : 0644
- name : 9851 - Verify that we don't trigger https://github.com/ansible/ansible/issues/9851
copy:
@ -33,7 +37,9 @@
- {"k": "Quotes \"'\n" }
- name : 9851 - copy known good output into place
copy : src=9851.txt dest={{output_dir}}/9851.txt
copy:
src : 9851. txt
dest : "{{ output_dir }}/9851.txt"
- name : 9851 - Compare generated json to known good
shell : diff -w {{ output_dir }}/9851.out {{ output_dir }}/9851.txt
@ -45,11 +51,16 @@
- 'diff_result_9851.stdout == ""'
- name : fill in a basic template
template : src=foo.j2 dest={{output_dir}}/foo.templated mode=0644
template:
src : foo.j2
dest : "{{ output_dir }}/foo.templated"
mode : 0644
register : template_result
- name : copy known good into place
copy : src=foo.txt dest={{output_dir}}/foo.txt
copy:
src : foo.txt
dest : "{{ output_dir }}/foo.txt"
- name : compare templated file to known good
shell : diff -w {{ output_dir }}/foo.templated {{ output_dir }}/foo.txt
@ -85,15 +96,16 @@
- "{{'10.00 Kb'|human_to_bytes(isbits=True)}} == 10240"
- name : Verify human_to_bytes (bad string)
tags : "human_to_bytes"
set_fact : bad_string="{{'10.00 foo'|human_to_bytes }}"
set_fact:
bad_string : "{{ '10.00 foo' | human_to_bytes }}"
ignore_errors : yes
register : _
tags : human_to_bytes
register : _human_bytes_test
- name : Verify human_to_bytes (bad string)
tags : "human_to_bytes"
tags : human_to_bytes
assert:
that : "{{_ .failed}}"
that : "{{_ human_bytes_test .failed}}"
- name : Test extract
assert:
@ -120,22 +132,40 @@
that:
- "users | json_query('[*].hosts[].host') == ['host_a', 'host_b', 'host_c', 'host_d']"
- name : "20379 - set_fact app_var_git_branch "
set_fact:
app_var_git_branch : multi-deployment-400-743
- name : Test hash filter
assert:
that:
- '"{{ "hash" | hash("sha1") }}" == "2346ad27d7568ba9896f1b7da6b5991251debdf2"'
- '"{{ "café" | hash("sha1") }}" == "f424452a9673918c6f09b0cdd35b20be8e6ae7d7"'
- name : "20379 - trigger a error in jmespath via json_query filter to test error handling"
debug:
msg: "{{ example_20379 | json_query('ApplicationVersions[].VersionLabel[] | [?starts_with(@, `multi`)]') }}"
ignore_errors: true
- debug:
var : "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit"
verbosity: 1
tags: debug
- name : "20379 - Test errors related to https://github.com/ansible/ansible/issues/20379"
- name : Test urlsplit filter
assert:
that : "example_20379 | json_query('ApplicationVersions[].VersionLabel[] | [?starts_with(@, '+app_var_git_branch+')] | [2:]') == multisdfsdf"
ignore_errors : true
that:
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('fragment') == 'fragment'"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('hostname') == 'www.acme.com'"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('netloc') == 'mary:MySecret@www.acme.com:9000'"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('path') == '/dir/index.html'"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('port') == 9000"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('query') == 'query=term'"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('scheme') == 'http'"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('username') == 'mary'"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit('password') == 'MySecret'"
- "'http://mary:MySecret@www.acme.com:9000/dir/index.html?query=term#fragment' | urlsplit == { 'fragment': 'fragment', 'hostname': 'www.acme.com', 'netloc': 'mary:MySecret@www.acme.com:9000', 'password': 'MySecret', 'path': '/dir/index.html', 'port': 9000, 'query': 'query=term', 'scheme': 'http', 'username': 'mary' }"
- name : Test urlsplit filter bad argument
debug:
var : "'http://www.acme.com:9000/dir/index.html' | urlsplit('bad_filter')"
register : _bad_urlsplit_filter
ignore_errors : yes
- name : Test hash filter
- name : Verify urlsplit filter showed an error message
assert:
that:
- '"{{ "hash" | hash("sha1") }}" == "2346ad27d7568ba9896f1b7da6b5991251debdf2"'
- '"{{ "café" | hash("sha1") }}" == "f424452a9673918c6f09b0cdd35b20be8e6ae7d7"'
- _bad_urlsplit_filter | failed
- "'unknown URL component' in _bad_urlsplit_filter.msg"