In regard to: [Puppet Users] Have Class Only Perform Actions When There Is...:

Howdy. I feel like I am missing something really simply with regards to the
way that Puppet works and I am wondering if someone can point me in the
write direction.

I have written a class that downloads, uncompresses, compiles, and installs
Python from source. So far so good.

I would highly recommend you just package your custom python and install
it using a package management system, rather than doing what you're doing.
Depending on what host OS you're using, it's not too difficult, and it
works a lot better with puppet *and* you get all the benefits of having
the package installed through a more coherent means.

The problem is that it only needs to do
this once, when Python is not already in place (or some other custom
indicator of the Python version). I have my 3 calls to exec doing their
checks just fine, but my calls to wget::fetch and archive::untar both fire
during every apply. Specifically, archive::untar takes about 30 seconds to
run and I'd prefer it if it only ran conditionally.

What is the best way to make sure that this code:

 wget::fetch { "python-${version}":
   source =>
"http://python.org/ftp/python/${version}/Python-${version}.tgz";,
   destination => "/tmp/Python-${version}.tgz",
 }

 archive::untar {"/tmp/python-${version}":
   source => "/tmp/Python-${version}.tgz",
   compression => 'gz',
   rootdir => "Python-${version}",
   require => Wget::Fetch["python-${version}"],
 }

As you're discovering, these kind of exec chains, where the first part
of the chain involves temporary files, don't really fit into the puppet
paradigm very well.  About the best you can do is something like

        exec { '/usr/local/sbin/install-python-if-necessary.sh':
                source  => 'http://your_module/install-python-if-necessary.sh',
                creates => '/your/python/lib/dir',
        }

and then bury all the fetch/extract/configure/compile/install logic
in the shell script, which puppet will make certain is always present
on the system.  It will only execute it if /your/python/lib/dir is not
present.

But if you're going to build fetch/extract/configure/compile/install logic
into a shell script, you're probably 85% of the way to packaging the
software appropriately anyway.

Tim
--
Tim Mooney                                             tim.moo...@ndsu.edu
Enterprise Computing & Infrastructure                  701-231-1076 (Voice)
Room 242-J6, IACC Building                             701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to