Refactor Ansible tasks and templates for improved consistency and clarity

This commit is contained in:
2026-07-31 02:24:42 +02:00
parent 81ef678904
commit 46327da2ac
52 changed files with 1679 additions and 1461 deletions
+18 -13
View File
@@ -5,28 +5,27 @@
# ---
- name: (ntp.yml) Ensure ntpsec package is installed.
apt:
ansible.builtin.apt:
name:
- ntpsec
state: present
when:
- ansible_facts.os_family == "Debian"
- groups['file_server']|string is search(inventory_hostname)
- groups['file_server'] | string is search(inventory_hostname)
tags:
- ntp-server
- name: (ntp.yml) Check file '/etc/ntpsec/ntp.conf.ORIG' exists
stat:
ansible.builtin.stat:
path: /etc/ntpsec/ntp.conf.ORIG
register: etc_ntpsec_conf_ORIG
register: common_etc_ntpsec_conf_orig
when:
- groups['file_server']|string is search(inventory_hostname)
- groups['file_server'] | string is search(inventory_hostname)
tags:
- ntp-server
- name: (ntp.yml) Ensure directory '/var/log/ntpsec' is present
file:
ansible.builtin.file:
path: /var/log/ntpsec
state: directory
owner: ntpsec
@@ -37,10 +36,17 @@
- name: (ntp.yml) Backup installation version of file '/etc/ntpsec/ntp.conf'
command: cp /etc/ntpsec/ntp.conf /etc/ntpsec/ntp.conf.ORIG
ansible.builtin.copy:
src: /etc/ntpsec/ntp.conf
dest: /etc/ntpsec/ntp.conf.ORIG
remote_src: true
owner: root
group: root
mode: "0644"
force: false
when:
- groups['file_server']|string is search(inventory_hostname)
- etc_ntpsec_conf_ORIG.stat.exists == False
- groups['file_server'] | string is search(inventory_hostname)
- not common_etc_ntpsec_conf_orig.stat.exists
tags:
- ntp-server
@@ -50,10 +56,9 @@
dest: /etc/ntpsec/ntp.conf
owner: root
group: root
mode: 0644
mode: "0644"
notify: Restart ntp
when:
- groups['file_server']|string is search(inventory_hostname)
- groups['file_server'] | string is search(inventory_hostname)
tags:
- ntp-server