Craig White
2011-Jun-23 23:07 UTC
[Puppet Users] Package pre-requisites prior to file exec
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). I think I am close but the best way to handle this is eluding me (and my google searches). -- Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white@ttiltd.com 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com Need help communicating between generations at work to achieve your desired success? Let us help! -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2011-Jun-24 01:17 UTC
Re: [Puppet Users] Package pre-requisites prior to file exec
On Thu, Jun 23, 2011 at 4:07 PM, Craig White <craig.white@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. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Craig White
2011-Jun-24 16:26 UTC
Re: [Puppet Users] Package pre-requisites prior to file exec
On Jun 23, 2011, at 6:17 PM, Nigel Kersten wrote:> On Thu, Jun 23, 2011 at 4:07 PM, Craig White <craig.white@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Craig White
2011-Jun-24 17:38 UTC
Re: [Puppet Users] Package pre-requisites prior to file exec
Nevermind... under control - thanks for the fish Craig On Jun 24, 2011, at 9:26 AM, Craig White wrote:> > On Jun 23, 2011, at 6:17 PM, Nigel Kersten wrote: > >> On Thu, Jun 23, 2011 at 4:07 PM, Craig White <craig.white@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2011-Jun-24 17:42 UTC
Re: [Puppet Users] Package pre-requisites prior to file exec
On Fri, Jun 24, 2011 at 10:38 AM, Craig White <craig.white@ttiltd.com> wrote:> Nevermind... under control - thanks for the fishHeh. Great timing, I was just typing up a reply. Craig, I''d appreciate it if we could try and work out what led you down the wrong path in terms of syntax so we can try to make sure it doesn''t happen for other people learning Puppet in the future. I''d be more than happy to have an off-list chat if needed. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Craig White
2011-Jun-24 18:33 UTC
Re: [Puppet Users] Package pre-requisites prior to file exec
On Jun 24, 2011, at 10:42 AM, Nigel Kersten wrote:> On Fri, Jun 24, 2011 at 10:38 AM, Craig White <craig.white@ttiltd.com> wrote: >> Nevermind... under control - thanks for the fish > > Heh. Great timing, I was just typing up a reply. > > Craig, I''d appreciate it if we could try and work out what led you > down the wrong path in terms of syntax so we can try to make sure it > doesn''t happen for other people learning Puppet in the future. I''d be > more than happy to have an off-list chat if needed.---- I don''t think anything is wrong with the documentation - I probably bit off a very complicated use case before I had my understanding up to speed. This has taught me much though. I am trying to make apache co-exist with nginx which is difficult enough (managing ports, virtual host conf) but we are also using gems for things like nginx which add to the complexity. I suspect that some may be interested in what I finally work out (and I''m maybe another 4-6 hours away from completing this). What I didn''t realize was that in my process of flailing for answers, I failed to preserve an intermediate configuration that semi-worked and so I reverted to the file that I posted to the list yesterday which failed to account for ruby being in /usr/local (ruby-enterprise) and so I was getting failures because it couldn''t find the command. This was clearly my issue and it had me going for a while. Anyway, I''ve only been at this since Monday and I am quite pleased. I have managed to add some custom ''facts'', get some pretty complicated chaining of package installations, work through some reasonably sophisticated templates so that things like apache & nginx config files, sysv initscripts, virtual hosts are all delivered with a high enough level of flexibility for mods, rewrite rules, etc. for each vhost. Thanks again 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2011-Jun-24 20:03 UTC
Re: [Puppet Users] Package pre-requisites prior to file exec
On Fri, Jun 24, 2011 at 11:33 AM, Craig White <craig.white@ttiltd.com> wrote:> Anyway, I''ve only been at this since Monday and I am quite pleased. I have managed to add some custom ''facts'', get some pretty complicated chaining of package installations, work through some reasonably sophisticated templates so that things like apache & nginx config files, sysv initscripts, virtual hosts are all delivered with a high enough level of flexibility for mods, rewrite rules, etc. for each vhost.That''s really quite awesome progress for a couple of days work Craig. Well done! Glad to hear the docs weren''t a big problem, but it does feel like there''s something here that could maybe have been called out in a more obvious manner in the docs. -- Nigel Kersten Product, Puppet Labs @nigelkersten -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.