I have a simple playbook to query a package version
---
- name: version find
hosts: all
become: yes
tasks:
- name: query
shell: *shell command*
register: info
no_log: true
- debug:
msg: " {{inventory_hostname}} blah {{info.stdout}}blah"
I get an output with a lot of junk that makes parsing/using the output difficult without edits:
ok: [hostname] => {
"msg": " *hostname* blah *info* blah"
}
I am trying find a solution to only return the msg without the "ok:", and JSON-esque junk that comes with it.
I have tried setting no_log:True in the YAML file and the ansible.cfg files with no luck.
Use the callback community.general.diy (do it yourself). See
shell> ansible-doc -t callback community.general.diy
For example,
shell> cat pb.yml
- hosts: localhost
tasks:
- command: uname -o
register: info
- debug:
msg: ""
vars:
ansible_callback_diy_runner_on_ok_msg: |
msg: {{ inventory_hostname }} {{ info.stdout }}
gives
shell> ANSIBLE_STDOUT_CALLBACK=community.general.diy ansible-playbook pb.yml
PLAY [localhost] *****************************************************************************
TASK [command] *******************************************************************************
changed: [localhost]
TASK [debug] *********************************************************************************
msg: localhost GNU/Linux
PLAY RECAP ***********************************************************************************
localhost: ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With