Re: [ansible-project] Date in a Jinja template

2020-12-08 Thread harry devine
Thank you!  That worked very well.

Harry

On Tue, Dec 8, 2020, 9:49 AM Dick Visser  wrote:

> I think now() is naive, i.e. it does not know about time zones.
> If you need time zones, then I'd give 'ansible_date_time' a try.
>
> On Tue, 8 Dec 2020 at 15:20, lift...@gmail.com  wrote:
> >
> > I generate a report using a Jinja template file from one of my playbooks
> and mail that file to several users.  In it, I am putting the current date
> and time as follows:
> >
> > Date generated: {{ now(false, '%m/%d/%Y %I:%M:%S') }}
> > ---
> > {% for i in play_hosts | sort %}
> > Host: {{ i }}
> >   Rebooted: {{ hostvars[i]['rebooted']['rebooted'] }}
> >   Total reboot time: {{ hostvars[i]['rebooted']['elapsed'] }} seconds
> > ---
> > {% endfor %}
> >
> > When I get the email, the date is correct but the time is 7 hours off.
> For example, the report was generated and mailed at 10:40:00am yesterday,
> but the time listed via the Jinja template above was 03:40:00.
> >
> > Any ideas on how to get the time be in the current timezone?
> >
> > Thanks,
> > Harry
> >
> > --
> > 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-project+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8d957e26-0a8b-40bd-9dd4-f7b4f3297a29n%40googlegroups.com
> .
>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> 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-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwPQfChKV3PA-9Tj-A0AM0u%3DygcWYQcoc0BdjGfXN3q0_w%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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALYKJ24JqoRMX5X%2B8tNMwJ-a22OB-km1pT70pL6NsBwiVMF1eQ%40mail.gmail.com.


Re: [ansible-project] Date in a Jinja template

2020-12-08 Thread Dick Visser
I think now() is naive, i.e. it does not know about time zones.
If you need time zones, then I'd give 'ansible_date_time' a try.

On Tue, 8 Dec 2020 at 15:20, lift...@gmail.com  wrote:
>
> I generate a report using a Jinja template file from one of my playbooks and 
> mail that file to several users.  In it, I am putting the current date and 
> time as follows:
>
> Date generated: {{ now(false, '%m/%d/%Y %I:%M:%S') }}
> ---
> {% for i in play_hosts | sort %}
> Host: {{ i }}
>   Rebooted: {{ hostvars[i]['rebooted']['rebooted'] }}
>   Total reboot time: {{ hostvars[i]['rebooted']['elapsed'] }} seconds
> ---
> {% endfor %}
>
> When I get the email, the date is correct but the time is 7 hours off.  For 
> example, the report was generated and mailed at 10:40:00am yesterday, but the 
> time listed via the Jinja template above was 03:40:00.
>
> Any ideas on how to get the time be in the current timezone?
>
> Thanks,
> Harry
>
> --
> 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-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/8d957e26-0a8b-40bd-9dd4-f7b4f3297a29n%40googlegroups.com.



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwPQfChKV3PA-9Tj-A0AM0u%3DygcWYQcoc0BdjGfXN3q0_w%40mail.gmail.com.


[ansible-project] Date in a Jinja template

2020-12-08 Thread lift...@gmail.com
I generate a report using a Jinja template file from one of my playbooks 
and mail that file to several users.  In it, I am putting the current date 
and time as follows:

Date generated: {{ now(false, '%m/%d/%Y %I:%M:%S') }}
---
{% for i in play_hosts | sort %}
Host: {{ i }}
  Rebooted: {{ hostvars[i]['rebooted']['rebooted'] }}
  Total reboot time: {{ hostvars[i]['rebooted']['elapsed'] }} seconds
---
{% endfor %}

When I get the email, the date is correct but the time is 7 hours off.  For 
example, the report was generated and mailed at 10:40:00am yesterday, but 
the time listed via the Jinja template above was 03:40:00.

Any ideas on how to get the time be in the current timezone?

Thanks,
Harry

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8d957e26-0a8b-40bd-9dd4-f7b4f3297a29n%40googlegroups.com.