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:
2026-07-20 23:09:30 +02:00
parent bc330beebf
commit 81398e847e
33 changed files with 745 additions and 844 deletions
+10 -11
View File
@@ -1,6 +1,5 @@
---
#- name: (sudoers.yml) include variables
# - name: (sudoers.yml) include variables
# include_vars: "{{ item }}"
# with_first_found:
# - "sudoers-{{ inventory_hostname }}.yml"
@@ -11,28 +10,28 @@
# - sudoers-remove
# - sudoers-file-configuration
# - sudoers-global-configuration
- name: (sudoers.yml) Remove user entries in file /etc/sudoers
lineinfile:
ansible.builtin.lineinfile:
dest: /etc/sudoers
state: absent
regexp: '^{{ item }}'
regexp: "^{{ item }}"
owner: root
group: root
mode: 0440
mode: "0440"
validate: visudo -cf %s
with_items: '{{ sudoers_remove_user }}'
with_items: "{{ sudoers_remove_user }}"
tags:
- sudoers-remove
- name: (sudoers.yml) update specific sudoers configuration files (/etc/sudoers.d/)
template:
ansible.builtin.template:
src: etc/sudoers.d/50-user.j2
dest: /etc/sudoers.d/50-user
#validate: visudo -cf %s
owner: root
group: root
mode: 0440
mode: "0440"
tags:
- sudoers-file-configuration
@@ -48,10 +47,10 @@
# - sudoers-global-configuration
- name: (sudoers.yml) Ensure all sudo_users are in sudo group
user:
ansible.builtin.user:
name: "{{ item }}"
groups: sudo
append: yes
append: true
with_items: "{{ sudo_users }}"
tags:
- sudo-users