Weatherburn, G \(Guy\)
2007-Dec-03 16:21 UTC
exec when missing a file but service installed.
Hi all, I am new to this list and puppet. I am working at the Rutherford Appleton Lab and am part of a team that looks after several hundred servers mainly running Scientific Linux (based on RedHat). I am currently looking at puppet to be used to perform what is currently done by kickstart scripts, with these performing an on going configuration job once the systems are built. My current problem is one where I have a need that arises on a couple of occasions where a service/program is installed, or should be installed and a file created by that service needs to be created, but is done by the service/program itself. One of these is the slocate databases so I require a manifest that does the following: Check that slocate is installed Check if the slocate db exists (/var/lib/slocate/slocatedb) And if not run ''updatedb'' Else Do nothing. I did come up with the following but it does not work. File { "/var/lib/slocate/slocate.db": requires => Package["slocate"], notify => Exec[/usr/bin/updatedb"] } Can anyone point me in the right direction. Guy _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 03 December 2007, Weatherburn, G (Guy) wrote:> Hi all, > > I am new to this list and puppet. I am working at the Rutherford > Appleton Lab and am part of a team that looks after several hundred > servers mainly running Scientific Linux (based on RedHat). I am > currently looking at puppet to be used to perform what is currently done > by kickstart scripts, with these performing an on going configuration > job once the systems are built. > > My current problem is one where I have a need that arises on a couple > of occasions where a service/program is installed, or should be > installed and a file created by that service needs to be created, but is > done by the service/program itself. One of these is the slocate > databases so I require a manifest that does the following: > > Check that slocate is installed > Check if the slocate db exists (/var/lib/slocate/slocatedb) > And if not run ''updatedb'' > Else > Do nothing. > > > I did come up with the following but it does not work. > > File { "/var/lib/slocate/slocate.db": > requires => Package["slocate"], > notify => Exec[/usr/bin/updatedb"] > } > > Can anyone point me in the right direction.Use the "unless" parameter of the Exec type. Regards, DavidS - -- The primary freedom of open source is not the freedom from cost, but the free- dom to shape software to do what you want. This freedom is /never/ exercised without cost, but is available /at all/ only by accepting the very different costs associated with open source, costs not in money, but in time and effort. - -- http://www.schierer.org/~luke/log/20070710-1129/on-forks-and-forking -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFHVDRU/Pp1N6Uzh0URAuXLAJ4j6+pKPRyYXHsrpsdGQVvvCLPDvACdHma4 VVIutzjZXKDp+1Hxtz9Bn9A=QYvv -----END PGP SIGNATURE-----
On 12/3/2007 10:52 AM, David Schmitt wrote:> On Monday 03 December 2007, Weatherburn, G (Guy) wrote: >> My current problem is one where I have a need that arises on a couple >> of occasions where a service/program is installed, or should be >> installed and a file created by that service needs to be created, but is >> done by the service/program itself. One of these is the slocate >> databases so I require a manifest that does the following: >> >> Check that slocate is installed >> Check if the slocate db exists (/var/lib/slocate/slocatedb) >> And if not run ''updatedb'' >> Else >> Do nothing. >> >> >> I did come up with the following but it does not work. >> >> File { "/var/lib/slocate/slocate.db": >> requires => Package["slocate"], >> notify => Exec[/usr/bin/updatedb"] >> } >> >> Can anyone point me in the right direction. > > Use the "unless" parameter of the Exec type.Use ''unless'' if you want to decide based off the return value of a program, or ''creates'' if you want to decide based simply off the existence of a particular file. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University
Weatherburn, G \(Guy\)
2007-Dec-04 09:41 UTC
Re: exec when missing a file but service installed.
Thanks for that eventually got it going with the following: exec { "update-locate-db" : command => "/usr/bin/updatedb", unless => "/usr/bin/test -e ''/var/lib/slocate/slocate.db''" } Works for me. Thanks for all the great work on puppet folks. Guy -----Original Message----- From: puppet-users-bounces@madstop.com [mailto:puppet-users-bounces@madstop.com] On Behalf Of Mike Renfro Sent: 03 December 2007 17:10 To: Puppet User Discussion Subject: Re: [Puppet-users] exec when missing a file but service installed. On 12/3/2007 10:52 AM, David Schmitt wrote:> On Monday 03 December 2007, Weatherburn, G (Guy) wrote: >> My current problem is one where I have a need that arises on acouple>> of occasions where a service/program is installed, or should be >> installed and a file created by that service needs to be created, butis>> done by the service/program itself. One of these is the slocate >> databases so I require a manifest that does the following: >> >> Check that slocate is installed >> Check if the slocate db exists (/var/lib/slocate/slocatedb) >> And if not run ''updatedb'' >> Else >> Do nothing. >> >> >> I did come up with the following but it does not work. >> >> File { "/var/lib/slocate/slocate.db": >> requires => Package["slocate"], >> notify => Exec[/usr/bin/updatedb"] >> } >> >> Can anyone point me in the right direction. > > Use the "unless" parameter of the Exec type.Use ''unless'' if you want to decide based off the return value of a program, or ''creates'' if you want to decide based simply off the existence of a particular file. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users