In my playbook I need the last half hour of data only. For that I do the following
- set_fact:
half_hour_back_epoch_int: "{{(ansible_date_time.epoch|int) - (60*60*0.5) }}"
- name: Add jobs data to dictionary
set_fact:
list_of_jobs_info: "{{ list_of_jobs_info + [{ 'job_id' : item['id'], 'job_name' : item['name'], 'job_status' : item['status'] }] }}"
when:
- item['status'] == "canceled"
- item['started'] > half_hour_back_epoch_int
loop: "{{ jobs_data['json']['results'] }}"
The " item['started'] > half_hour_back_epoch_int " condition does not work.
I suspect it is because the datatype of item['started'] is of the following format
"started": "2022-11-15T20:00:07.881083Z",
Can you tell me how to convert this item['started'] to epoch so that I can compare to my half_hour_back_epoch_int variable
Or is there any other way to get the when condition to work