Files
ansible/roles/common/tasks/time.yaml

35 lines
925 B
YAML

---
- name: Set timezone
community.general.timezone:
name: "{{ timezone }}"
become: true
when: ansible_facts['user_id'] != "root"
- name: Set timezone
community.general.timezone:
name: "{{ timezone }}"
when: ansible_facts['user_id'] == "root"
- name: Configure NTP servers for systemd-timesyncd
ansible.builtin.lineinfile:
path: /etc/systemd/timesyncd.conf
regexp: "^#?NTP="
line: "NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org"
become: true
notify: Restart timesyncd
- name: Enable and start systemd-timesyncd
ansible.builtin.systemd:
name: systemd-timesyncd
enabled: true
state: started
become: true
when: ansible_facts['user_id'] != "root"
- name: Enable and start systemd-timesyncd
ansible.builtin.systemd:
name: systemd-timesyncd
enabled: true
state: started
when: ansible_facts['user_id'] == "root"