diff --git a/roles/debian-base/defaults/main.yaml b/roles/debian-base/defaults/main.yaml index fa8f6da..5b2dc17 100644 --- a/roles/debian-base/defaults/main.yaml +++ b/roles/debian-base/defaults/main.yaml @@ -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 diff --git a/roles/debian-base/handlers/main.yml b/roles/debian-base/handlers/main.yml index 2626302..8ffbd80 100644 --- a/roles/debian-base/handlers/main.yml +++ b/roles/debian-base/handlers/main.yml @@ -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 \ No newline at end of file + command: /usr/sbin/update-exim4.conf diff --git a/roles/debian-base/tasks/main.yml b/roles/debian-base/tasks/main.yml index ab9c185..665c208 100644 --- a/roles/debian-base/tasks/main.yml +++ b/roles/debian-base/tasks/main.yml @@ -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 diff --git a/roles/debian-base/tasks/timesync.yml b/roles/debian-base/tasks/timesync.yml index 708a409..103234f 100644 --- a/roles/debian-base/tasks/timesync.yml +++ b/roles/debian-base/tasks/timesync.yml @@ -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