I am new to Ansible and a bit stuck.
I have a python script that returns true or false.
I run this python script via ansible task.
I am trying to debug the value returned by running the py script.
Additionally I would want to run another task only if the value returned is true.
Ansible Task below:
---
- name: Check XML against XSD
become: yes
shell: /usr/bin/python3 check.py
args:
chdir: "/var/www/html/det/scripts/"
register: result
tags: schema_check
- debug: var =schema_check.stdout
msg: "Testing..."
verbosity: 2
And the python script check.py
result = true
print(result)
Best Answer
The issue here is you are registering the output as
result
, while in thedebug
task you are callingschema_check
, which is the name of the tag.Furthermore
debug
can only have either thevar
or themsg
property, not both at the same time.