mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.0 KiB
YAML
63 lines
2.0 KiB
YAML
- name: Test INI lookup errors
|
|
hosts: testhost
|
|
|
|
tasks:
|
|
- name: Test for failure on Python 3
|
|
when: ansible_facts.python.version_info[0] >= 3
|
|
block:
|
|
- name: Lookup a file with duplicate keys
|
|
debug:
|
|
msg: "{{ lookup('ini', 'name', file='duplicate.ini', section='reggae') }}"
|
|
ignore_errors: yes
|
|
register: duplicate
|
|
|
|
- name: Lookup a file with keys that differ only in case
|
|
debug:
|
|
msg: "{{ lookup('ini', 'name', file='duplicate_case_check.ini', section='reggae') }}"
|
|
ignore_errors: yes
|
|
register: duplicate_case_sensitive
|
|
|
|
- name: Ensure duplicate key errors were handled properly
|
|
assert:
|
|
that:
|
|
- duplicate is failed
|
|
- "'Duplicate option in' in duplicate.msg"
|
|
- duplicate_case_sensitive is failed
|
|
- "'Duplicate option in' in duplicate_case_sensitive.msg"
|
|
|
|
- name: Lookup a file with a missing section
|
|
debug:
|
|
msg: "{{ lookup('ini', 'name', file='lookup.ini', section='missing') }}"
|
|
ignore_errors: yes
|
|
register: missing_section
|
|
|
|
- name: Ensure error was shown for a missing section
|
|
assert:
|
|
that:
|
|
- missing_section is failed
|
|
- "'No section' in missing_section.msg"
|
|
|
|
- name: Mix options type and push key out of order
|
|
debug:
|
|
msg: "{{ lookup('ini', 'file=lookup.ini', 'value1', section='value_section') }}"
|
|
register: bad_mojo
|
|
ignore_errors: yes
|
|
|
|
- name: Verify bad behavior reported an error
|
|
assert:
|
|
that:
|
|
- bad_mojo is failed
|
|
- '"No key to lookup was provided as first term with in string inline option" in bad_mojo.msg'
|
|
|
|
- name: Test invalid option
|
|
debug:
|
|
msg: "{{ lookup('ini', 'invalid=option') }}"
|
|
ignore_errors: yes
|
|
register: invalid_option
|
|
|
|
- name: Ensure invalid option failed
|
|
assert:
|
|
that:
|
|
- invalid_option is failed
|
|
- "'is not a valid option' in invalid_option.msg"
|