We have a playbook where, once its completed, we'd like to email the stdout to certain users. Right now I am testing with the command module in the playbook as follows:
- name: Get job output
command: curl -k -u admin:{{ tower_pass }} -X GET https://<server>/api/v2/jobs/{{ tower_id }}/stdout/
register: output
-name: Print output
debug:
msg: "{{ output.stdout }}"
Obviously it doesn't work or else I wouldn't be posting this. The error I get is:
The task includes an option with an undefined variable. The error was: 'tower_id' is undefined\n\nThe error appears to be in '/var/lib/awx/projects/tsose/tsose_uptime.yml': line 15, column 6, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Get job output\n ^ here\n
Any ideas on how we can get a job's stdout via the API once the job is completed?
Thanks,
Harry