keep clock updated

This commit is contained in:
f 2022-06-19 02:48:44 -03:00
parent 1f650c21a7
commit ac9f6ba592
4 changed files with 42 additions and 0 deletions

View file

@ -24,6 +24,7 @@
- tinc - tinc
- prometheus-node-exporter - prometheus-node-exporter
- prometheus-node-exporter-openrc - prometheus-node-exporter-openrc
- ntpsec
tasks: tasks:
- include_tasks: "tasks/partition.yml" - include_tasks: "tasks/partition.yml"
- include_tasks: "tasks/encrypt.yml" - include_tasks: "tasks/encrypt.yml"

View file

@ -48,6 +48,8 @@
service: "hwclock" service: "hwclock"
- runlevel: "boot" - runlevel: "boot"
service: "swclock" service: "swclock"
- runlevel: "default"
service: "ntpd"
- name: "Install firewall rules." - name: "Install firewall rules."
template: template:
src: "templates/etc/iptables/{{ item }}.j2" src: "templates/etc/iptables/{{ item }}.j2"
@ -62,5 +64,19 @@
loop: loop:
- blocklist4 - blocklist4
- blocklist6 - blocklist6
- name: "Create NTP directories."
file:
state: "directory"
path: "{{ item }}"
loop:
- "/var/NTP"
- "/var/lib/ntp"
- name: "And services."
template:
src: "templates/{{ item }}.j2"
dest: "{{ item }}"
mode: "750"
loop:
- /etc/init.d/ntpd
- name: "Reboot!" - name: "Reboot!"
reboot: reboot:

20
templates/etc/init.d/ntpd.j2 Executable file
View file

@ -0,0 +1,20 @@
#!/sbin/openrc-run
DAEMON="/usr/sbin/ntpd"
PIDFILE="/var/run/ntpd.pid"
depend() {
need net
}
start() {
ebegin "Starting NTPSec"
start-stop-daemon --start --exec "${DAEMON}" --pidfile "${PIDFILE}"
eend $?
}
stop() {
ebegin "Stopping NTPSec"
start-stop-daemon --stop --pidfile "${PIDFILE}"
eend $?
}

5
templates/etc/ntp.conf Normal file
View file

@ -0,0 +1,5 @@
pool pool.ntp.org
driftfile /var/lib/ntp/ntp.drift
restrict default kod limited nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1