Update to 2024-09-23 23:00

This commit is contained in:
Daniel Berteaud
2024-09-23 23:00:09 +02:00
parent abb4d79e6c
commit 9c1159e3de
16 changed files with 127 additions and 76 deletions

View File

@@ -0,0 +1,28 @@
---
- when:
- ansible_virtualization_role == 'guest'
- ansible_virtualization_type == 'kvm'
block:
- name: Configure ptp_kvm to be loaded
copy: content=ptp_kvm dest=/etc/modules-load.d/ptp_kvm.conf
register: ntp_ptp_kvm_mod
- name: Load ptp_kvm
service: name=systemd-modules-load state=restarted
when: ntp_ptp_kvm_mod.changed
tags: ntp
- when: ansible_virtualization_role != 'guest' or ansible_virtualization_type != 'kvm'
file: path=/etc/modules-load.d/ptp_kvm.conf state=absent
tags: ntp
- name: Check if /dev/ptp_kvm exists
stat: path=/dev/ptp_kvm
register: ntp_ptp_kvm_dev
tags: ntp
- name: Deploy chrony configuration
template: src=chrony.conf.j2 dest={{ ntp_chrony_conf }}
notify: restart chrony
tags: ntp

View File

@@ -0,0 +1,19 @@
---
- include_vars: "{{ item }}"
with_first_found:
- vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml
- vars/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml
- vars/{{ ansible_distribution }}.yml
- vars/{{ ansible_os_family }}.yml
tags: ntp
- name: Check if systemd-timesyncd is available
stat: path=/lib/systemd/systemd-timesyncd
register: systemd_timesyncd
tags: ntp
- name: Check if ntpd is installed
stat: path=/lib/systemd/system/{{ ntp_ntpd_service }}.service
register: ntp_unit
tags: ntp

View File

@@ -0,0 +1,17 @@
---
# If systemd-timesyncd is installed, stop and disable it
- name: Disable systemd-timesyncd
service: name=systemd-timesyncd state=stopped enabled=False
when: systemd_timesyncd.stat.exists
tags: ntp
# If ntpd is installed, stop and disable it
- name: Handle ntpd service
service: name={{ ntp_ntpd_service }} state=stopped enabled=False
when: ntp_unit.stat.exists
tags: ntp
- name: Install Chrony
package: name=chrony
tags: ntp

View File

@@ -1,53 +1,14 @@
---
- include_vars: "{{ item }}"
with_first_found:
- vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml
- vars/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml
- vars/{{ ansible_distribution }}.yml
- vars/{{ ansible_os_family }}.yml
tags: ntp
- include_tasks: facts.yml
tags: always
- name: Check if systemd-timesyncd is available
stat: path=/lib/systemd/systemd-timesyncd
register: systemd_timesyncd
tags: ntp
- include_tasks: install.yml
tags: always
- name: Disable systemd-timesyncd
service: name=systemd-timesyncd state=stopped enabled=False
when: systemd_timesyncd.stat.exists
tags: ntp
- include_tasks: conf.yml
tags: always
- name: Install Chrony
package: name=chrony
tags: ntp
- name: Deploy chrony configuration
template: src=chrony.conf.j2 dest={{ ntp_chrony_conf }}
notify: restart chrony
tags: ntp
# Always close port, it's only used as a server on samba DC, where port 123 is opened
# by the samba role
- name: Handle ntpd port
iptables_raw:
name: ntpd_port
state: absent
when: iptables_manage | default(True)
tags: ntp
- name: Check if ntpd is installed
stat: path=/lib/systemd/system/{{ ntp_ntpd_service }}.service
register: ntp_unit
tags: ntp
# If ntpd is installed, stop and disable it
- name: Handle ntpd service
service: name={{ ntp_ntpd_service }} state=stopped enabled=False
when: ntp_unit.stat.exists
tags: ntp
- name: Start and enable chrony
service: name={{ ntp_chrony_service }} state=started enabled=True
tags: ntp
- include_tasks: services.yml
tags: always

View File

@@ -0,0 +1,5 @@
---
- name: Start and enable chrony
service: name={{ ntp_chrony_service }} state=started enabled=True
tags: ntp

View File

@@ -3,9 +3,12 @@ server {{ server }} iburst
{% endfor %}
keyfile {{ ntp_chrony_keyfile }}
driftfile /var/lib/chrony/drift
{% if ansible_virtualization_role == "guest" and ansible_virtualization_type == "kvm" and ntp_ptp_kvm_dev.stat.exists %}
refclock PHC /dev/ptp0 poll 2 trust
{% endif %}
{% if ansible_virtualization_role == "guest" %}
# Virtualization guest, so allow unlimited steps if the clock is more than 5sec off
makestep 5 -1
# Virtualization guest, so allow unlimited steps if the clock is more than 15sec off
makestep 15 -1
{% else %}
makestep 1.0 3
{% endif %}