homeserver/roles/mgrote.ntp_chrony_client/tasks/main.yml

68 lines
1.6 KiB
YAML
Raw Normal View History

---
- name: Check systemd-timesyncd status
become: true
shell: systemctl is-active --quiet systemd-timesyncd && echo "Active" || echo "Inactive"
register: timesyncd_status
changed_when: false
- name: Disable systemd-timesyncd
become: true
ansible.builtin.systemd:
name: systemd-timesyncd
masked: yes
state: stopped
when: timesyncd_status.stdout == "Active"
- name: gather package facts
become: yes
ansible.builtin.package_facts:
manager: auto
- name: stop and mask ntp service
become: yes
systemd:
name: ntp
masked: yes
state: stopped
when: "'ntp' in ansible_facts.packages"
- name: install chrony packages
become: yes
ansible.builtin.package:
name:
- chrony
state: present
notify: restart_chrony
- name: copy chrony config
become: yes
ansible.builtin.template:
src: chrony.conf.j2
dest: /etc/chrony/chrony.conf
mode: 0755
notify: restart_chrony
- name: copy logrotate config
become: yes
ansible.builtin.template:
src: logrotate_chrony
dest: /etc/logrotate.d/chrony
owner: root
group: root
mode: 0644
- name: Create chrony driftfile folder
become: yes
file:
state: directory
path: "{{ ntp_chrony_driftfile_directory }}"
mode: 0755
owner: "{{ ntp_chrony_user }}"
group: "{{ ntp_chrony_group }}"
notify: restart_chrony
- name: set timezone to {{ ntp_chrony_timezone }}
become: yes
ansible.builtin.timezone:
name: "{{ ntp_chrony_timezone }}"