Browse Source

Move time synchronization (client) out to its own role.

master
Dan Helfman 6 months ago
parent
commit
87e2e00418
3 changed files with 22 additions and 19 deletions
  1. 0
    19
      roles/common/tasks/main.yml
  2. 21
    0
      roles/time_synchronization/tasks/main.yml
  3. 1
    0
      site.yml

+ 0
- 19
roles/common/tasks/main.yml View File

@@ -153,25 +153,6 @@
153 153
   tags:
154 154
     - common
155 155
 
156
-# Linode apparently doesn't need timesyncd to keep time, because it's a VM.
157
-# (And timesyncd actually screws up the date on Linode.)
158
-- name: configure NTP server on Manjaro
159
-  lineinfile:
160
-    dest: /etc/systemd/timesyncd.conf
161
-    line: "NTP=time.nist.gov"
162
-    regexp: "^NTP="
163
-    state: present
164
-  when: ansible_distribution in ["Manjaro", "Manjaro-ARM"]
165
-  register: time_server_result
166
-  tags:
167
-    - common
168
-
169
-- name: enable time synchronization on Manjaro
170
-  command: "timedatectl set-ntp true"
171
-  when: time_server_result.changed and ansible_distribution in ["Manjaro", "Manjaro-ARM"]
172
-  tags:
173
-    - common
174
-
175 156
 - name: enable rsyslog on Debian
176 157
   command: systemctl enable rsyslog
177 158
   when: ansible_distribution == "Debian" and install_result.changed

+ 21
- 0
roles/time_synchronization/tasks/main.yml View File

@@ -0,0 +1,21 @@
1
+# Note that Linode apparently doesn't need timesyncd to keep time, because it's
2
+# a VM. And timesyncd actually screws up the date on Linode. So don't use this
3
+# role on Linode VMs.
4
+
5
+- name: configure NTP server
6
+  lineinfile:
7
+    dest: /etc/systemd/timesyncd.conf
8
+    line: "NTP=time.nist.gov"
9
+    regexp: "^NTP="
10
+    state: present
11
+  register: time_server_result
12
+  tags:
13
+    - time_synchronization
14
+
15
+- name: enable time synchronization
16
+  command: "timedatectl set-ntp true"
17
+  when: time_server_result.changed
18
+  tags:
19
+    - time_synchronization
20
+
21
+

+ 1
- 0
site.yml View File

@@ -50,4 +50,5 @@
50 50
   roles:
51 51
     - common
52 52
     - wireless
53
+    - time_synchronization
53 54
     - home_automation

Loading…
Cancel
Save