On 28.03.2019 21:17, James Gibson wrote:
> I am trying to output what shift an event has happened depending on the
> time of day, but keep running into errors or getting nothing back.
> 
> 
> ---
> - hosts: localhost
>    vars:
>       shift: "{{ 'First Shift' if ansible_date_time.time > '09:00:00' && 
> ansible_date_time.time < '17:00:01' else '' }}"
>       shift: "{{ 'Second Shift' if ansible_date_time.time > '17:00:00' && 
> ansible_date_time.time < '01:00:01' else '' }}"
>       shift: "{{ 'Third Shift' if ansible_date_time.time > '01:00:00' && 
> ansible_date_time.time < '09:00:01' else '' }}"

There are two reason this will not work.
The second shift will overwrite the first shift and the third shift will 
overwrite the second shift.
ansible_date_time.time is a string an you are comparing string, since time 
compare and string compare is completely different thing, this will not work as 
you would like.



-- 
Kai Stian Olstad

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d8699f61-b874-510d-02b7-f31eedac5f1b%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to