I'm writing a playbook to publish new Content View versions and promote the
new version to our Lifecycle Environments using the uri module. I'm trying
to create a task that will query the task ID until it reports a result of
'success'. I've tried the following:
- name: Get the tasks list from Satellite
uri:
url: https://satelitlite-server/foreman_tasks/api/tasks
method: GET
body:
order: 'id DESC'
organization_id: 3
user: "{{ satellite_user }}"
password: "{{ satellite_pass }}"
force_basic_auth: yes
validate_certs: no
body_format: json
register: tasks_list
- name: Wait for new Content View version to finish publishing
uri:
url: "https://satellite-server/foreman_tasks/api/tasks/{{
tasks_list.json.results[4].id }}"
method: GET
status_code: 200
validate_certs: no
user: "{{ satellite_user }}"
password: "{{ satellite_pass }}"
force_basic_auth: yes
body_format: json
register: task_result
until: task_result.json.results[4].result == 'success'
retries: 60
delay: 20
This gives me an error of:
TASK [Wait for new Content View version to finish publishing]
*********************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The conditional check
'task_result.json.results[4].result == 'success'' failed. The error was:
error while evaluating conditional (task_result.json.results[4].result ==
'success'): 'dict object' has no attribute 'results'"}
I'm guessing I can't query a variable that's registered in the same task?
Does anyone know an alternative method other than just pausing the playbook
for a few minutes to let the publish task finish?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/6f35ca5c-1c4c-439c-bf05-42a5ad6fe478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.