Timestamp formats in ansible

1,625 views
Skip to first unread message

rambius

unread,
Apr 22, 2015, 12:03:00 PM4/22/15
to ansible...@googlegroups.com
Hello,

I defined a timestamp variable used to name backup files:

backup_timestamp: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}{{ ansible_date_time.hour }}{{ ansible_date_time.minute }}{{ ansible_date_time.second }}"

I use that variable successfully in a command. My questions is: is there a way to define timestamp formats without manual appending of ansible_data_time's components?

Regards
rambius

Jian Jakim Li

unread,
Sep 19, 2016, 1:18:00 PM9/19/16
to Ansible Project
If you're using ansible 2.0, now you can use "{{lookup('pipe', 'date +%Y%m%d%H%M%S')}}" to get what you want.
Reply all
Reply to author
Forward
0 new messages