From c5a275505bf2aafb9378d923985f9915e81ce7a7 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 9 Aug 2012 16:03:01 -0400 Subject: fix puppetmaster service definition for passenger Because passenger mode doesn't have its own daemon, it was a hack before to have the service definition for 'puppetmaster' be actually looking in the process list for 'apache2'. This sort of worked, but not if you need to notify the service for a restart. It also didn't actually work, because the hasstatus parameter was set to true, which meant that on every run, puppet did a /etc/init.d/puppetmaster status and found that it was not running and then tried to start it by doing /etc/init.d/puppetmaster start. That doesn't work because its turned off in /etc/default/puppetmaster when puppetmaster_mode='passenger'. So... this commit removes that hacky service definition and instead just requires the apache::base class, providing the apache service monitoring that is needed when you are running puppetmaster_mode='passenger'. It also has to pull up the Service[puppet] override which was adding the puppetmaster service, which makes no sense because there is no service. Finally, in order to notify it for changes, we need to use a selector to determine how to reload things based on puppetmaster_mode. Conflicts: manifests/puppetmaster/linux.pp --- manifests/puppetmaster/debian.pp | 5 ++++- manifests/puppetmaster/linux.pp | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/manifests/puppetmaster/debian.pp b/manifests/puppetmaster/debian.pp index 8cee0ea..853a0e6 100644 --- a/manifests/puppetmaster/debian.pp +++ b/manifests/puppetmaster/debian.pp @@ -13,7 +13,10 @@ class puppet::puppetmaster::debian inherits puppet::puppetmaster::package { "puppet:///modules/site-puppet/master/debian/${domain}/puppetmaster", "puppet:///modules/site-puppet/master/debian/puppetmaster", "puppet:///modules/puppet/master/debian/puppetmaster" ], - notify => Service[puppetmaster], + notify => $puppetmaster_mode ? { + 'passenger' => Exec['notify_passenger_puppetmaster'], + default => Service[puppetmaster], + }, owner => root, group => 0, mode => 0644; } } diff --git a/manifests/puppetmaster/linux.pp b/manifests/puppetmaster/linux.pp index 2670203..5cde0c3 100644 --- a/manifests/puppetmaster/linux.pp +++ b/manifests/puppetmaster/linux.pp @@ -1,6 +1,9 @@ class puppet::puppetmaster::linux inherits puppet::linux { if $puppetmaster_mode == 'passenger' { + + require('apache::base') + exec { 'notify_passenger_puppetmaster': refreshonly => true, command => 'touch /etc/puppet/rack/tmp/restart.txt && sleep 1 && rm /etc/puppet/rack/tmp/restart.txt', @@ -11,8 +14,8 @@ class puppet::puppetmaster::linux inherits puppet::linux { enable => true, require => [ Package[puppet] ], } - } - Service[puppet]{ - require +> Service[puppetmaster], + Service[puppet]{ + require +> Service[puppetmaster], + } } } -- cgit v1.2.3 From 1d3e2b5bd6788894c49d8db6ab65f67b0540b87d Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Fri, 10 Aug 2012 12:32:29 -0400 Subject: Fix puppet attempting to change the puppet service from 'stopped' to running on each run: notice: /Stage[main]/Puppet::Base/Service[puppet]/ensure: ensure changed 'stopped' to 'running' When running in cron mode, you do not want the puppet service enabled, nor do you want it 'running'. When enabling the cron mode, the first part of puppet::cron::base does a Service override on the puppet service to set enable => false. That is a good thing, but all it does is make the service setup so it wont be run on boot. Unfortunately, the puppet service definition also has a 'ensure => running' which does an /etc/init.d/puppet status and then starts the service if it is not running. In a cron-only setup, the 'status' command results in a failure, because the daemon is not running, and then puppet attempts to start it, which goes nowhere because the /etc/default/puppet is configured not to start. So, looking further at puppet::cron::base we see there is a case switch, testing on operatingsystem and if its debian/ubuntu (or openbsd) it falls out of the case. If it is not one of those, it continues and does a test to see if the version of puppet is 2.6 and if so then it does an additional puppet Service override to set ensure=> stopped which keeps the service from being checked to see if it is running, and if it is not starting it. So to fix this, we remove debian/ubuntu from the case, so it will continue through and then we change the $puppet_majorversion test to look for anything greater than or equal to '2.6', since 2.7 and later are also versions we want this to work with. After this change, we no longer get the attempt to restart puppet on every run. --- manifests/cron/base.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/cron/base.pp b/manifests/cron/base.pp index 7daa6fb..5c7a708 100644 --- a/manifests/cron/base.pp +++ b/manifests/cron/base.pp @@ -6,12 +6,12 @@ class puppet::cron::base inherits puppet::base { } case $operatingsystem { - debian,openbsd,ubuntu: { + openbsd: { #it's already disabled } default: { $puppet_majorversion = regsubst($puppetversion,'^(\d+\.\d+).*$','\1') - if $puppet_majorversion == '2.6' { + if $puppet_majorversion >= '2.6' { Service['puppet']{ ensure => stopped, } -- cgit v1.2.3 From 346e0e0c5819107474b47025ac7fadaa751f63a5 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 22 Aug 2012 14:12:34 -0400 Subject: switch to $::operatingsystem as suggested by ng in https://labs.riseup.net/code/issues/4029 --- manifests/puppetmaster/passenger.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/puppetmaster/passenger.pp b/manifests/puppetmaster/passenger.pp index 9f4d1e8..e026a62 100644 --- a/manifests/puppetmaster/passenger.pp +++ b/manifests/puppetmaster/passenger.pp @@ -7,7 +7,7 @@ class puppet::puppetmaster::passenger inherits puppet::puppetmaster::base { # A reference configuration is available at : # http://github.com/reductivelabs/puppet/tree/master/ext/rack - case $operatingsystem { + case $::operatingsystem { debian: { package { 'puppetmaster-passenger': ensure => installed } file { -- cgit v1.2.3 From 0097eeef0b24a85d6f067bbf5b126d3fa22f1c15 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 22 Aug 2012 14:40:59 -0400 Subject: implement fixes from #3514 --- manifests/debian.pp | 18 ++++++++---------- manifests/puppetmaster/debian.pp | 27 ++++++++++++++++----------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/manifests/debian.pp b/manifests/debian.pp index f0479ae..e24a1bc 100644 --- a/manifests/debian.pp +++ b/manifests/debian.pp @@ -1,21 +1,19 @@ class puppet::debian inherits puppet::linux { file { '/etc/default/puppet': - source => [ "puppet:///modules/site-puppet/client/debian/${fqdn}/puppet", - "puppet:///modules/site-puppet/client/debian/${domain}/puppet", - "puppet:///modules/site-puppet/client/debian/puppet", + source => [ "puppet:///modules/site_puppet/client/debian/${fqdn}/puppet", + "puppet:///modules/site_puppet/client/debian/${domain}/puppet", + "puppet:///modules/site_puppet/client/debian/puppet", "puppet:///modules/puppet/client/debian/puppet" ], notify => Service[puppet], owner => root, group => 0, mode => 0644; } - case $lsbdistcodename { - squeeze,sid: { - $real_puppet_hasstatus = true - } - default: { - $real_puppet_hasstatus = false - } + if versioncmp($puppetversion,'2.6') >= 0 { + $real_puppet_hasstatus = true + } + else { + $real_puppet_hasstatus = false } Service[puppet]{ diff --git a/manifests/puppetmaster/debian.pp b/manifests/puppetmaster/debian.pp index 853a0e6..fc24221 100644 --- a/manifests/puppetmaster/debian.pp +++ b/manifests/puppetmaster/debian.pp @@ -1,21 +1,26 @@ -class puppet::puppetmaster::debian inherits puppet::puppetmaster::package { +class puppet::puppetmaster::debian { + include puppet::puppetmaster::package + include puppet::puppetmaster::linux + if $puppetmaster_mode != 'passenger' { - case $lsbdistcodename { - squeeze,sid: { - Service['puppetmaster'] { hasstatus => true, hasrestart => true } - } + if $puppet_majorversion >= '2.6' { + Service['puppetmaster'] { hasstatus => true, hasrestart => true } } } + if $puppetmaster_mode == 'passenger' { + $puppetmaster_default_nofity = 'Exec[notify_passenger_puppetmaster]' + } + file { '/etc/default/puppetmaster': - source => [ "puppet:///modules/site-puppet/master/debian/${fqdn}/puppetmaster", - "puppet:///modules/site-puppet/master/debian/${domain}/puppetmaster", - "puppet:///modules/site-puppet/master/debian/puppetmaster", + source => [ "puppet:///modules/site_puppet/master/debian/${fqdn}/puppetmaster", + "puppet:///modules/site_puppet/master/debian/${domain}/puppetmaster", + "puppet:///modules/site_puppet/master/debian/puppetmaster", "puppet:///modules/puppet/master/debian/puppetmaster" ], - notify => $puppetmaster_mode ? { - 'passenger' => Exec['notify_passenger_puppetmaster'], - default => Service[puppetmaster], + notify => $puppetmaster_default_nofity ? { + '' => Service[puppetmaster], + default => Exec['notify_passenger_puppetmaster'] }, owner => root, group => 0, mode => 0644; } -- cgit v1.2.3