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/ansible-inventory/tasks/toml.yml | |
parent | Initial commit. (diff) | |
download | ansible-core-upstream.tar.xz ansible-core-upstream.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/ansible-inventory/tasks/toml.yml')
-rw-r--r-- | test/integration/targets/ansible-inventory/tasks/toml.yml | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-inventory/tasks/toml.yml b/test/integration/targets/ansible-inventory/tasks/toml.yml new file mode 100644 index 0000000..4a227dd --- /dev/null +++ b/test/integration/targets/ansible-inventory/tasks/toml.yml @@ -0,0 +1,66 @@ +- name: Ensure no toml packages are installed + pip: + name: + - tomli + - tomli-w + - toml + state: absent + +- name: Install toml package + pip: + name: '{{ toml_package|difference(["tomllib"]) }}' + state: present + +- name: test toml parsing + command: ansible-inventory --list --toml -i {{ role_path }}/files/valid_sample.toml + register: toml_in + +- assert: + that: + - > + 'foo = "bar"' in toml_in.stdout + +- name: "test option: --toml with valid group name" + command: ansible-inventory --list --toml -i {{ role_path }}/files/valid_sample.yml + register: result + +- assert: + that: + - result is succeeded + +- name: "test option: --toml with invalid group name" + command: ansible-inventory --list --toml -i {{ role_path }}/files/invalid_sample.yml + ignore_errors: true + register: result + +- assert: + that: + - result is failed + - > + "ERROR! The source inventory contains" in result.stderr + +- block: + - name: "test toml output with unicode characters" + command: ansible-inventory --list --toml -i {{ role_path }}/files/unicode.yml + register: result + + - assert: + that: + - result is succeeded + - result.stdout is contains('příbor') + + - block: + - name: "test toml output file with unicode characters" + command: ansible-inventory --list --toml --output unicode_inventory.toml -i {{ role_path }}/files/unicode.yml + + - set_fact: + toml_inventory_file: "{{ lookup('file', 'unicode_inventory.toml') | string }}" + + - assert: + that: + - toml_inventory_file is contains('příbor') + always: + - file: + name: unicode_inventory.toml + state: absent + when: ansible_python.version.major|int == 3 |