Skip to content

Instantly share code, notes, and snippets.

@BartVB
Forked from jerm/gist:fc7f33f6a6d6534f6fde
Last active August 29, 2015 14:02
Show Gist options
  • Save BartVB/80b1fa98abc34d61e525 to your computer and use it in GitHub Desktop.
Save BartVB/80b1fa98abc34d61e525 to your computer and use it in GitHub Desktop.
---
- name: Group by Distribution
hosts: all
tasks:
- group_by: key={{ansible_distribution}}
- name: Set Time Zone
hosts: Ubuntu
gather_facts: False
vars:
- my_zone: 'America/New_York'
tasks:
- name: check current timezone
shell: cat /etc/timezone
register: current_zone
changed_when: False
- name: Set timezone variables
copy: content={{my_zone}}
dest=/etc/timezone
owner=root
group=root
mode=0644
backup=yes
when: current_zone.stdout != my_zone
notify:
- update timezone
handlers:
- name: update timezone
command: dpkg-reconfigure --frontend noninteractive tzdata
@BartVB
Copy link
Author

BartVB commented Jun 5, 2014

Added 'changed_when' to prevent the 'check current timezone' task from returning a 'Changed' status on all runs. (requires Ansible 1.3+)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment