我正在尝试使用Windows Ansible安装Visual Studio 2017,但遇到一个奇怪的问题。安装程序位于Z:\visualstudio\2017\vs2017_professional\vs2017_Professional.exe
,这是我运行它的任务:
- 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
但是,它总是失败:
致命:[主机名]:失败! => {“已更改”: true,“ cmd”:“启动过程-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“:”非-零返回码”, “ rc”:1,“ start”:“ 2018-10-17 09:00:29.104384”,“ stderr”: “启动过程:由于错误而无法运行此命令: 系统找不到指定的驱动器。\ r \ n在第1行:char:65 \ r \ n + ... ing $ false;启动过程-FilePath Z:\ visualstudio \ 2017 \ vs2017_profe ... \ r \ n +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~ \ r \ n + CategoryInfo:InvalidOperation:(:) [开始过程], InvalidOperationException \ r \ n + FullyQualifiedErrorId: InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand”, “ stderr_lines”:[“启动过程:由于以下原因,无法运行此命令 错误:系统找不到指定的驱动器。“,”在第1行: char:65“,” + ... ing $ false;启动过程-FilePath Z:\ visualstudio \ 2017 \ vs2017_profe ...“,” +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~“,” + CategoryInfo:InvalidOperation:(:) [开始过程], InvalidOperationException“,” + FullyQualifiedErrorId: InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand“], “ stdout”:“”,“ stdout_lines”:[]}
文件路径绝对有效,并且完全相同的脚本可以很好地用作在计算机上本地运行的独立powershell文件。我在做什么错了?
答案 0 :(得分:0)
也许这会有所帮助:
- 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