[Windows] Install visual studio

Hi

It seems i need to wait a bit after the Visual studio installation.
It stated as failed because it couldn’t remove the temporary install file (web install file) - VS was installed !

I’m using win_package and i’m not interested in using the raw module since i need the win_package capabilities.
A workaround would be to have: if you can’t remove the file, it’s not a failure and keep going (which i don’t know how to do yet :))

`

task path: /ansible/scripts/vs2012.yaml:23
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_package.ps1
ESTABLISH WINRM CONNECTION FOR USER: ansible on PORT 5986 TO hasjrwts02
creating Kerberos CC at /tmp/tmpJ_QHmz
calling kinit for principal ansible
kinit succeeded for principal ansible
WINRM CONNECT: transport=kerberos endpoint=https://hasjrwts02:5986/wsman
WINRM OPEN SHELL: 23C2DB3A-DC34-4DA0-A019-7CD45579D735
EXEC (via pipeline wrapper)
WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-ExecutionPolicy’, ‘Unrestricted’, ‘-’]
WINRM RESULT u’<Response code 1, out “”, err “An error occurred wh”>’
WINRM STDOUT
WINRM STDERR An error occurred while creating the pipeline.

  • CategoryInfo : NotSpecified: (:slight_smile: , ParentContainsErrorRecordException
  • FullyQualifiedErrorId : RuntimeException

Exception calling “Run” with “1” argument(s): “Exception calling “Invoke” with “0” argument(s): “The running command
stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop: Cannot remove item
C:\Users\ansible\r4muzag1.gdd: Access to the path ‘C:\Users\ansible\r4muzag1.gdd’ is denied.””
At line:47 char:5

  • $output = $entrypoint.Run($payload)
  • CategoryInfo : NotSpecified: (:slight_smile: , ParentContainsErrorRecordException
  • FullyQualifiedErrorId : ScriptMethodRuntimeException

WINRM CLOSE SHELL: 23C2DB3A-DC34-4DA0-A019-7CD45579D735
fatal: [hasjrwts02]: FAILED! => {
“changed”: false,
“module_stderr”: “An error occurred while creating the pipeline.\r\n + CategoryInfo : NotSpecified: (:slight_smile: , ParentContainsErrorRecordException\r\n + FullyQualifiedErrorId : RuntimeException\r\n \r\nException calling "Run" with "1" argument(s): "Exception calling "Invoke" with "0" argument(s): "The running command \r\nstopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot remove item \r\nC:\Users\ansible\r4muzag1.gdd: Access to the path ‘C:\Users\ansible\r4muzag1.gdd’ is denied.""\r\nAt line:47 char:5\r\n+ $output = $entrypoint.Run($payload)\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:slight_smile: , ParentContainsErrorRecordException\r\n + FullyQualifiedErrorId : ScriptMethodRuntimeException\r\n \r\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE”,
“rc”: 1
}
to retry, use: --limit @/ansible/scripts/vs2012.retry

`

Any idea please :slight_smile: ?

I have successfully installed visual studio using win_chocolatey in the past (with become escalating to run as local administrator). Might be worth trying that.
I suspect running with become might fix your problem as clearly its upset about having access to C:\\Users\\ansible\\r4muzag1.gdd

Hope this is some help,

Jon

Seems there is no become in the win_package module…

That's not how become works. You can set become: yes at the task and play level, not module level.

There’s windows-specific documentation about using become here: https://docs.ansible.com/ansible/devel/become.html#become-and-windows

Yes, and?

To avoid this issue and since my user is already admin on the server, i’ve just download the file first instead of installing over http url.
Thanks!

+1 for Chocolatey. Way easier to manage updates and install software and it pulls straight from the vendor if you use an internet package versus your own chocolatey repository.