Skip to content

Commit

Permalink
chore: add timesyncd support
Browse files Browse the repository at this point in the history
this change will ensure that we're using timesyncd when configuring hosts.

Signed-off-by: Kevin Carter <[email protected]>
  • Loading branch information
cloudnull committed Feb 5, 2025
1 parent e6695fc commit e98770a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ansible/inventory/genestack/group_vars/all/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ kube_webhook_token_auth_url_skip_tls_verify: false

## NTP Settings
# Start the ntpd or chrony service and enable it at system boot.
ntp_enabled: true
ntp_manage_config: true
ntp_enabled: false
ntp_manage_config: false
ntp_servers:
- "0.pool.ntp.org iburst"
- "1.pool.ntp.org iburst"
Expand Down
5 changes: 5 additions & 0 deletions ansible/roles/host_setup/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,8 @@ host_specific_kernel_modules: []
# Optional user defined list of sysctl options in the same dict item format as
# above.
user_kernel_options: []

# Limited to two servers, the first one is the primary and the second one is the backup.
host_ntp_server:
- 0.pool.ntp.org
- 1.pool.ntp.org
6 changes: 6 additions & 0 deletions ansible/roles/host_setup/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@
name: "queue_max.service"
state: "restarted"
enabled: true

- name: Reload systemd-timesyncd
ansible.builtin.systemd:
name: systemd-timesyncd
state: reloaded
enabled: true
14 changes: 14 additions & 0 deletions ansible/roles/host_setup/tasks/configure_hosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,17 @@
dest: /etc/systemd/system/queue_max.service
mode: "0644"
notify: Load and start queue_max service

- name: Ensure timesyncd is running
ansible.builtin.service:
name: systemd-timesyncd
state: started
enabled: true
notify: Reload systemd-timesyncd

- name: Create systemd-timesyncd configuration file
ansible.builtin.copy:
src: timesyncd.conf
dest: /etc/systemd/timesyncd.conf
mode: "0644"
notify: Reload systemd-timesyncd
9 changes: 0 additions & 9 deletions ansible/roles/host_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,3 @@
until: install_packages is success
retries: 5
delay: 2

# this is added to remove conflicts with systemd-timesyncd and ntpsec with kubespray installation
- name: Ensure conflicting time synchronization packages are removed
package:
name:
- ntpsec
- systemd-timesyncd
state: absent
purge: yes
8 changes: 8 additions & 0 deletions ansible/roles/host_setup/templates/timesyncd.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Time]
NTP={{ host_ntp_server | first }}
FallbackNTP={{ host_ntp_server | last }}
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
#ConnectionRetrySec=30
#SaveIntervalSec=60
1 change: 1 addition & 0 deletions ansible/roles/host_setup/vars/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ _host_distro_packages:
- rsync
- software-properties-common
- sysstat
- systemd-timesyncd
- time
- vlan
- wget
Expand Down

0 comments on commit e98770a

Please sign in to comment.