mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -07:00
[PR #10242/66cb9aef backport][stable-10] yaml callback: use new util introduced in ansible-core 2.19.0b2 (#10245)
yaml callback: use new util introduced in ansible-core 2.19.0b2 (#10242)
* Avoid repeating some code.
* Use new utility added for ansible-core 2.19.0b2.
* Lint.
* Add changelog fragment.
* transform_to_native_types() does not convert map keys.
To catch all tagged strings, we have to recursively walk the data structure then.
* Add test with vaulted string.
(cherry picked from commit 66cb9aefb5
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
a9e892952d
commit
cae0457e0e
5 changed files with 119 additions and 136 deletions
|
@ -30,7 +30,7 @@
|
|||
label: "{{ test.name }}"
|
||||
|
||||
- name: Collect outputs
|
||||
command: "ansible-playbook -i {{ inventory }} {{ playbook }}"
|
||||
command: "ansible-playbook -i {{ inventory }} {{ playbook }} {{ test.extra_cli_arguments | default('') }}"
|
||||
environment: "{{ test.environment }}"
|
||||
loop: "{{ tests }}"
|
||||
loop_control:
|
||||
|
|
7
tests/integration/targets/callback_yaml/meta/main.yml
Normal file
7
tests/integration/targets/callback_yaml/meta/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
dependencies:
|
||||
- setup_remote_tmp_dir
|
|
@ -8,6 +8,11 @@
|
|||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Write vault password to disk
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ remote_tmp_dir }}/vault-password"
|
||||
content: asdf
|
||||
|
||||
- name: Run tests
|
||||
include_role:
|
||||
name: callback
|
||||
|
@ -96,3 +101,43 @@
|
|||
- ""
|
||||
- "PLAY RECAP *********************************************************************"
|
||||
- "testhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 "
|
||||
- name: Some more fun with data tagging
|
||||
environment:
|
||||
ANSIBLE_NOCOLOR: 'true'
|
||||
ANSIBLE_FORCE_COLOR: 'false'
|
||||
ANSIBLE_STDOUT_CALLBACK: community.general.yaml
|
||||
extra_cli_arguments: "--vault-password-file {{ remote_tmp_dir }}/vault-password"
|
||||
playbook: !unsafe |
|
||||
- hosts: testhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
foo: bar
|
||||
baz: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
30393064316433636636373336363538663034643135363938646665393661353833633865313765
|
||||
3835366434646339313337663335393865336163663434310a316161313662666466333332353731
|
||||
64663064366461643162666137303737643164376134303034306366383830336232363837636638
|
||||
3830653338626130360a313639623231353931356563313065373661303262646337383534663932
|
||||
64353461663065333362346264326335373032313333343539646661656634653138646332313639
|
||||
3566313765626464613734623664663266336237646139373935
|
||||
tasks:
|
||||
- name: Test regular string
|
||||
debug:
|
||||
var: foo
|
||||
- name: Test vaulted string
|
||||
debug:
|
||||
var: baz
|
||||
expected_output:
|
||||
- ""
|
||||
- "PLAY [testhost] ****************************************************************"
|
||||
- ""
|
||||
- "TASK [Test regular string] *****************************************************"
|
||||
- "ok: [testhost] => "
|
||||
- " foo: bar"
|
||||
- ""
|
||||
- "TASK [Test vaulted string] *****************************************************"
|
||||
- "ok: [testhost] => "
|
||||
- " baz: aBcDeFgHiJkLmNoPqRsTuVwXyZ012345"
|
||||
- ""
|
||||
- "PLAY RECAP *********************************************************************"
|
||||
- "testhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue