diff --git a/roles/config-ntp/handlers/main.yaml b/roles/config-ntp/handlers/main.yaml index c77652f..a089d46 100644 --- a/roles/config-ntp/handlers/main.yaml +++ b/roles/config-ntp/handlers/main.yaml @@ -1,5 +1,5 @@ # restart crontab service to apply changes -- name: restart crontab hourly +- name: restart systemd-timesyncd service: - name: "{{ cron_daemon }}" + name: "{{ timesyncd_daemon }}" state: restarted \ No newline at end of file diff --git a/roles/config-ntp/tasks/main.yaml b/roles/config-ntp/tasks/main.yaml index 9c08c7e..c071870 100644 --- a/roles/config-ntp/tasks/main.yaml +++ b/roles/config-ntp/tasks/main.yaml @@ -3,22 +3,34 @@ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# SE OMITE , SE REALIZA CON systemd-timesyncd.service # paso1 # install package ntpdate -- name: install package ntpdate - apt: - name: "{{ ntpdate_package }}" - state: present +#- name: install package ntpdate +# apt: +# name: "{{ ntpdate_package }}" +# state: present #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # paso2 # copy timesync file to crontab.hourly -- name: copy file timesync to /etc/cron.hourly/timesync - copy: - src: timesync - dest: "{{ timesync_path }}" +#- name: copy file timesync to /etc/cron.hourly/timesync +# copy: +# src: timesync +# dest: "{{ timesync_path }}" +# owner: root +# group: root +# mode: '0644' +# backup: yes # NO backups +# notify: restart crontab hourly +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +# retocar fichero /etc/systemd/timesyncd.conf +- name: retocar fichero /etc/systemd/timesyncd.conf + lineinfile: + path: /etc/systemd/timesyncd.conf + regexp: '^#NTP' + line: "NTP=time1.verdnatura.es time2.verdnatura.es" owner: root group: root mode: '0644' -# backup: yes # NO backups - notify: restart crontab hourly -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file + notify: restart systemd-timesyncd \ No newline at end of file diff --git a/roles/config-ntp/vars/main.yaml b/roles/config-ntp/vars/main.yaml index 74a621e..5b626b1 100644 --- a/roles/config-ntp/vars/main.yaml +++ b/roles/config-ntp/vars/main.yaml @@ -1,4 +1,4 @@ # vars file ntpdate_package: ntpdate timesync_path: /etc/cron.hourly/timesync -cron_daemon: cron \ No newline at end of file +timesyncd_daemon: systemd-timesyncd \ No newline at end of file