39 lines
1.2 KiB
YAML
39 lines
1.2 KiB
YAML
|
---
|
||
|
|
||
|
- name: Создание пользователей контроллера домена
|
||
|
hosts: dctest1
|
||
|
vars:
|
||
|
- samba_user_mode: create
|
||
|
|
||
|
tasks:
|
||
|
- name: Пользователи в домене Samba
|
||
|
ansible.builtin.command: samba-tool user list
|
||
|
register: user_list
|
||
|
- name: Список пользователей
|
||
|
ansible.builtin.debug:
|
||
|
var: user_list.stdout_lines
|
||
|
|
||
|
- name: Создаются пользователи домена
|
||
|
ansible.builtin.command: |
|
||
|
samba-tool user {{ samba_user_mode }} \
|
||
|
{{ item.username }} {{ item.password }} \
|
||
|
--login-shell=/bin/bash \
|
||
|
--gecos='{{ item.fname }} {{ item.sname }}' \
|
||
|
--given-name={{ item.fname }} --surname={{ item.sname }}
|
||
|
loop: "{{ samba_users }}"
|
||
|
when: (not item.username in user_list.stdout_lines) and (samba_user_mode != 'delete')
|
||
|
no_log: true
|
||
|
|
||
|
- name: Удаляются пользователи домена
|
||
|
ansible.builtin.command: samba-tool user {{ samba_user_mode }} {{ item.username }}
|
||
|
loop: "{{ samba_users }}"
|
||
|
when: samba_user_mode == 'delete'
|
||
|
register: status
|
||
|
ignore_errors: true
|
||
|
no_log: true
|
||
|
- debug:
|
||
|
msg: "{{ status.results[1].stderr_lines }}"
|
||
|
when: samba_user_mode == 'delete'
|
||
|
|
||
|
|