How to check if a service Or a Package exists

282 views
Skip to first unread message

kaustubh chaudhari

unread,
Mar 5, 2014, 10:40:48 AM3/5/14
to puppet...@googlegroups.com
Hi All,

I need to check if a service or a package is already installed before running the further code.

Eg:

Install bigfix package if bigfix service dose not exist.

i know ensure => true will do this, but there is a possibility that bigfix was installed from the source in c:\bigfix on few server and on few its installed as a msi and i can see it under add remove programs.

So the best way is to check if the bigfix service exists or not, if exist ignore if not install via puppet.

Any pointers ?

-Kaustubh

jcbollinger

unread,
Mar 5, 2014, 1:20:25 PM3/5/14
to puppet...@googlegroups.com


The way to inform the Puppet master about the state of the target system before catalog compilation is via facts.  You can create a custom fact that uses whatever logic is appropriate to determine whether the software in question is installed, and then use conditionals based on that fact in your manifests to control whether you declare the Package or not.

But you shouldn't.  Bite the bullet: bring your servers under control so that this sort of thing is no longer a concern.  It is really bad to install software from source on your production machines.  Everything ought to be managed via packages.

If needs be you could adopt a hybrid approach: write a custom fact that identifies when a piece of software of interest is installed from source, and when that's so, tell Puppet to remove it before (re)installing it from a package (e.g. an MSI).  The package then does not need to be conditional, which is to your advantage if you ever want to use Puppet to update it or remove it.


John

kaustubh chaudhari

unread,
Mar 11, 2014, 8:38:01 AM3/11/14
to puppet...@googlegroups.com
Hi John,

I totally agree with you and i am trying to do the same cleaning previous crap!

Thanks a ton for your advice. I created a custom fact and did simple if .. else which did the job!

Have a great day ahead!


With Warm Regards
Kaustubh.A.Chaudhari
(M)-09373102619


--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/MsyNFxZ4atE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/88fd0a27-1ffa-4e7a-8a9f-9961b70cbba2%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages