0

I am trying to install a monitoring agent using ansible with the win_command module to run by CMD as an administrator, Everyone I am having permission problems in the folder, but already set it to 'Everyone' and with Read and Write privileges

Playbook:

 - name: Installing SD Agent win_command: cmd.exe - args: stdin: start /wait {{ DIRWIN }}\SD_AGENT_WINNT\setup.exe /w /z"/sf{{ DIRWIN }}\SD_AGENT_WINNT\NTX64_Silent_Install.txt" /s /f2"\INSTALLSD\Silent_SD.log" become: yes become_user: administrador register: installSD - debug: var=installSD 

Output:

TASK [Automation_Install_SD : debug] *********************************************************************************************ok: [192.168.149.6] => { "installSD": { "changed": true, "cmd": "cmd.exe -", "delta": "0:00:23.032349", "end": "2020-03-02 04:53:09.762995", "failed": false, "rc": 0, "start": "2020-03-02 04:52:46.730645", "stderr": "", "stderr_lines": [], "stdout": "Microsoft Windows [versão 10.0.14393]\r\n(c) 2016 Microsoft Corporation. Todos os direitos reservados.\r\n\r\nC:\\Users\\Administrador.WIN-C7S8PFMJMUD>start /wait {{ DIRWIN }}\SD_AGENT_WINNT\setup.exe /w /z"/sf{{ DIRWIN }}\SD_AGENT_WINNT\NTX64_Silent_Install.txt" /s /f2"\INSTALLSD\Silent_SD.log"\r\n\r\nC:\\Users\\Administrador.WIN-C7S8PFMJMUD>", "stdout_lines": [ "Microsoft Windows [versão 10.0.14393]", "(c) 2016 Microsoft Corporation. Todos os direitos reservados.", "", "C:\\Users\\Administrador.WIN-C7S8PFMJMUD>start /wait {{ DIRWIN }}\SD_AGENT_WINNT\setup.exe /w /z"/sf{{ DIRWIN }}\SD_AGENT_WINNT\NTX64_Silent_Install.txt" /s /f2"\INSTALLSD\Silent_SD.log"", "", "C:\\Users\\Administrador.WIN-C7S8PFMJMUD>" ] } } 

Log:

03-02-2020 13:34:33: RC_INFO: The C:\AGENT\SD directory has locked files, you cannot continue. 

Variable:

DIRWIN = C:\AGENT\SD 

1 Answer 1

2

You should add specifically these configurations in your playbook (these are the configurations I see you're missing):

become_method: runas ansible_become_password: "{{ password }}" 

By Ansible official documentation:

- name: copy a file from a fileshare with custom credentials win_copy: src: \\server\share\data\file.txt dest: C:\temp\file.txt remote_src: yes vars: ansible_become: yes ansible_become_method: runas ansible_become_user: DOMAIN\user ansible_become_password: Password01 ansible_become_flags: logon_type=new_credentials logon_flags=netcredentials_only 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.