ansible-role-os-bootstrap/tasks/timezone.yml

29 lines
978 B
YAML

---
- name: timezone | Manage the timezone in Ubuntu Trusty and older
block:
- name: timezone | Write the timezone file
ansible.builtin.template:
src: etc-timezone.j2
dest: /etc/timezone
owner: root
group: root
mode: "0644"
register: set_timezone
- name: timezone | Reconfigure the system tzdata
ansible.builtin.command: dpkg-reconfigure --frontend noninteractive tzdata
when: set_timezone is changed # noqa: no-handler
changed_when: false
when: ansible_distribution_release == "trusty"
tags: [systemsetup, timezone]
- name: timezone | Manage the timezone in Ubuntu Bionic or CentOS
block:
- name: timezone | Set the timezone
ansible.builtin.command: timedatectl set-timezone {{ timezone }}
changed_when: false
when: ansible_facts['distribution_version'] is version_compare('16.04', '>=') or ansible_distribution_file_variety == "RedHat"
tags: [systemsetup, timezone]