Skip to content

Commit d782b1e

Browse files
committed
Configure local NTP server
1 parent 551b827 commit d782b1e

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

inventory.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ clients:
1616
kafka_topic: green
1717
"10.0.42.6":
1818
kafka_topic: blue
19+
ntpd:
20+
hosts:
21+
"10.0.42.1":

playbooks/proxy.yml

+37-13
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,44 @@
3030
- no_proxy
3131
- NO_PROXY
3232

33-
- name: Set up DNS
34-
ansible.builtin.copy:
33+
- name: Install Chrony on all hosts
34+
ansible.builtin.apt:
35+
name: chrony
36+
37+
- name: Configure one machine as an isolated NTP server
38+
hosts: ntpd
39+
become: true
40+
tasks:
41+
- ansible.builtin.copy:
42+
content: |
43+
allow 10.0.42.0/16
44+
dest: /etc/chrony/conf.d/local.conf
45+
register: restart_needed
46+
47+
- ansible.builtin.copy:
3548
content: |
36-
nameserver 10.0.0.1
37-
dest: /etc/resolv.conf
49+
local
50+
server 10.0.0.1
51+
dest: /etc/chrony/sources.d/gateway.sources
52+
register: restart_needed
3853

39-
- name: Create /etc/systemd/timesyncd.conf.d directory
40-
ansible.builtin.file:
41-
path: /etc/systemd/timesyncd.conf.d
42-
state: directory
54+
- ansible.builtin.systemd_service:
55+
name: chrony.service
56+
state: restarted
57+
when: restart_needed.changed
4358

44-
- name: Set up NTP
45-
ansible.builtin.copy:
59+
- name: Configure all other machines to get their time from the isolated NTP server
60+
hosts: all:!ntpd
61+
become: true
62+
tasks:
63+
64+
- ansible.builtin.copy:
4665
content: |
47-
[Time]
48-
NTP=10.0.0.1
49-
dest: /etc/systemd/timesyncd.conf.d/proxy.conf
66+
server {{groups.ntpd[0]}} iburst
67+
dest: /etc/chrony/sources.d/local.sources
68+
register: restart_needed
69+
70+
- ansible.builtin.systemd_service:
71+
name: chrony.service
72+
state: restarted
73+
when: restart_needed.changed

0 commit comments

Comments
 (0)