What if you need to return data to the caller/launcher of an AWX job via API?
In your playbook you can set facts with:
- name: Set the company id
set_fact:
tenant_id: "{{ tenant.json.id }}"
How could I access the tenant id from the api after calling the job?
You can use the cacheable option of set_fact in your playbook/role. On the AWX side, if you enable fact caching on your inventory, the facts you have marked with "cacheable: yes" will be available as facts for the host via the AWX hosts API (hosts/{id}/ansible_facts).
On the AWX release I am using 11.0, it cannot be done as far as I know.
The best work around would be to explicitly push that data somewhere within the play.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.