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
+12 -18
View File
@@ -1,59 +1,53 @@
---
# ---
# - Remove unwanted users
# ---
- name: "(samba-remove-user.yml) Check if samba user exists for removable system user"
shell: pdbedit -w -L | awk -F":" '{ print $1 }' | grep -q '{{ item.name }}'
ansible.builtin.shell: pdbedit -w -L | awk -F":" '{ print $1 }' | grep -q '{{ item.name }}'
register: samba_remove_system_users_present
changed_when: "samba_remove_system_users_present.rc == 0"
failed_when: "samba_remove_system_users_present.rc > 1"
with_items:
with_items:
- "{{ remove_samba_users }}"
loop_control:
label: '{{ item.name }}'
label: "{{ item.name }}"
tags:
- system-user
- samba-user
- name: (samba-remove-user.yml) Remove (old) system users from samba
shell: >
ansible.builtin.shell: >
smbpasswd -s -x {{ item.item.name }}
with_items:
with_items:
- "{{ samba_remove_system_users_present.results }}"
loop_control:
label: '{{ item.item.name }}'
when:
label: "{{ item.item.name }}"
when:
- item.changed
tags:
- system-user
- samba-user
- name: (samba-remove-user.yml) Remove users from system
user:
name: '{{ item.name }}'
ansible.builtin.user:
name: "{{ item.name }}"
state: absent
with_items:
- "{{ remove_samba_users }}"
loop_control:
label: '{{ item.name }}'
label: "{{ item.name }}"
tags:
- system-user
- samba-user
- name: (samba-remove-user.yml) Remove home directory from deleted users
file:
ansible.builtin.file:
path: "{{ base_home | default('/home', true) }}/{{ item.name }}"
state: absent
with_items:
- "{{ remove_samba_users }}"
loop_control:
label: '{{ item.name }}'
label: "{{ item.name }}"
tags:
- system-user
- samba-user