Hi everyone,

I'm trying to mount smb share on windows host (win10 pro) that requires 
authentication using *win_mapped_drive/win_credential*

Here is the playbook sample (based on docs example)

- name: Create mapped drive with credentials and save the username and password
  block:
  - name: Save the network credentials required for the mapped drive
    win_credential:
      name: 10.0.20.1
      type: domain_password
      username: DOMAIN\admin
      secret: password
      state: present

  - name: Create a mapped drive that requires authentication
    win_mapped_drive:
      letter: M
      path: \\10.0.20.1\myshare1
      state: present
  vars:
    # become is required to save and retrieve the credentials in the tasks
    ansible_become: yes
    ansible_become_method: runas
    ansible_become_user: '{{ ansible_user }}'
    ansible_become_pass: '{{ ansible_password }}'

But the issue is:

- if *ansible_become_pass* variable is set *win_mapped_drive *task fails:
The full traceback is:
Exception calling "Invoke" with "2" argument(s): "Failed to map M: to 
'\\10.0.20.1\myshare1' with WNetAddConnection2W() (The specified network 
password is not correct, Win32ErrorCode 86)"
At line:420 char:17
+ ... $add_method.Invoke($null, [Object[]]@($letter_root, $path ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
 + FullyQualifiedErrorId : Win32Exception

ScriptStackTrace:
at <ScriptBlock>, <No file>: line 420
fatal: [win1]: FAILED! => {
 "changed": false,
 "msg": "Unhandled exception while executing module: Exception calling 
\"Invoke\" with \"2\" argument(s): \"Failed to map M: to 
'\\\\10.0.20.1\\myshare1' with WNetAddConnection2W() (The specified network 
password is not correct, Win32ErrorCode 86)\""
}


- if *ansible_become_pass* variable is unset (or empty string) - everything 
works perfectly


So, AFAIK in 2.8+ become can work without password, as the docs say:
https://docs.ansible.com/ansible/latest/user_guide/become.html#become-without-setting-a-password

But my assumtions were, that with password defined it should wark just fine

My ansible version is - ansible 2.9.9
Windows host's account i'm using is local admin

Can someone help me to debug the issue, it's probably me missusing the 
module or some sort of admin account missconfiguration (e.g. disabled 
priveledges mb), but no ideas left for me to prove it, thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/0a719ed2-1890-4b8b-8a68-d4ecf0bc59afo%40googlegroups.com.

Reply via email to