【问题标题】:Run a windows .exe file using Ansible使用 Ansible 运行 windows .exe 文件
【发布时间】:2015-12-25 09:25:55
【问题描述】:

我想在命令提示符下运行远程 Windows Server 2012 机器上的 wrapper.exe,如下所示:

wrapper.exe -t wrapper.conf

我使用 ansible 创建了一个剧本,至少可以尝试运行不带任何参数的 exe。我的剧本如下所示:

---
- hosts: windows
  tasks:
    - name: Register as a service
      raw: 'D:\builds\router\bin\wrapper.exe'

但是,我收到以下错误:

fatal: [windows_ip]: FAILED! => {
  "changed": false,
  "failed": true,
  "rc": 1,
  "stderr": "#< CLIXML\r\n<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S S=\"Error\">D:_x0008_uilds : The term 'D:_x0008_uilds' is not recognized as the name of a cmdlet, _x000D__x000A_</S><S S=\"Error\">function, script file, or operable program. Check the spelling of the name, or _x000D__x000A_</S><S S=\"Error\">if a path was included, verify that the path is correct and try again._x000D__x000A_</S><S S=\"Error\">At line:1 char:1_x000D__x000A_</S><S S=\"Error\">+ D:_x0008_uilds_x000D__x000A_</S><S S=\"Error\">+ ~~~~~~~~_x000D__x000A_</S><S S=\"Error\">    + CategoryInfo          : ObjectNotFound: (D:_x0008_uilds:String) [], CommandNot _x000D__x000A_</S><S S=\"Error\">   FoundException_x000D__x000A_</S><S S=\"Error\">    + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</S><S S=\"Error\">outer_x0008_in\\wrapper.exe : The module 'outer_x0008_in' could not be loaded. For more _x000D__x000A_</S><S S=\"Error\">information, run 'Import-Module outer_x0008_in'._x000D__x000A_</S><S S=\"Error\">At line:2 char:1_x000D__x000A_</S><S S=\"Error\">+ outer_x0008_in\\wrapper.exe_x000D__x000A_</S><S S=\"Error\">+ ~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S S=\"Error\">    + CategoryInfo          : ObjectNotFound: (outer_x0008_in\\wrapper.exe:String) [] _x000D__x000A_</S><S S=\"Error\">   , CommandNotFoundException_x000D__x000A_</S><S S=\"Error\">    + FullyQualifiedErrorId : CouldNotAutoLoadModule_x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</S></Objs>",
  "stdout": "",
  "stdout_lines": []
}

这里有什么问题?

【问题讨论】:

    标签: windows ansible


    【解决方案1】:

    这是YAML 相关的,您需要输入'\\' 以获得\。所以在你的情况下,这样说它应该可以工作:

    ---
    - hosts: windows
        tasks:
          - name: Register as a service
            raw: 'D:\\builds\\router\\bin\\wrapper.exe'
    

    【讨论】:

      【解决方案2】:

      或者你可以只使用正斜杠(Powershell 理解它们) "D:/builds/router/bin/wrapper.exe"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-04
        • 1970-01-01
        • 1970-01-01
        • 2019-12-25
        • 1970-01-01
        相关资源
        最近更新 更多