Last active
August 2, 2021 19:59
-
-
Save jerm/fc7f33f6a6d6534f6fde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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 | |
- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here is my solution
name: Check current timezone
shell: cat /etc/timezone
register: current_timezone
changed_when: false
name: Set Timezone
timezone:
name: America/Chicago
when: current_timezone.stdout != "America/Chicago"