Files
nis/roles/common/tasks/samba-user.yml
T

40 lines
1.0 KiB
YAML

---
# ---
# - default user/groups
# ---
- name: (samba-user.yml) Check if samba user exists for nis user
ansible.builtin.shell:
cmd: >-
set -o pipefail &&
pdbedit -w -L | awk -F":" '{ print $1 }' | grep -e "^{{ item.name }}"
executable: /bin/bash
register: common_samba_nis_user_present
changed_when: false
failed_when: common_samba_nis_user_present.rc > 1
loop: "{{ nis_user }}"
loop_control:
label: '{{ item.name }}'
when:
- item.is_samba_user is defined and item.is_samba_user | bool
tags:
- samba-user
- name: (samba-user.yml) Add nis user to samba (with nis users password)
ansible.builtin.shell:
cmd: >-
set -o pipefail &&
(echo '{{ item.item.password }}'; echo '{{ item.item.password }}') |
smbpasswd -s -a {{ item.item.name }}
executable: /bin/bash
changed_when: true
loop: "{{ common_samba_nis_user_present.results }}"
when:
- item.rc is defined
- item.rc == 1
loop_control:
label: '{{ item.item.name }}'
tags:
- samba-user