Question:
Assuming the below tasks:
1 2 3 |
shell: "some_script.sh" register: "some_script_result" |
1 2 3 |
debug: msg: "Output: {{ some_script_result.stdout_lines }} |
I receive the below output:
1 2 |
"msg": "Output: [u'some_value',u'some_value2,u'some_value3]" |
How do I get the output to print as?
1 2 3 4 5 6 |
"msg": Output: some_value some_value2 some_value3 |
Ansible version is 2.4.2.
Thank you!
Answer:
There’s a new YAML callback plugin introduced with Ansible 2.5 — meaning any machine running Ansible 2.5.0 or later can automatically start using this format without installing custom plugins.
To use it, edit your ansible.cfg file (either global, in /etc/ansible/ansible.cfg, or a local one in your playbook/project), and add the following lines under the [defaults] section:
1 2 3 4 5 |
# Use the YAML callback plugin. stdout_callback = yaml # Use the stdout_callback when running ad-hoc commands. bin_ansible_callbacks = True |
Now I can easily read through your output message
If you get the following error:
1 2 |
ERROR! Invalid callback for stdout specified: yaml |
run
1 2 |
ansible-galaxy collection install community.general |