Skip to content

Instantly share code, notes, and snippets.

@hyperized
Created June 29, 2016 13:01
Show Gist options
  • Save hyperized/426a6a481566d705458df5152540377d to your computer and use it in GitHub Desktop.
Save hyperized/426a6a481566d705458df5152540377d to your computer and use it in GitHub Desktop.
---
- hosts: localhost
vars:
hour_block_size: 4
tasks:
# To find the nearest hour within a X (hour_block_size) hour span (nearest neighbor), sort floor
- set_fact:
block_of_hours: "{{ ( ( ansible_date_time.hour | int ) // hour_block_size ) | int }}"
- debug: msg="{{ [ ( block_of_hours | int ) ] | map('extract', range(0, 24, hour_block_size)) | list }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment