[Puppet Users] Disable A Windows Service Only If It Exists

Paul Nickerson
Thu, 11 Apr 2013 15:45:52 -0000

I am wondering whether it is possible to have Puppet only stop and disable
a Windows service if it exists. I have Puppet master 3.1.1 on CentOS, and
Puppet clients 3.1.1 on many Windows machines. Right now, I have the bit
below for certain nodes:

service { "CVSNT":
ensure => ''stopped'',
enable => ''false'',
}

Some of the nodes have this service, some do not. Occasionally, new nodes
are added that this applies to (through inherits statements), and these new
nodes may or may not have this service. It''s not just this service,
either;
I have an array of services I need to ensure won''t run. I just
simplified
the above example with one service.

If the Windows node does not have the service, then the Puppet agent still
runs successfully. But, when I run puppet agent --test in the Command
Prompt with Puppet on the node, I get this error:

Error: /Stage[main]//Node[winbase]/Service[CVSNT]: Could not evaluate:
Cannot get status of CVSNT, error was: The specified service does not exist
as an installed service.

The agent continues to run and completes successfully. But, getting several
of these lines at different points each time I run the Puppet agent makes
testing and debugging whatever other module I''m working on a little
difficult. I would like to get rid of the clutter.

I''ve been researching this topic for a while, and haven''t come
up with any
solutions. Is there any way to have Puppet disable a Windows service only
if it exists? Or, is there a way to suppress these warning lines
without suppressing other output?

--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.