update..
This commit is contained in:
58
roles/common/tasks/samba-remove-user.yml
Normal file
58
roles/common/tasks/samba-remove-user.yml
Normal file
@ -0,0 +1,58 @@
|
||||
---
|
||||
|
||||
# ---
|
||||
# - 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 '{{ 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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
Reference in New Issue
Block a user