configure-ntp playbook
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1s
This commit is contained in:
50
playbooks/ntp-chrony.yml
Normal file
50
playbooks/ntp-chrony.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
- name: Настройка NTP через chrony
|
||||
hosts: all
|
||||
become: yes
|
||||
tasks:
|
||||
- name: Установка и настройка chrony (только для хостов и privileged LXC)
|
||||
block:
|
||||
- name: Установка chrony
|
||||
apt:
|
||||
name: chrony
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Настройка конфига под MikroTik
|
||||
copy:
|
||||
dest: /etc/chrony/chrony.conf
|
||||
mode: '0644'
|
||||
content: |
|
||||
# Управляется Ansible
|
||||
confdir /etc/chrony/conf.d
|
||||
server 192.168.0.234 iburst prefer
|
||||
pool 0.ru.pool.ntp.org iburst
|
||||
pool 1.ru.pool.ntp.org iburst
|
||||
pool 2.ru.pool.ntp.org iburst
|
||||
pool 3.ru.pool.ntp.org iburst
|
||||
sourcedir /run/chrony-dhcp
|
||||
sourcedir /etc/chrony/sources.d
|
||||
keyfile /etc/chrony/chrony.keys
|
||||
driftfile /var/lib/chrony/chrony.drift
|
||||
ntsdumpdir /var/lib/chrony
|
||||
logdir /var/log/chrony
|
||||
maxupdateskew 100.0
|
||||
rtcsync
|
||||
makestep 1 3
|
||||
leapsectz right/UTC
|
||||
register: chrony_config
|
||||
|
||||
- name: Перезапуск службы при изменении настроек
|
||||
systemd:
|
||||
name: chrony
|
||||
state: restarted
|
||||
when: chrony_config.changed
|
||||
|
||||
- name: Обеспечение автозапуска
|
||||
systemd:
|
||||
name: chrony
|
||||
state: started
|
||||
enabled: yes
|
||||
# Магия фильтрации: применяем ТОЛЬКО если это не гостевой LXC
|
||||
when: not (ansible_virtualization_type == 'lxc' and ansible_virtualization_role == 'guest')
|
||||
Reference in New Issue
Block a user