summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2010-08-06 22:10:39 +0200
committermh <mh@immerda.ch>2010-08-06 22:11:58 +0200
commit4036ecf691babf80d859b68865e66cea0008a238 (patch)
tree9fa165d448b560077af447c1acf9132a1bb8957c
parentdcdf341af2b32969c47bef5939e34952a6fc7642 (diff)
cleanup 'if defined' code smell
A new variable $puppetmaster_mode have been introduced, which should later be replaced by a class variable.
-rw-r--r--README15
-rw-r--r--manifests/puppetmaster.pp7
-rw-r--r--manifests/puppetmaster/base.pp39
-rw-r--r--manifests/puppetmaster/linux.pp16
-rw-r--r--manifests/puppetmaster/passenger.pp3
5 files changed, 46 insertions, 34 deletions
diff --git a/README b/README
index f925dfa..e09bbaf 100644
--- a/README
+++ b/README
@@ -14,18 +14,25 @@ Depends on Modules
Usage
-----
+If you want to run the puppetmaster in a non-webrick based
+mode, you can set $puppetmaster_mode either to:
+
+* passenger, run puppetmaster as a passenger application
+* cluster, run puppetmaster as a mongrel based cluster
+
+In both cases you have to setup the appropriate frontends
+(apache vhost configuration/nginx vhost configuration) on
+your own.
+
in your site.pp, i.e. :
$puppet_crontime = "0,12 * * * *"
include puppet::cron
+ $puppetmaster_mode = 'passenger'
include puppet::puppetmaster
- include puppet::puppetmaster::passenger
-
$puppet_storeconfig_password="..."
include puppet::puppetmaster::storeconfigs
-
-
...tbc...
diff --git a/manifests/puppetmaster.pp b/manifests/puppetmaster.pp
index f9f4306..5f3ad16 100644
--- a/manifests/puppetmaster.pp
+++ b/manifests/puppetmaster.pp
@@ -13,6 +13,13 @@ class puppet::puppetmaster inherits puppet {
include puppet::puppetmaster::base
include puppet::puppetmaster::checklastrun
+ if $puppetmaster_mode == 'passenger' {
+ include puppet::puppetmaster::pasenger
+ } elsif $puppetmaster_mode == 'cluster' {
+ include puppet::puppetmaster::cluster
+ }
+
+
if $use_shorewall {
include shorewall::rules::puppet::master
}
diff --git a/manifests/puppetmaster/base.pp b/manifests/puppetmaster/base.pp
index 3d0934f..a5f7e90 100644
--- a/manifests/puppetmaster/base.pp
+++ b/manifests/puppetmaster/base.pp
@@ -1,17 +1,16 @@
class puppet::puppetmaster::base inherits puppet::base {
- File[puppet_config]{
- source => [ "puppet://$server/modules/site-puppet/master/puppet.conf",
- "puppet://$server/modules/puppet/master/puppet.conf" ],
- notify => Service[puppetmaster],
- }
+ File[puppet_config]{
+ source => [ "puppet://$server/modules/site-puppet/master/puppet.conf",
+ "puppet://$server/modules/puppet/master/puppet.conf" ],
+ notify => Service[puppetmaster],
+ }
if !$puppet_fileserverconfig { $puppet_fileserverconfig = '/etc/puppet/fileserver.conf' }
file { "$puppet_fileserverconfig":
- source => [ "puppet://$server/modules/site-puppet/master/${fqdn}/fileserver.conf",
- "puppet://$server/modules/site-puppet/master/fileserver.conf",
- "puppet://$server/modules/puppet/master/fileserver.conf" ],
- notify => Service[puppetmaster],
+ source => [ "puppet://$server/modules/site-puppet/master/${fqdn}/fileserver.conf",
+ "puppet://$server/modules/site-puppet/master/fileserver.conf",
+ "puppet://$server/modules/puppet/master/fileserver.conf" ],
owner => root, group => puppet, mode => 640;
}
@@ -20,13 +19,21 @@ class puppet::puppetmaster::base inherits puppet::base {
}
- if ! defined (puppet::puppetmaster::passenger) {
- # restart the master from time to time to avoid memory problems
- file{'/etc/cron.d/puppetmaster.cron':
- source => [ "puppet://$server/modules/puppet/cron.d/puppetmaster.${operatingsystem}",
- "puppet://$server/modules/puppet/cron.d/puppetmaster" ],
- owner => root, group => 0, mode => 0644;
- }
+ if $puppetmaster_mode == 'passenger' {
+ include puppet::puppetmaster::pasenger
+ File[$puppet_fileserverconfig]{
+ notify => Exec['notify_passenger_puppetmaster'],
+ }
+ File[puppet_config]{
+ notify => Exec['notify_passenger_puppetmaster'],
+ }
+ } else {
+ File[$puppet_fileserverconfig]{
+ notify => Service[puppetmaster],
+ }
+ File[puppet_config]{
+ notify => Service[puppetmaster],
+ }
}
# clean up reports older than 30 days
diff --git a/manifests/puppetmaster/linux.pp b/manifests/puppetmaster/linux.pp
index 062d907..3d36f75 100644
--- a/manifests/puppetmaster/linux.pp
+++ b/manifests/puppetmaster/linux.pp
@@ -1,17 +1,9 @@
class puppet::puppetmaster::linux inherits puppet::linux {
- if defined (puppet::puppetmaster::passenger) {
- service{'puppetmaster':
- ensure => running,
- #name => apache2,
- #enable => true,
- pattern => 'apache2',
- hasstatus => true,
- start => '/etc/init.d/apache2 start',
- stop => '/etc/init.d/apache2 start',
- restart => '/etc/init.d/apache2 restart',
- status => 'pgrep apache2',
- require => [ Package[puppet] ],
+ if $puppetmaster_mode == 'passenger' {
+ exec{'notify_passenger_puppetmaster':
+ refreshonly => true,
+ command => 'touch /etc/puppet/rack/tmp/restart.txt && sleep 1 && rm /etc/puppet/rack/tmp/restart.txt',
}
} else {
service{'puppetmaster':
diff --git a/manifests/puppetmaster/passenger.pp b/manifests/puppetmaster/passenger.pp
index 375d364..b1b165c 100644
--- a/manifests/puppetmaster/passenger.pp
+++ b/manifests/puppetmaster/passenger.pp
@@ -7,13 +7,12 @@ class puppet::puppetmaster::passenger inherits puppet::puppetmaster::base {
# A reference configuration is available at :
# http://github.com/reductivelabs/puppet/tree/master/ext/rack
- file { ['/etc/puppet/rack', '/etc/puppet/rack/public']:
+ file { ['/etc/puppet/rack', '/etc/puppet/rack/public', '/etc/puppet/rack/tmp']:
ensure => directory,
owner => root, group => 0, mode => 0755;
}
file {'/etc/puppet/rack/config.ru':
- ensure => present,
source => [ "puppet://${server}/modules/site-puppet/master/config.ru",
"puppet://${server}/modules/puppet/master/config.ru" ],
owner => puppet, group => 0, mode => 0644;