Ansible stdout Formatting

后端 未结 4 2146
终归单人心
终归单人心 2021-02-14 01:03

Assuming the below tasks:

shell: \"some_script.sh\" register: \"some_script_result\"

debug: msg: \"Output: {{ some_script_result.stdout_li

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-14 02:00

    Try this option. You’ll love it.

    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:

    # 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

提交回复
热议问题