简体   繁体   中英

Run a windows .exe file using Ansible

I want to run a wrapper.exe present on a remote windows server 2012 machine on the command prompt as follows :

wrapper.exe -t wrapper.conf

Using ansible i created a playbook to atleast try running the exe without any arguments. My playbook looks as follows:

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

However, I get the following error:

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": []
}

What is the issue here?

This is YAML related, you need to put '\\\\' to get a \\. So in your case put it like this and it should work:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM