ansible.windows.win_copy - Copy wireguard config files works but throws an error

It’s possible to install config files for Windows Wireguard GUI by copying them to a location

“The manager service monitors %ProgramFiles%\WireGuard\Data\Configurations\ for the addition of new .conf files. Upon seeing one, it encrypts the file to a .conf.dpapi file, makes it unreadable to users other than Local System”

https://git.zx2c4.com/wireguard-windows/about/docs/enterprise.md

It works in that the files are imported ok but behaviour is strange…
*First run it can either work ok ‘changed’ or throw an error (but still work) total guess here but could wireguard be grabbing the file preventing ansible from confirming it’s been copied (?)
*Second run usually shows ‘changed’ without errors even though it works the first time
*With further of runs it will eventually settle on a green ok

So, I can just ignore errors here but is there a more graceful way to do this?

Is there some way to keep looping through these tasks until all become green ok?

Example:

  • name: copy lh conf file
    ansible.windows.win_copy:
    src: ‘G:\config\lh.conf’
    dest: 'C:\Program Files\WireGuard\Data\Configurations'
    remote_src: yes

-vvv error

The full traceback is:
Cannot find path ‘C:\Program Files\WireGuard\Data\Configurations\mont.conf’ because it does not exist.
At line:133 char:13

  • $file = Get-Item -LiteralPath $path -Force
  • CategoryInfo : ObjectNotFound: (C:\Program File…tions\mont.conf:String) [Get-Item], ItemNotFoundException
  • FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

ScriptStackTrace:
at Get-FileSize, : line 133
at , : line 367

System.Management.Automation.ItemNotFoundException: Cannot find path ‘C:\Program Files\WireGuard\Data\Configurations\mont.conf’ because it does not exist.
at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext context, Boolean allowNonexistingPaths, CmdletProvider& providerInstance)
at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, CmdletProvider& providerInstance)
at System.Management.Automation.LocationGlobber.GetGlobbedProviderPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, ProviderInfo& provider, CmdletProvider& providerInstance)
at System.Management.Automation.SessionStateInternal.GetItem(String paths, CmdletProviderContext context)
at Microsoft.PowerShell.Commands.GetItemCommand.ProcessRecord()
fatal: [beast_win]: FAILED! => {
“changed”: false,
“dest”: “C:\Program Files\WireGuard\Data\Configurations\”,
“msg”: “Unhandled exception while executing module: Cannot find path ‘C:\Program Files\WireGuard\Data\Configurations\mont.conf’ because it does not exist.”,
“src”: “G:\scripts\wireguard\mont_wg_config\users\beast\mont.conf”