I’m not able to use a share or unc path in the source parameter of win_chocolatey module
The same is running if you use choco directly with cinst -y myPack --source “\myserver\myshare”
What you are most likely coming across is the double hop/credential delegation issue as Ansible runs the task through WinRM. When using WinRM (or other network logons), the user’s credentials are typically not accessible to the running process so it cannot then authenticate with different servers like a file share. In this case it will try and access the share as an anonymous user which results in either an access is denied or file not found error. Compared to when you run it locally, the process has access to the user’s credentials and can authenticate as that user for downstream server implicitly.
So to get this task working you have a few options available to you;
If in a domain environment, use ‘ansible_winrm_transport: kerbros’ and ‘ansible_winrm_kerberos_delegation: True’ to enable Kerberos auth with credential delegation
A special Kerb ticket is sent to the server which can use that ticket for further authentication
You can configure this to be constrained to only work for certain downstream servers in AD if you wish
This is the most secure option as no credential is actually sent to the server but a special kerb ticket but it still has some limitations where become is more suited towards the task
Use ‘ansible_winrm_transport: credssp’ after enabling CredSSP auth on your Windows host
This works the same as Kerberos but works for local account but this is unconstrained delegation- Use become[1] on the Ansible task
As well as running it in a process that has access to the user’s credentials it also changes the logon type from network to interactive
This can solve other issues when it comes to installing certain programs or hotfixes
Using become is probably the easiest and it’s quite simple to do;
What that task will do is run under become and set the become user to the current Ansible connection user with it’s password. Give that a try and see how you go.