Refs #8025 Rol debian-base. Task timesync systemd fix, vars add to defaults, refactor handlers

This commit is contained in:
Xavi Lleó 2024-10-10 11:49:42 +02:00
parent 616beda4b7
commit d14b123219
4 changed files with 23 additions and 18 deletions

View File

@ -8,3 +8,4 @@ fail2ban:
vn_host:
url: http://apt.verdnatura.es/pool/main/v/vn-host
package: vn-host_2.0.2_all.deb
time_server_spain: ntp.roa.es

View File

@ -1,17 +1,17 @@
- name: restart-timesyncd
service:
- name: restart systemd-timesyncd
systemd:
name: systemd-timesyncd
state: restarted
- name: restart-ssh
service:
systemd:
name: ssh
state: restarted
- name: restart-fail2ban
service:
systemd:
name: fail2ban
state: restarted
- name: restart-nrpe
service:
systemd:
name: nagios-nrpe-server
state: restarted
- name: generate locales
@ -19,4 +19,4 @@
- name: reconfigure tzdata
command: dpkg-reconfigure -f noninteractive tzdata
- name: update exim configuration
command: /usr/sbin/update-exim4.conf
command: /usr/sbin/update-exim4.conf

View File

@ -1,5 +1,7 @@
- import_tasks: resolv.yml
tags: resolv
- import_tasks: timesync.yml
tags: timesync
- import_tasks: defuser.yml
tags: defuser
- import_tasks: install.yml

View File

@ -1,21 +1,23 @@
- name: Configure /etc/systemd/timesyncd.conf
lineinfile:
path: /etc/systemd/timesyncd.conf
regexp: '^#NTP'
line: "NTP={{ time_server }}"
- name: Ensure directory for timesyncd custom configuration exists
file:
path: /etc/systemd/timesyncd.conf.d/
state: directory
owner: root
group: root
mode: '0644'
- name: Configure /etc/systemd/timesyncd.conf
lineinfile:
path: /etc/systemd/timesyncd.conf
regexp: '^#?FallbackNTP='
line: "FallbackNTP=ntp.roa.es"
mode: '0755'
- name: Configure NTP settings in /etc/systemd/timesyncd.conf.d/vn-ntp.conf
copy:
dest: /etc/systemd/timesyncd.conf.d/vn-ntp.conf
content: |
[Time]
NTP={{ time_server }}
FallbackNTP={{ time_server_spain }}
owner: root
group: root
mode: '0644'
notify: restart systemd-timesyncd
- name: Service should start on boot
- name: Ensure systemd-timesyncd service is enabled and started
service:
name: systemd-timesyncd
enabled: yes
state: started