Skip to content

Instantly share code, notes, and snippets.

@emorisse
Created December 15, 2022 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emorisse/d0525cf32418c7a71f239fade53f3903 to your computer and use it in GitHub Desktop.
Save emorisse/d0525cf32418c7a71f239fade53f3903 to your computer and use it in GitHub Desktop.
---
- name: date and time demo
hosts: localhost
connection: local
gather_facts: true
tasks:
- name: time of day
vars:
afternoon: 'afternoon'
morning: "{{ 'morning' if ansible_date_time.hour < '12' else afternoon }}"
period: "{{ 'evening' if ansible_date_time.hour >= '17' else morning }}"
debug: msg="{{ 'Good ' + period + '!' }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment