Thank you. I guess I missed that while reading, honestly I mostly skip down to the usage. I did not think about using the UNC path and yes, I will be able to utilize the same account for both servers thank goodness.
On Thursday, April 15, 2021 at 4:45:22 PM UTC-5 [email protected] wrote: > Each task is run in it's own shell, you cannot map a drive and expect to > be able to use it in an Ansible task. It even says it in the documentation > for win_mapped_drive > https://docs.ansible.com/ansible/latest/collections/community/windows/win_mapped_drive_module.html > > > 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. > > What you are meant to do is just use the UNC path and use become on the > task that needs to access that UNC path so the credentials are delegated. > If you need to use 2 separate credentials you might be able to make it work > with win_credential like > > - name: run tasks with become to access the cred store > become: yes # Required so you can access the cred store > become_method: runas > vars: > ansible_become_user: '{{ ansible_user }}' > ansible_become_pass: '{{ ansible_password }}' > block: > - win_credential: > name: server1 > type: domain_password > username: user1 > secret: password > state: present > > - win_credential: > name: server2 > type: domain_password > username: user2 > secret: password > state: present > > - win_command: robocopy \\server1\share\folder \\server2\share\folder > > On Friday, April 16, 2021 at 7:33:37 AM UTC+10 Daniel wrote: > >> Working on a playbook, using the following windows modules: >> win_mapped_drive and win_robocopy. >> I have been using net use commands since the late 80's with 3Com Lan >> Manager, so I know what I am doing and I can do what I want at the command >> line. >> >> win_mapped_drive x: >> block of stuff >> >> win_mapped_drive z: >> block of stuff >> >> win_robocopy >> block of stuff >> >> I am running this in AWX, and I see that when it does the first module it >> makes the connection and does it >> Then it makes a connection and does the second mapped drive >> Then it makes a connection and errors out at the robocopy, saying that x: >> does not exist. >> >> I tried making it persistent with become, runas, SYSTEM. Then I get a >> permission issue with win_robocopy module and I had to go into the registry >> and kill the mapped drives. >> >> I think it is "logging off" after every task, is there a way to make a >> single connection and keep the same connection for the entire playbook? >> >> Thank you >> > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7bf03b65-7181-4b4b-86ae-0d635ff9217dn%40googlegroups.com.
