role.timezone/tasks/main.yml
2025-04-12 15:44:42 +02:00

31 lines
739 B
YAML

---
- name: Set /etc/timezone
copy:
content: |
{{ timezone_zone }}
dest: /etc/timezone
mode: 0644
owner: root
group: root
backup: yes
- name: 'Look for /usr/share/zoneinfo/{{ timezone_zone }}'
stat:
path: '/usr/share/zoneinfo/{{ timezone_zone }}'
register: timezone_zoneinfo
- name: 'Link /etc/localtime to /usr/share/zoneinfo/{{ timezone_zone }}'
file:
src: '/usr/share/zoneinfo/{{ timezone_zone }}'
dest: /etc/localtime
state: link
mode: 0644
when: timezone_zoneinfo.stat.exists
- name: Setup timezone for Alpine Linux
command:
cmd: '/usr/sbin/setup-timezone {{ timezone_zone }}'
creates: '/etc/zoneinfo/{{ timezone_zone }}'
when: ansible_os_family == "Alpine"