On Thu, Jun 23, 2011 at 4:07 PM, Craig White <[email protected]> wrote:
> class nginx::install {
> $prerequisites = [ "build-essential", "libcurl4-openssl-dev", "libssl-dev",
> "zlib1g-dev" ]
> case $operatingsystem {
> centos, redhat: {
> }
> debian, ubuntu: {
> package { $prerequisites : ensure => "installed" :
> ensure => present {
> exec { "Installing nginx via passenger":
> path => "/bin:/usr/bin",
> environment => "HOME=/root",
> command => "passenger-install-nginx-module --auto-download
> --auto",
> user => "root",
> group => "root",
> unless => "ls -l /opt | grep nginx",
> logoutput => on_failure,
> }
> }
> file {"/etc/init.d/nginx":
> source => "puppet:///modules/nginx/nginx-initd",
> owner => root,
> group => root,
> mode => 755,
> require => Class["nginx::install"],
> notify => Class["nginx::service"],
> }
> }
> }
> }
> }
>
> The above has a syntax error on line 7 and the catalog won't build but
> essentially I want to 'ensure' that the pre-requsite packages are installed
> prior to attempting to execute the command (because if the pre-requisites
> aren't there, the command will fail).
That definitely won't compile :)
You should be able to just declare the exec and package(s) resources
separately and define a relationship, like:
exec { "Installing nginx via passenger":
path => "/bin:/usr/bin",
environment => "HOME=/root",
command => "passenger-install-nginx-module --auto-download --auto",
user => "root",
group => "root",
unless => "ls -l /opt | grep nginx",
logoutput => on_failure,
require => Package[$prerequisites],
}
That last line should work for you. Otherwise you could define it the
opposite way around:
package { $prerequisites:
ensure => installed,
before => Exec["Installing nginx via passenger"],
}
Both those methods should work, but I have a vague memory of the first
method failing in a point release or two.
What version of Puppet are you running? You may have a much clearer
way of expressing the conditional you're using than the somewhat messy
case statement you're using at the moment.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.