Closed Pshemas closed 8 months ago
Have a look at the notes of the modules documentation
You cannot use this module to access a mapped drive in another Ansible task, drives mapped with this module are only accessible when logging in interactively with the user through the console or RDP.
Mapped drives are just for interactive uses and won't ever work inside another Ansible task. If all you need is to authenticate with a network endpoint with custom credentials you can use the UNC path and become
- name: install inkscape
ansible.windows.win_package:
path: \\192.168.1.122\installers\inkscape\inkscape_x64.msi
arguments: ALLUSERS=1
state: present
become: true
become_method: runas
become_flags: logon_type=new_credentials logon_flags=netcredentials_only
vars:
ansible_become_user: someuser
ansible_become_pass: somepassword
It will access the UNC path directly but with the new_credentials
become flags it will now use the become credentials provided for authentication.
thank you @jborean93 . I overlooked this part of the docs.
Any suggestions on solving the same problem while using chocolatey packages stored on SMB share?
In more general sense - is there a way to mount a network share so it would be usable by other tasks some other way? I see several workflows where it would make things much easier (mount first, then use it).
Use the become stuff I shared with a UNC path for credential support, as for mapped drives just don't use them. Always use the UNC path.
I'm trying to use
win_mapped_drive
in a chain of tasks (playbook). The idea is to map drive temporarily on Windows devices and then run powershell script that would use files in share. For example:But sadly it seems that the second task does not see the mapped drive. I had similar issue when I've tried doing
net use
andmsiexec
in separate steps (tasks) like here. If I did both in a single task it worked.I guess it's very likely I'm doing something wrong, but after flipping through docs and trying different options I'm out of ideas.