--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CADp8UUS10CbPWP45TRpfXB%2BYRWev5KaSRFjchAi7KQO7Dt%2BzHQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CADp8UUS10CbPWP45TRpfXB%2BYRWev5KaSRFjchAi7KQO7Dt%2BzHQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6F27360B-C585-4887-A1DF-230B8C3020A0%40gmail.com.
old_date: "{{ lookup('ansible.builtin.pipe', 'date -d \"now - 14 days\" +%Y-%m-%dT%H:%M:%S') }}"The contents of this message and any attachment(s) are confidential, proprietary to the City of Edmonton, and are intended only for the addressed recipient. If you have received this in error, please disregard the contents, inform the sender of the misdirection, and remove it from your system. The copying, dissemination, or distribution of this message, if misdirected, is strictly prohibited. --
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CADp8UUTFhKPwN3DT41e7SxwOQs4jSOWZvjeQk2F%3DuCq8B%3Dv5Cg%40mail.gmail.com.
-- Todd
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/622a5121-efa6-495b-b836-e8f583d8184d%40gmail.com.
utoddl@tango:~/ansible$ cat test.yml
---
# test.yml
- name: Date games
hosts: localhost
gather_facts: false
vars:
old_date: "{{ lookup('ansible.builtin.pipe', 'date -d \"now - 14 days\" +%Y-%m-%dT%H:%M:%S') }}"
start_trigger: "{{ (now(utc=false,fmt='%Y-%m-%dT%H:%M:%S') | to_datetime('%Y-%m-%dT%H:%M:%S')).strftime('%s') }}"
tasks:
- name: Set 2 weeks ago date
ansible.builtin.set_fact:
new_date: "{{ lookup('ansible.builtin.pipe', 'date -d \"now - 14 days\" +%Y-%m-%d\" \"%H:%M:%S') | to_datetime }}"
- name: Check types
ansible.builtin.debug:
msg:
- '{{ old_date }}, {{ old_date | type_debug }}'
- '{{ new_date }}, {{ new_date | type_debug }}'
utoddl@tango:~/ansible$ ansible-playbook test.yml
PLAY [Date games] *********************************************************************************************************
TASK [Set 2 weeks ago date] ***********************************************************************************************
ok: [localhost]
TASK [Check types] ********************************************************************************************************
ok: [localhost] =>
msg:
- 2024-08-21T23:56:21, AnsibleUnsafeText
- 2024-08-21 23:56:21, AnsibleUnsafeText
Since the output of `date` is a string, if you could get
`create_time` to be a string also, you could compare them as strings
rather than datetime objects. And you probably only need the
"+%Y-%m-%d" part anyway.The contents of this message and any attachment(s) are confidential, proprietary to the City of Edmonton, and are intended only for the addressed recipient. If you have received this in error, please disregard the contents, inform the sender of the misdirection, and remove it from your system. The copying, dissemination, or distribution of this message, if misdirected, is strictly prohibited. --
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CADp8UUR0h7cN8k9E7mPL1Wxnqgdzx7_DxpyT4oZhe-iSaXwWSw%40mail.gmail.com.
-- Todd