Need yesterday's date in a playbook

418 views
Skip to first unread message

kaleb....@gmail.com

unread,
May 28, 2021, 1:40:50 PM5/28/21
to AWX Project
I have a need to run a playbook using yesterday's date as a variable in the playbook...

I had a thought to have two scheduled jobs..one to set a fact with the date the job is running, then use that on the next scheduled job, but I'm not entirely sure if that's the best way when really I just need to have a way to find yesterday's date in an ansible playbook.


Patrick Dreher

unread,
May 28, 2021, 2:01:50 PM5/28/21
to AWX Project
first off this Google Group is about discussing AWX/Tower - not Ansible.

having said that - how about using the shell module to run the date command and registering the output?

- name: Get timestamp from the system
    shell: "date --date='1 days ago'"
    register: tstamp

might need to change the command a bit to get the kind of date format you need. for wherever you'll use it.

Kaleb S

unread,
May 28, 2021, 4:15:22 PM5/28/21
to AWX Project
Thanks Patrick,

I apologize for hijacking the group, but appreciate the pointers.

Regards,

Kaleb

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/71fb2287-141a-4c2c-b4c2-30d652670507n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages