I appreciate your advise on ansible playbook mention below i am using Redhat satellite server [GET /foreman_tasks/api/tasks] api to extract the running tasks l and then mapping the task related to publishing with key value “result”. I need to check this task until the running task result from status pending to success.
I m able to retrieve task and also specific task result value but how to loop this task until the result changes from status pending to success?
using ansible v 2.9
- name: Retrieve tasks and find the state of the task
- name: Retrieve all the tasks
ansible.builtin.uri:
url: “https://{{ satellite_name }}/foreman_tasks/api/tasks”
user: “{{ sat_user }}”
password: “{{ sat_token }}”
force_basic_auth: true
method: GET
register: tasks - name: Set fact to the publish task state
ansible.builtin.set_fact:
result: “{{ tasks.json.results | selectattr (‘label’, ‘==’,‘Actions::Katello::ContentView::Publish’) | map (attribute= ‘result’) | first }}”
Print taskid from the list
- name: “Print task state”
ansible.builtin.debug:
var: result
I appreciate if any one us give me suggestion as i m struck and unable to proceed further
Thanks
Deepak B Kumar