vn-ansible/roles/config-ntp/tasks/main.yaml

45 lines
1.4 KiB
YAML
Raw Normal View History

2023-10-23 11:46:57 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Install and configure NTP
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2024-02-15 16:30:52 +00:00
- name: "[CONFIG NTP] Comprobando si es necesario configurar ntp"
meta: end_host
when: ntp_enabled is not defined or not ntp_enabled
2023-10-23 11:46:57 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-30 16:34:30 +00:00
# SE OMITE , SE REALIZA CON systemd-timesyncd.service
2023-10-23 11:46:57 +00:00
# paso1
# install package ntpdate
2023-10-30 16:34:30 +00:00
#- name: install package ntpdate
# apt:
# name: "{{ ntpdate_package }}"
# state: present
2023-10-23 11:46:57 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# paso2
# copy timesync file to crontab.hourly
2023-10-30 16:34:30 +00:00
#- 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"
2023-10-23 11:46:57 +00:00
owner: root
group: root
mode: '0644'
2024-02-12 16:32:18 +00:00
notify: restart systemd-timesyncd
# service should start on boot.
- name: service should start on boot
service:
name: "{{ timesyncd_daemon }}"
enabled: yes