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: vn_host:
url: http://apt.verdnatura.es/pool/main/v/vn-host url: http://apt.verdnatura.es/pool/main/v/vn-host
package: vn-host_2.0.2_all.deb package: vn-host_2.0.2_all.deb
time_server_spain: ntp.roa.es

View File

@ -1,17 +1,17 @@
- name: restart-timesyncd - name: restart systemd-timesyncd
service: systemd:
name: systemd-timesyncd name: systemd-timesyncd
state: restarted state: restarted
- name: restart-ssh - name: restart-ssh
service: systemd:
name: ssh name: ssh
state: restarted state: restarted
- name: restart-fail2ban - name: restart-fail2ban
service: systemd:
name: fail2ban name: fail2ban
state: restarted state: restarted
- name: restart-nrpe - name: restart-nrpe
service: systemd:
name: nagios-nrpe-server name: nagios-nrpe-server
state: restarted state: restarted
- name: generate locales - name: generate locales
@ -19,4 +19,4 @@
- name: reconfigure tzdata - name: reconfigure tzdata
command: dpkg-reconfigure -f noninteractive tzdata command: dpkg-reconfigure -f noninteractive tzdata
- name: update exim configuration - 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 - import_tasks: resolv.yml
tags: resolv tags: resolv
- import_tasks: timesync.yml
tags: timesync
- import_tasks: defuser.yml - import_tasks: defuser.yml
tags: defuser tags: defuser
- import_tasks: install.yml - import_tasks: install.yml

View File

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