diff --git a/roles/common/tasks/samba-remove-user.yml b/roles/common/tasks/samba-remove-user.yml index 98a0c1f..eb0d05b 100644 --- a/roles/common/tasks/samba-remove-user.yml +++ b/roles/common/tasks/samba-remove-user.yml @@ -3,10 +3,14 @@ # - 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" + ansible.builtin.shell: + executable: /bin/bash + cmd: | + set -o pipefail + pdbedit -w -L | awk -F":" '{ print $1 }' | grep -q '{{ item.name }}' + register: common_samba_remove_system_users_present + changed_when: "common_samba_remove_system_users_present.rc == 0" + failed_when: "common_samba_remove_system_users_present.rc > 1" with_items: - "{{ remove_samba_users }}" loop_control: @@ -15,15 +19,19 @@ - system-user - samba-user -- name: (samba-remove-user.yml) Remove (old) system users from samba - ansible.builtin.shell: > - smbpasswd -s -x {{ item.item.name }} +- name: (samba-remove-user.yml) Remove (old) system users from samba # noqa no-handler + ansible.builtin.shell: + executable: /bin/bash + cmd: | + set -o pipefail + smbpasswd -s -x {{ item.item.name }} with_items: - - "{{ samba_remove_system_users_present.results }}" + - "{{ common_samba_remove_system_users_present.results }}" loop_control: label: "{{ item.item.name }}" when: - item.changed + changed_when: true tags: - system-user - samba-user