From c4f2ecaa9c989d653395c21af3fcab50ac68d985 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 5 Jun 2023 21:48:39 +0200 Subject: [PATCH] feat: enable chrony-wait service --- tasks/main.yml | 28 ++++++++++++++++++- .../time-sync.target.d/requires.conf.j2 | 4 +++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 templates/etc/systemd/system/time-sync.target.d/requires.conf.j2 diff --git a/tasks/main.yml b/tasks/main.yml index d50b26b..05a1648 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,6 +5,17 @@ name: chrony state: present + - name: Create required directories + loop: + - name: /etc/systemd/system/time-sync.target.d + mode: "0755" + loop_control: + label: "{{ item.name }}" + file: + path: "{{ item.name }}" + state: directory + mode: "{{ item.mode }}" + - name: Deploy configuration file template: src: etc/chrony.conf.j2 @@ -23,11 +34,26 @@ mode: 0644 notify: __chrony_restart - - name: Ensure service is up and running + - name: Deploy time-sync.target override file + template: + src: etc/systemd/system/time-sync.target.d/requires.conf.j2 + dest: /etc/systemd/system/time-sync.target.d/requires.conf + owner: root + group: root + mode: 0644 + notify: __chrony_restart + + - name: Ensure chronyd is up and running systemd: name: chronyd.service state: started daemon_reload: True enabled: True + + - name: Ensure chrony-wait is enabled + systemd: + name: chrony-wait.service + daemon_reload: True + enabled: True become: True become_user: root diff --git a/templates/etc/systemd/system/time-sync.target.d/requires.conf.j2 b/templates/etc/systemd/system/time-sync.target.d/requires.conf.j2 new file mode 100644 index 0000000..f197fd7 --- /dev/null +++ b/templates/etc/systemd/system/time-sync.target.d/requires.conf.j2 @@ -0,0 +1,4 @@ +#jinja2: lstrip_blocks: True +{{ ansible_managed | comment }} +[Unit] +Requires=chrony-wait.service