I have a role in a playbook which gets a value from a query. That value should then be available in other roles.
I tried: root-play.yml:
roles:
- update
- role: query
tags: query
- process
The query
role:
- name: Query data
shell: query.sh
environment:
VAR: "some var"
register: query_out
- debug: msg="{{ query_out.stdout }}"
- set_fact:
id: "{{ query_out.stdout | from_json | json_query(id) }}"
- debug: msg="{{ id }}"
This fails with a message of like
"the field 'args' has an invalid value ([u'query']), and could not be converted to an dict.The error was: Expecting property name enclosed in double quotes
I am assuming that the set_fact
statement above in the roles doesn't work as expected, in fact I always read something that it'd be with a task, but not with a role.
How can I pass that variable on to the next role?