0
votes

I am trying to install Visual Studio 2017 using Ansible for Windows and I'm running into a strange issue. The installer is located at Z:\visualstudio\2017\vs2017_professional\vs2017_Professional.exe, and here is my task to run it:

- name: Install Visual Studio
  win_shell: Start-Process -FilePath Z:\visualstudio\2017\vs2017_professional\vs2017_Professional.exe -ArgumentList '--quiet --norestart' -Wait
  args:
    creates: 'C:\Program Files (x86)\MSBuild\14.1\Bin\MSBuild.exe'
  become_user: Administrator

However, it always fails:

fatal: [hostname]: FAILED! => {"changed": true, "cmd": "Start-Process -FilePath Z:\visualstudio\2017\vs2017_professional\vs2017_Professional.exe -ArgumentList '--quiet --norestart' -Wait", "delta": "0:00:06.157773", "end": "2018-10-17 09:00:35.262158", "msg": "non-zero return code", "rc": 1, "start": "2018-10-17 09:00:29.104384", "stderr": "Start-Process : This command cannot be run due to the error: The system cannot find the drive specified.\r\nAt line:1 char:65\r\n+ ... ing $false; Start-Process -FilePath Z:\visualstudio\2017\vs2017_profe ...\r\n+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException\r\n + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand", "stderr_lines": ["Start-Process : This command cannot be run due to the error: The system cannot find the drive specified.", "At line:1 char:65", "+ ... ing $false; Start-Process -FilePath Z:\visualstudio\2017\vs2017_profe ...", "+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", " + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException", " + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand"], "stdout": "", "stdout_lines": []}

The file path is definitely valid, and the exact same script works just fine as a standalone powershell file run locally on the machine. What am I doing wrong?

1
if you take the command you are trying to run in Ansible and just run from the (powershell or command) Prompt first does it work?thom schumacher
Is the Z: drive mapped/available for the account Ansible is running as?boxdog
Yes and yes (respectively).iLikeDirt

1 Answers

0
votes

Maybe this helps:

- name: Install Visual Studio
  win_shell: Start-Process -FilePath " Z:\\visualstudio\\2017\\vs2017_professional\\vs2017_Professional.exe" -ArgumentList '--quiet --norestart' -Wait
  args:
    creates: 'C:\Program Files (x86)\MSBuild\14.1\Bin\MSBuild.exe'
  become_user: Administrator