The variable error_code below contains this string:
"failed": true
How can I use this string as the trigger for the 'when module? I am not sure how to escape these special characters so the playbook interprets them correctly. Here's what I have tried but it is not working:
- name: copying index
copy:
src: /tmp/index.html
dest: /var/www/html/
notify: reloadone
register: error_code
- name: verify content
fail:
msg: There has been an error with the index file
when: " \"failed\"\: true in error_code"
handlers:
- name: reloadone
systemd:
state: restarted
name: httpd