Juri Rischel Jensen
2007-Jan-23 20:54 UTC
Setting a variable to true or false, if a certain file exists...
Hi, I need to set a variable to true or false if a certain file exists. I need to use it in a case statement like: case $is_installed { false: { exec... file... service... } true: { package... } } Is it possible...? I searched for the syntax, but I can''t find an appropriate example... -- Med venlig hilsen Juri Rischel Jensen Fab:IT ApS Vesterbrogade 50 DK-1620 København Tlf: 70 202 407 / Fax: 33 313 640 www.fab-it.dk / juri@fab-it.dk
Luke Kanies
2007-Jan-23 21:30 UTC
Re: Setting a variable to true or false, if a certain file exists...
On Jan 23, 2007, at 2:54 PM, Juri Rischel Jensen wrote:> Hi, > > I need to set a variable to true or false if a certain file exists. I > need to use it in a case statement like: > > case $is_installed { > false: { > exec... > file... > service... > } > true: { > package... > } > } > > Is it possible...? I searched for the syntax, but I can''t find an > appropriate example...The only way you could do such a thing right now is to use a fact, which does not scale very well. It should work fine for one or two, but not so much for many more. -- I happen to feel that the degree of a person''s intelligence is directly reflected by the number of conflicting attitudes she can bring to bear on the same topic. -- Lisa Alther --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Matthew Palmer
2007-Jan-23 21:37 UTC
Re: Setting a variable to true or false, if a certain file exists...
On Tue, Jan 23, 2007 at 09:54:47PM +0100, Juri Rischel Jensen wrote:> I need to set a variable to true or false if a certain file exists. IMy rule of thumb on things like this is as follows: If you need to do something like this, you''re probably not thinking about the problem in the "right" (Puppetish) way. If you can give a representative sample problem, I''m pretty certain we can give you some guidance. - Matt
Juri Rischel Jensen
2007-Jan-23 21:41 UTC
Re: Setting a variable to true or false, if a certain file exists...
On Jan 23, 2007, at 22:37, Matthew Palmer wrote:> My rule of thumb on things like this is as follows: If you need to do > something like this, you''re probably not thinking about the problem > in the > "right" (Puppetish) way. If you can give a representative sample > problem, > I''m pretty certain we can give you some guidance.I''d like to install rubygems on my computers, but it''s not part of Debian stable so I have to install it by hand (e.g. download a .tgz file and run ruby setup.rb), but afterwards, I can use rubygems to update itself... -- Med venlig hilsen Juri Rischel Jensen Fab:IT ApS Vesterbrogade 50 DK-1620 København Tlf: 70 202 407 / Fax: 33 313 640 www.fab-it.dk / juri@fab-it.dk
Matthew Palmer
2007-Jan-23 23:55 UTC
Re: Setting a variable to true or false, if a certain file exists...
On Tue, Jan 23, 2007 at 10:41:22PM +0100, Juri Rischel Jensen wrote:> > On Jan 23, 2007, at 22:37, Matthew Palmer wrote: > > > My rule of thumb on things like this is as follows: If you need to do > > something like this, you''re probably not thinking about the problem > > in the > > "right" (Puppetish) way. If you can give a representative sample > > problem, > > I''m pretty certain we can give you some guidance. > > I''d like to install rubygems on my computers, but it''s not part of > Debian stable so I have to install it by hand (e.g. download a .tgz > file and run ruby setup.rb), but afterwards, I can use rubygems to > update itself...Aaah. Interesting problem. For myself, I just use the rubygems Debian package from testing/unstable (works fine on Ubuntu Breezy/Dapper, and I can''t see any reason why it shouldn''t work on Debian Sarge). But then, I run with a private repository all the time, so that is a trivial step for me. If you want to persevere with the tarball method, Puppet isn''t particularly well suited to this task. I''d write a shell script that did the download and install, and run that in an exec object with an appropriate ''creates'' parameter. - Matt -- "I''m tempted to try Gentoo, but then I learned that its installer is in Python, and, well, a base Python install on my system is something like fifty megabytes (for what? oh, right, we NEED four XML libraries, I forgot)." -- Dave Brown, ASR
Luke Kanies
2007-Jan-24 17:54 UTC
Re: Setting a variable to true or false, if a certain file exists...
On Jan 23, 2007, at 3:41 PM, Juri Rischel Jensen wrote:> > On Jan 23, 2007, at 22:37, Matthew Palmer wrote: > >> My rule of thumb on things like this is as follows: If you need to do >> something like this, you''re probably not thinking about the problem >> in the >> "right" (Puppetish) way. If you can give a representative sample >> problem, >> I''m pretty certain we can give you some guidance. > > I''d like to install rubygems on my computers, but it''s not part of > Debian stable so I have to install it by hand (e.g. download a .tgz > file and run ruby setup.rb), but afterwards, I can use rubygems to > update itself...This is similar to the yum problems that someone else is having. I agree with Matt that using a package is far preferred to the tarball, even if you just download the testing/unstable package and install that using ''dpkg''. There still isn''t an easy way to set up all of the gem packages to require this package, so I''ll have to think about that a bit more. -- Most people are born and years later die without really having lived at all. They play it safe and tiptoe through life with no aspiration other than to arrive at death safely. -- Tony Campolo, "Carpe Diem" --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com