From d01f285adb683bb6f806f36cc6f7ac96ae7683ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BE=D0=BB=D0=B3=D0=B8=D0=B9=20=D0=90=D1=80=D1=82?= =?UTF-8?q?=D1=91=D0=BC?= Date: Thu, 24 Aug 2023 16:23:49 +0300 Subject: [PATCH] mod add_samba_users --- ansible_deploy_dc/add_samba_users.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ansible_deploy_dc/add_samba_users.yml b/ansible_deploy_dc/add_samba_users.yml index 6082cca..3bee7b3 100644 --- a/ansible_deploy_dc/add_samba_users.yml +++ b/ansible_deploy_dc/add_samba_users.yml @@ -2,6 +2,8 @@ - name: Создание пользователей контроллера домена hosts: dctest + vars: + - samba_user_mode: create vars_files: - samba_users.yml @@ -13,8 +15,21 @@ ansible.builtin.debug: var: user_list.stdout_lines - - name: Создаются пользователя домена - ansible.builtin.command: samba-tool user create {{ item.name }} {{ item.password }} + - name: Создаются пользователи домена + ansible.builtin.command: samba-tool user {{ samba_user_mode }} {{ item.name }} {{ item.password }} loop: "{{ samba_users }}" - when: not item.name in user_list.stdout_lines + when: (not item.name in user_list.stdout_lines) and (samba_user_mode != 'delete') no_log: true + + - name: Удаляются пользователи домена + ansible.builtin.command: samba-tool user {{ samba_user_mode }} {{ item.name }} + 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' + +