win_service play fails when run without an optional parameter

60 views
Skip to first unread message

Dimitri Yioulos

unread,
Aug 31, 2016, 9:12:17 AM8/31/16
to Ansible Project
All,

I'm running version 2.1.1, and have a very simple play to restart a service on my Win2k8 and Win2k12 servers:

---

- hosts: all
  gather_facts: false

  tasks:
    - name: restart ListManagerWeb
      win_service:
        name: ListManagerWeb
        state: restarted
        start_mode: auto

The start_mode parameter is optional and, until a few days ago, the play would run without it.  However, if I run the play without it, I get the following:


<talk> ESTABLISH WINRM CONNECTION FOR USER: ansible on PORT 5986 TO talk
<talk> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1472648842.63-190726517193215").FullName | Write-Host -Separator '';
<talk> PUT "/tmp/tmp7PEdUH" TO "C:\Users\ansible\AppData\Local\Temp\ansible-tmp-1472648842.63-190726517193215\win_service.ps1"
<talk> EXEC Set-StrictMode -Version Latest
Try
{
& 'C:\Users\ansible\AppData\Local\Temp\ansible-tmp-1472648842.63-190726517193215\win_service.ps1'
}
Catch
{
$_obj = @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj.Add('msg', $_.Exception.Message)
}
Else
{
$_obj.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
An exception occurred during task execution. The full traceback is:
At C:\Users\ansible\AppData\Local\Temp\ansible-tmp-1472648842.63-190726517193215\win_service.ps1:265 char:5
+ If ($params.start_mode) {
+     ~~~~~~~~~~~~~~~~~~
fatal: [talk]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "win_service"}, "msg": "The property 'start_mode' cannot be found on this object. Verify that the property exists."}


Why, all of a sudden, am I seeing this behavior, and how do I fix it?

With thanks.


J Hawkesworth

unread,
Sep 1, 2016, 3:20:09 AM9/1/16
to Ansible Project
Hi,

I wonder if you are somehow picking up an old version of the modules, as I just checked (latest devel 2.2 version and

If ($params.start_mode) {

is no longer in the code.

If you are running from source ensure you have done a git submodule update --init and a source hacking/env-setup otherwise you may pick up older versions of the modules installed elsewhere on your system.

If it isn't something to do with picking up an old version of win_service.ps1 reply back and I'll have another think what could be causing this.

Hope this helps,

Jon

Dimitri Yioulos

unread,
Sep 19, 2016, 2:16:03 PM9/19/16
to Ansible Project
Hi, Jon.

Sorry for the long delay in responding.

It may well be that an old version of the module is being picked up.  There are two, one in core (dated July, 2016), the other one in extras (dated March, 2015).  I guess this module made it into core.  If I delete the version in extras, will that solve the problem.  This is an RPM install.

Dimitri

J Hawkesworth

unread,
Sep 22, 2016, 3:02:43 AM9/22/16
to Ansible Project
I would definitely clean up your installation and try again - you definitely only need one version of the module.  I wonder perhaps if you have a source installation or a pip installation as well as an RPM install?
Reply all
Reply to author
Forward
0 new messages