Files
oopen-server/roles/common/tasks/ntp.yml
T

63 lines
1.5 KiB
YAML

---
# ---
# NTP Server
# ---
- name: (ntp.yml) Ensure ntpsec package is installed.
ansible.builtin.apt:
name:
- ntpsec
state: present
when:
- ansible_facts.os_family == "Debian"
tags:
- ntp-server
- name: (ntp.yml) Check file '/etc/ntpsec/ntp.conf.ORIG' exists
ansible.builtin.stat:
path: /etc/ntpsec/ntp.conf.ORIG
register: common_etc_ntpsec_conf_orig
when:
- ansible_facts.distribution == "Debian"
tags:
- ntp-server
- name: (ntp.yml) Ensure directory '/var/log/ntpsec' is present
ansible.builtin.file:
path: /var/log/ntpsec
state: directory
owner: ntpsec
group: ntpsec
mode: "0755"
when:
- ansible_facts.distribution == "Debian"
- name: (ntp.yml) Backup installation version of file '/etc/ntpsec/ntp.conf'
ansible.builtin.copy:
src: /etc/ntpsec/ntp.conf
dest: /etc/ntpsec/ntp.conf.ORIG
remote_src: true
owner: root
group: root
mode: "0644"
when:
- groups['oopen_office_server']|string is search(inventory_hostname)
- not common_etc_ntpsec_conf_orig.stat.exists
- local_ntp_service is defined and local_ntp_service
tags:
- ntp-server
- name: (ntp.yml) Update '/etc/ntpsec/ntp.conf'
ansible.builtin.template:
src: "etc/ntpsec/ntp.conf.j2"
dest: /etc/ntpsec/ntp.conf
owner: root
group: root
mode: "0644"
notify: Restart ntp
when:
- groups['oopen_office_server']|string is search(inventory_hostname)
- local_ntp_service is defined and local_ntp_service|bool
tags:
- ntp-server