JP Vossen on 5 Jul 2016 16:10:47 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
[PLUG] Server date in Ansible/J2? |
It should go without saying that I want the date in the only sane format (ISO-8601): CCYY-MM-DD.
I found one "solution" that was a filter that shelled out and ran the `date` command, but that's just amazingly wrong and bad. Python knows what time it is, so does Ansible, and so does J2. Just...how do I get them to cough it up?
Use case (this works, but it's remote node "setup" (get facts) time, not local server "now" time):
- name: Update image_release file lineinfile: dest=..../image_release state=present insertbefore=BOF line='{{ ansible_date_time.date }} {{ image_release }}'There's got to be some way that's so fundamentally simple no one even bothers to document it because it's so obvious...except to me.
Thanks, JP -- ------------------------------------------------------------------- JP Vossen, CISSP | http://www.jpsdomain.org/ | http://bashcookbook.com/ ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug