使用 Ansible 在 Windows 上执行 .exe [英] Execute .exe on Windows with Ansible

查看:49
本文介绍了使用 Ansible 在 Windows 上执行 .exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想在装有 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

这篇关于使用 Ansible 在 Windows 上执行 .exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆