Files
ansible-repo/playbooks/ntp-chrony.yml
hogweed1 d1528c8e31
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s
make prometheus less big
2026-06-11 00:21:28 +10:00

50 lines
1.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- 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: ansible_virtualization_type != 'lxc'