Files
oopen-server/roles/common/tasks/samba-remove-user.yml
T
chris 81398e847e 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.
2026-07-20 23:09:30 +02:00

54 lines
1.4 KiB
YAML

---
# ---
# - Remove unwanted users
# ---
- name: "(samba-remove-user.yml) Check if samba user exists for removable system user"
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:
- "{{ remove_samba_users }}"
loop_control:
label: "{{ item.name }}"
tags:
- system-user
- samba-user
- name: (samba-remove-user.yml) Remove (old) system users from samba
ansible.builtin.shell: >
smbpasswd -s -x {{ item.item.name }}
with_items:
- "{{ samba_remove_system_users_present.results }}"
loop_control:
label: "{{ item.item.name }}"
when:
- item.changed
tags:
- system-user
- samba-user
- name: (samba-remove-user.yml) Remove users from system
ansible.builtin.user:
name: "{{ item.name }}"
state: absent
with_items:
- "{{ remove_samba_users }}"
loop_control:
label: "{{ item.name }}"
tags:
- system-user
- samba-user
- name: (samba-remove-user.yml) Remove home directory from deleted users
ansible.builtin.file:
path: "{{ base_home | default('/home', true) }}/{{ item.name }}"
state: absent
with_items:
- "{{ remove_samba_users }}"
loop_control:
label: "{{ item.name }}"
tags:
- system-user
- samba-user