在Windows上使用Ansible执行.exe [英] Execute .exe on Windows with Ansible
问题描述
我们想在具有Ansible 1.8.2的Windows Server 2012上部署应用程序.
We want to deploy an application on a Windows Server 2012 with Ansible 1.8.2.
我搜索并找到了适用于Windows的模块列表.是否有执行.exe的模块?
I have searched and found a list of modules for Windows. Is there a module to execute a .exe?
有人已经使用Ansible在Windows上启动.exe吗?
Did someone already launch a .exe on Windows with Ansible?
推荐答案
raw
模块可以正常工作,正如其他人建议的那样.一个挑战是,它不会知道"可执行文件是否已经运行过.与win_stat
模块和when
有条件的组合,您可以构建一个脚本来检测是否已安装某些组件,如果没有安装则运行.例如,我想安装 MSBuild开发工具 :
The raw
module can work, as others have suggested. One challenge is that it won't "know" if the executable has already been run before. In combination with the win_stat
module and the when
conditional, you can build a script that detects if something has been installed and runs if not installed. For example, I wanted to install the MSBuild development tools:
- name: Check to see if MSBuild is installed
win_stat: path='C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe'
register: msbuild_installed
- name: Download MS Build Tools 2013
win_get_url:
url: 'http://download.microsoft.com/download/9/B/B/9BB1309E-1A8F-4A47-72A3B3/BuildTools_Full.exe'
dest: 'c:\temp\BuildTools_Full.exe'
when: not msbuild_installed.stat.exists
- name: Install MS Build Tools 2013
raw: 'c:\temp\BuildTools_Full.exe /Quiet /NoRestart /Full'
when: not msbuild_installed.stat.exists
请注意,我通过手动运行找到了BuildTools_Full.exe的命令行参数
Note that I found the command line arguments for BuildTools_Full.exe by manually running
.\BuildTools_Full.exe /h
这篇关于在Windows上使用Ansible执行.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!