On Jun 23, 2011, at 6:17 PM, Nigel Kersten wrote:

> On Thu, Jun 23, 2011 at 4:07 PM, Craig White <craig.wh...@ttiltd.com> 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.
----
puppet 2.6.8

Your first example would necessitate creating installation class for those 
pre-requisite packages which I was hoping to just slide by without doing. In 
fact, my way that I did it sort of worked with a little tweaking but it seemed 
to try to install nginx before the pre-requisite packages so the first tine 
through, it would time out on the command but load the pre-requisite packages 
afterwards and then the second time through, it would install via the command 
which was messy.

this is where I am at at the moment...

class nginx::install {
  case $operatingsystem {
    centos, redhat: {
    }
    debian, ubuntu: {
      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     => Class["gems::passenger", "nginx::prerequisites"]
      }
    }
  }
}

and still the 'require' doesn't seem to be executed prior to evaluating the 
'command' to exec  -  which still gives me issues.

Craig

-- 
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