sc is a powershell alias for 'set-content' 

If you change your raw command to 

   raw: sc.exe .... 

it will probably work.

Better still install nssm (which is a service manager) and use win_nssm 
module.

There is also a win_service_configure module if you prefer for creating 
modules but it hasn't been merged into ansible yet.  Its here - 
https://github.com/ansible/ansible-modules-extras/pull/1115
 perhaps you could test it?

Hope this helps,

Jon

On Friday, April 8, 2016 at 3:05:15 PM UTC+1, Sharwari Phadnis wrote:
>
> I am trying to create a service of type kernel on a remote windows 10 
> machine from a linux ansible controller machine. To create a service I'm 
> using *sc create* *type=kernel binpath=c:\path * command. 
>
> Ansible playbook for creating a service:
> - hosts: windows
>   tasks:
>      - name: Create temp service
>        raw: sc create temp type=kernel binpath=c:\path\
>
>
> And I'm getting the following error:
>
> TASK [Create temp service on windows] 
> ****************************************
> fatal: [10.x.x.x]: 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\ 
> <http://schemas.microsoft.com/powershell/2004/04/>"><Obj S=\"progress\" 
> RefId=\"0\"><TN 
> RefId=\"0\"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64
>  
> N=\"SourceId\">1</I64><PR N=\"Record\"><AV>Preparing modules for first 
> use.</AV><AI>0</AI><Nil 
> /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> 
> </SD></PR></MS></Obj><S S=\"Error\">Set-Content : A positional parameter 
> cannot be found that accepts argument 'type=kernel'._x000D__x000A_</S><S 
> S=\"Error\">At line:1 char:1_x000D__x000A_</S><S S=\"Error\">+ sc create 
> temp type=kernel binpath=c:\\windows\\ ..._x000D__x000A_</S><S 
> S=\"Error\">+ 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S
>  
> S=\"Error\">    + CategoryInfo          : InvalidArgument: (:) 
> [Set-Content], ParameterBindingException_x000D__x000A_</S><S 
> S=\"Error\">    + FullyQualifiedErrorId : 
> PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand_x000D__x000A_</S><S
>  
> S=\"Error\"> _x000D__x000A_</S></Objs>", "stdout": "", "stdout_lines": []}
>
>
>
> What could be the exact reason? Or is there any other of creating a 
> service on a windows machine?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ba0fccee-4dab-46cc-8238-9a2597a6319b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to