add ntp playbook and roles

This commit is contained in:
Ruben Blanco 2023-10-23 13:46:57 +02:00
parent ba22846931
commit 26f6adb53b
6 changed files with 58 additions and 0 deletions

View File

@ -42,6 +42,11 @@
name: config-server-type
tags: config-server-type_config
- name: "[CONFIG NTP] Install and configure ntp"
import_role:
name: config-ntp
tags: config-ntp_config
#handlers:
# - include_tasks: roles/{{ item }}/handlers/main.yaml
# with_items:

12
linux-config-ntp.yaml Normal file
View File

@ -0,0 +1,12 @@
---
- hosts: "{{ ip_addr }}"
become: yes
become_method: sudo
gather_facts: yes
tasks:
- name: "[CONFIG NTP] Install and configure ntp"
import_role:
name: config-ntp

View File

@ -0,0 +1,8 @@
#!/bin/sh
# PLS do NOT delete timesyncing from VM virtuals
# it is necessary for critical cluster services
# nada
test -x /usr/sbin/ntpdate || exit 0
/usr/sbin/ntpdate time1.verdnatura.es
/usr/sbin/ntpdate time2.verdnatura.es

View File

@ -0,0 +1,5 @@
# restart crontab service to apply changes
- name: restart crontab hourly
service:
name: "{{ cron_daemon }}"
state: restarted

View File

@ -0,0 +1,24 @@
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Install and configure NTP
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# paso1
# install package ntpdate
- name: install package ntpdate
apt:
name: "{{ ntpdate_package }}"
state: present
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# paso2
# copy timesync file to crontab.hourly
- name: copy file nslcd.conf
copy:
src: timesync
dest: "{{ timesync_path }}"
owner: root
group: root
mode: '0644'
backup: yes
notify: restart crontab hourly
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -0,0 +1,4 @@
# vars file
ntpdate_package: ntpdate
timesync_path: /etc/cron.hourly/timesync
cron_daemon: cron