Refactor Ansible tasks to use fully qualified module names and improve code consistency
- Updated all tasks to use fully qualified module names (e.g., ansible.builtin.shell, ansible.builtin.copy) for clarity and to avoid ambiguity. - Replaced deprecated 'yum' module with 'dnf' for package management on RedHat-based systems. - Improved formatting and consistency in task definitions, including the use of double quotes for strings and consistent indentation. - Removed unnecessary comments and whitespace to enhance readability. - Ensured that conditions and loops are consistently formatted across all tasks.
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
---
|
||||
|
||||
# ---
|
||||
# NTP Server
|
||||
# ---
|
||||
|
||||
- name: (ntp.yml) Ensure ntpsec package is installed.
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- ntpsec
|
||||
state: present
|
||||
@@ -15,7 +14,7 @@
|
||||
- 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
|
||||
when:
|
||||
@@ -23,20 +22,18 @@
|
||||
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
|
||||
group: ntpsec
|
||||
mode: '0755'
|
||||
mode: "0755"
|
||||
when:
|
||||
- ansible_facts.distribution == "Debian"
|
||||
|
||||
|
||||
- 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.command: cp /etc/ntpsec/ntp.conf /etc/ntpsec/ntp.conf.ORIG
|
||||
when:
|
||||
- groups['oopen_office_server']|string is search(inventory_hostname)
|
||||
- etc_ntpsec_conf_ORIG.stat.exists == False
|
||||
@@ -45,16 +42,15 @@
|
||||
- ntp-server
|
||||
|
||||
- name: (ntp.yml) Update '/etc/ntpsec/ntp.conf'
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/ntpsec/ntp.conf.j2"
|
||||
dest: /etc/ntpsec/ntp.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user