When executing a playbook to run a command in a remote host and pass the output using shell, getting below error.
fatal: [master1]: FAILED! => {} MSG: template error while templating string: unexpected char u'a' at 4. String: {{54aa7fda16833bff8358b6bd1157df2d9caa26b2}}
Below is my playbook content
- name: 'Play1'
hosts: master
tasks:
- name: 'Execute command'
shell: ''sh generate_ticket.sh" #command to generate ticket
register: shell_output
- name: 'debug shell_output'
debug:
var="{{ shell_output.stdout | from_yaml }}"
When I try the same with msg and don't try to filter then the output is printed without any error. However I prefer to use var as it suits best for my further requirements. If the ticket number is a different string I do not face any issues. Please see below:
Output:
ok: [master1] => {}
MSG:
54aa7fda16833bff8358b6bd1157df2d9caa26b2
Playbook :
- name: 'Play1'
hosts: master
tasks:
- name: 'Execute command'
shell: ''sh generate_ticket.sh" #command to generate ticket
register: shell_output
- name: 'debug shell_output'
debug: msg="{{ shell_output.stdout | from_yaml }}"
It seems to work when I put single quotes around shell_output.stdout
var="{{ 'shell_output.stdout' | from_yaml}}"
Let me know if anybody has a better fix than this.
use !unsafe
enter link description here
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