cool I see thank you!  but how do you avoid the special characters in the 
file name?  like so.
' "2023_07_26_14_34_22.txt" '

---

- name: date format filename
  hosts: localhost
  gather_facts: 0

  tasks:

    - name: create my file
      ansible.builtin.file:
        path: /tmp/"{{ now(fmt="%Y_%m_%d_%H_%M_%S.txt") }}"
        state: touch
...
On Wednesday, July 26, 2023 at 2:20:09 PM UTC-4 Andrew Latham wrote:

> * 
> https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
> * 
> https://github.com/ansible/ansible/blob/devel/lib/ansible/template/__init__.py#L829-L839
>
> typed without testing, sorry, give it a go
>
> - name: create my file
>   ansible.builtin.file:
>     path: /tmp/{{ now(fmt="%Y_%m_%d_%H_%M_%S.txt") }}
>     state: touch
>
> On Wed, Jul 26, 2023 at 3:09 AM javed khan Siddque <[email protected]> 
> wrote:
>
>> Hi All,
>>
>>
>> I want to convert the below time to human readable format, i tried some 
>> of the jinza formatter but it is failing .
>> Failed
>> {{ iso_date|iso8601_to_time|datetimeformat('%a, %B %d') }}
>> requirement 2023-07-20 16:36:44 
>> So i can convert this to <file_name>_2023_07_20_16_36_44 .txt 
>>
>>
>> "created": "2023-07-20T16:36:44.396234Z", "modified": 
>> "2023-07-20T16:37:26.400464Z",
>>
>> -- 
>>
> 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 [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/db9e47cf-a72f-415f-8474-16265c7eb0ccn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/db9e47cf-a72f-415f-8474-16265c7eb0ccn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> - Andrew "lathama" Latham -
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b02458dc-f4f3-4063-9785-87f9728ce167n%40googlegroups.com.

Reply via email to