Create chrony-online service

NetworkManager has a dispatcher which may cause the sources to be marked
as disabled. If you don't have any interfaces actually managed with
NetworkManager, we need to have a way to ensure that the sources get
marked enabled on boot. This change adds a chrony-online service that
waits for the network-online.target in order to be able to make chronyd
source online.

Change-Id: Ib1d91852d281c63b2458fc3c0199a5d5fed17056
This commit is contained in:
Alex Schultz 2022-01-17 11:30:23 -07:00
parent ae5374e14a
commit 14b34c20e5
4 changed files with 31 additions and 1 deletions

View File

@ -18,7 +18,7 @@ Role Variables
- Enable debug option in chrony
* - `chrony_role_action`
- `all`
- Ansible action when including the role. Should be one of: [all|install|config|upgrade]
- Ansible action when including the role. Should be one of: [all|install|config|upgrade|online]
* - `chrony_package_name`
- `chrony`
- chrony system package name

View File

@ -0,0 +1,12 @@
[Unit]
Description=chronyd online sources service
After=network-online.target chronyd.service
Wants=network-online.target chronyd.service
[Service]
Type=oneshot
ExecStart=/usr/libexec/chrony-helper command online
User=root
[Install]
WantedBy=multi-user.target

View File

@ -17,3 +17,7 @@
- name: Configure chronyd
include_tasks: config.yml
when: chrony_role_action in ['all', 'config']
- name: Enable online service
include_tasks: online.yml
when: chrony_role_action in ['all', 'online']

14
tasks/online.yml Normal file
View File

@ -0,0 +1,14 @@
---
- name: Create chrony-online.service unit file
become: True
copy:
src: files/chrony-online.service
dest: /etc/systemd/system/chrony-online.service
- name: Enable chrony-online.service
become: True
systemd:
state: started
name: chrony-online.service
enabled: true
daemon-reload: true