Refactor Ansible tasks and templates for improved consistency and clarity

This commit is contained in:
2026-07-31 02:24:42 +02:00
parent 81ef678904
commit 46327da2ac
52 changed files with 1679 additions and 1461 deletions
+18 -11
View File
@@ -5,26 +5,33 @@
# ---
- name: (samba-user.yml) Check if samba user exists for nis user
shell: pdbedit -w -L | awk -F":" '{ print $1 }' | grep -e "^{{ item.name }}"
register: samba_nis_user_present
changed_when: "samba_nis_user_present.rc == 1"
failed_when: "samba_nis_user_present.rc > 1"
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
- 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)
shell: >
(echo '{{ item.item.password }}'; echo '{{ item.item.password }}')
| smbpasswd -s -a {{ item.item.name }}
loop: "{{ samba_nis_user_present.results }}"
when: item.changed
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 == 1
loop_control:
label: '{{ item.item.name }}'
tags:
- samba-user