Hi All
Is there a way to get job running Start/Finish time from tower .
Hi All
Is there a way to get job running Start/Finish time from tower .
name: “[TIME-FETCH] Daily Health Check”
hosts: localhost
gather_facts: true
tasks:
name: “Debug Current Job ID → tower_job_id”
ansible.builtin.debug:
msg: “{{ tower_job_id }}”
name: “Provide Token Details Before Fetching Job Details[Required Variable]”
ansible.builtin.set_fact:
token: “SHQ0ywkHOnQy2kvE0O28VGo”
name: “Fetch Current Job Details To Get Job Start Time”
ansible.builtin.uri:
url: “https://{{ tower_host }}/api/v2/jobs/{{ tower_job_id }}”
method: GET
validate_certs: false
return_content: true
status_code:
201
200
headers:
Authorization: “Bearer {{ token }}”
Content-Type: “application/json”
register: job_details
name: “Fetch Start Time(request_date) From job_details in ISO-806 Format”
ansible.builtin.set_fact:
fetched_date: “{{ job_details.json.started }}” # 2023-07-20T16:36:44.396234Z
name: “Reformat Start Time(fetched_date) To Proper Date Format”
ansible.builtin.set_stats:
data:
job_started_date_kp_to_kyndryl: “{{ fetched_date.split(‘.’)[0].split(‘T’)[0].split(‘-’) | join(‘') + '’ + fetched_date.split(‘.’)[0].split(‘T’)[1].split(‘:’) | join(‘_’) }}”