diff options
-rw-r--r-- | files/.git_placeholder | 1 | ||||
-rw-r--r-- | files/cron.d/puppetd | 2 | ||||
-rw-r--r-- | files/cron.d/puppetd.CentOS | 1 | ||||
-rw-r--r-- | files/cron.d/puppetd.Gentoo | 1 | ||||
l--------- | files/cron.d/puppetmaster | 1 | ||||
-rw-r--r-- | files/cron.d/puppetmaster.CentOS | 2 | ||||
-rw-r--r-- | manifests/init.pp | 88 | ||||
-rw-r--r-- | manifests/puppetmaster.pp | 132 | ||||
-rw-r--r-- | manifests/storeconfigs.pp | 5 |
9 files changed, 156 insertions, 77 deletions
diff --git a/files/.git_placeholder b/files/.git_placeholder new file mode 100644 index 0000000..89cb1fe --- /dev/null +++ b/files/.git_placeholder @@ -0,0 +1 @@ +# file needed for git - don't remove it diff --git a/files/cron.d/puppetd b/files/cron.d/puppetd index 9f9e36d..bf19ea7 100644 --- a/files/cron.d/puppetd +++ b/files/cron.d/puppetd @@ -1 +1 @@ -#0 * * * * root /bin/ps ax | /bin/grep -v grep | /bin/grep puppetd > /dev/null || /etc/init.d/puppet restart +0 * * * * root /bin/ps ax | /bin/grep -v grep | /bin/grep puppetd > /dev/null || /etc/init.d/puppet restart diff --git a/files/cron.d/puppetd.CentOS b/files/cron.d/puppetd.CentOS new file mode 100644 index 0000000..bf19ea7 --- /dev/null +++ b/files/cron.d/puppetd.CentOS @@ -0,0 +1 @@ +0 * * * * root /bin/ps ax | /bin/grep -v grep | /bin/grep puppetd > /dev/null || /etc/init.d/puppet restart diff --git a/files/cron.d/puppetd.Gentoo b/files/cron.d/puppetd.Gentoo new file mode 100644 index 0000000..9f9e36d --- /dev/null +++ b/files/cron.d/puppetd.Gentoo @@ -0,0 +1 @@ +#0 * * * * root /bin/ps ax | /bin/grep -v grep | /bin/grep puppetd > /dev/null || /etc/init.d/puppet restart diff --git a/files/cron.d/puppetmaster b/files/cron.d/puppetmaster new file mode 120000 index 0000000..7e5177a --- /dev/null +++ b/files/cron.d/puppetmaster @@ -0,0 +1 @@ +puppetmaster.CentOS
\ No newline at end of file diff --git a/files/cron.d/puppetmaster.CentOS b/files/cron.d/puppetmaster.CentOS new file mode 100644 index 0000000..40a16e7 --- /dev/null +++ b/files/cron.d/puppetmaster.CentOS @@ -0,0 +1,2 @@ +# we restart puppetmaster every 4 hours to avoid memory problems +0 */6 * * * root /etc/init.d/puppetmaster restart > /dev/null diff --git a/manifests/init.pp b/manifests/init.pp index 7f1abd4..5707500 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,6 +1,10 @@ -# modules/puppet/manifests/init.pp - manage puppet stuff -# Copyright (C) 2007 admin@immerda.ch -# +# puppet module +# original by luke kanies +# http://github.com/lak +# adaapted by puzzel itc +# merged with immerda project group's +# solution +####################################### # modules_dir { "puppet": } @@ -21,17 +25,14 @@ class puppet { file { 'puppet_config': path => "$real_puppet_config", - owner => root, - group => 0, - mode => 600, source => [ "puppet://$server/files/puppet/client/${fqdn}/puppet.conf", "puppet://$server/files/puppet/client/puppet.conf.$operatingsystem", "puppet://$server/files/puppet/client/puppet.conf", "puppet://$server/puppet/client/puppet.conf.$operatingsystem", "puppet://$server/puppet/client/puppet.conf" ], notify => Service[puppet], + owner => root, group => 0, mode => 600; } - } class puppet::linux { @@ -50,14 +51,10 @@ class puppet::linux { require => Package[puppet], } - file{'/etc/cron.d/puppetd': - owner => root, - group => 0, - mode => 0644, - source => [ "puppet://$server/files/puppet/cron.d/puppetd", - "puppet://$server/puppet/cron.d/puppetd.$operatingsystem", - "puppet://$server/puppet/cron.d/puppetd" - ], + file{'/etc/cron.d/puppetd.cron': + source => [ "puppet://$server/puppet/cron.d/puppetd.${operatingsystem}", + "puppet://$server/puppet/cron.d/puppetd" ], + owner => root, group => 0, mode => 0644; } } class puppet::gentoo inherits puppet::linux { @@ -79,64 +76,3 @@ class puppet::openbsd { ensure => running, } } - -class puppetmaster inherits puppet { - case $kernel { - linux: { include puppetmaster::linux } - } - File[puppet_config]{ - source => [ "puppet://$server/files/puppet/master/puppet.conf", - "puppet://$server/puppet/master/puppet.conf" ], - notify => [Service[puppet],Service[puppetmaster] ], - } - - $real_puppet_fileserverconfig = $puppet_fileserverconfig ? { - '' => "/etc/puppet/fileserver.conf", - default => $puppet_fileserverconfig, - } - - file { "$real_puppet_fileserverconfig": - owner => root, - group => 0, - mode => 600, - source => [ "puppet://$server/files/puppet/master/fileserver.conf", - "puppet://$server/puppet/master/fileserver.conf" ], - notify => [Service[puppet],Service[puppetmaster] ], - } -} - -class puppetmaster::linux inherits puppet::linux { - service{'puppetmaster': - ensure => running, - require => Package[puppet], - } - - - Service[puppet]{ - require +> Service[puppetmaster], - } - -} - -class puppetmaster::cluster inherits puppetmaster { - include mongrel, nginx - - Service[puppetmaster]{ - require +> Service[ngnix], - } - - File[puppet_config] { - require => [ Package[mongrel], Package[nginx], File[nginx_config] ], - } - - file{"/etc/init.d/puppetmaster": - source => [ "puppet://$server/files/puppet/cluster/init.d/puppetmaster-${fqdn}", - "puppet://$server/puppet/cluster/init.d/puppetmaster.${operatingsystem}", - "puppet://$server/puppet/cluster/init.d/puppetmaster" ], - owner => root, - group => 0, - mode => 0755, - require => [ Package[puppet], Package[mongrel], Package[nginx], File[nginx_config] ], - notify => Service[puppetmaster], - } -} diff --git a/manifests/puppetmaster.pp b/manifests/puppetmaster.pp new file mode 100644 index 0000000..821cb80 --- /dev/null +++ b/manifests/puppetmaster.pp @@ -0,0 +1,132 @@ +# manifests/puppetmaster.pp + +import "storeconfigs.pp" + +class puppet::puppetmaster inherits puppet { + case $operatingsystem { + centos,debian, redhat: { include puppet::puppetmaster::package } + default: { + case $kernel { + linux: { include puppet::puppetmaster::linux } + } + } + } + + File[puppet_config]{ + source => [ "puppet://$server/files/puppet/master/puppet.conf", + "puppet://$server/puppet/master/puppet.conf" ], + notify => [Service[puppet],Service[puppetmaster] ], + } + + $real_puppet_fileserverconfig = $puppet_fileserverconfig ? { + '' => "/etc/puppet/fileserver.conf", + default => $puppet_fileserverconfig, + } + + file { "$real_puppet_fileserverconfig": + source => [ "puppet://$server/files/puppet/master/fileserver.conf", + "puppet://$server/puppet/master/fileserver.conf" ], + notify => [Service[puppet],Service[puppetmaster] ], + owner => root, group => 0, mode => 600; + } + + if $puppetmaster_storeconfigs { + include puppet::puppetmaster::storeconfigs + } + + # restart the master from time to time to avoid memory problems + file{'/etc/cron.d/puppetmaster.cron': + source => [ "puppet://$server/puppet/cron.d/puppetmaster.${operatingsystem}", + "puppet://$server/puppet/cron.d/puppetmaster" ], + owner => root, group => 0, mode => 0644; + } +} + +class puppet::puppetmaster::linux inherits puppet::linux { + + service{'puppetmaster': + ensure => running, + enable => true, + require => [ Package[puppet] ], + } + + Service[puppet]{ + require +> Service[puppetmaster], + } +} + +class puppet::puppetmaster::package inherits puppet::puppetmaster::linux { + package { puppet-server: ensure => present } + + Service[puppetmaster]{ + require +> Package[puppet-server], + } +} + +class puppet::puppetmaster::cluster inherits puppet::puppetmaster { + include mongrel, nginx + + Service[puppetmaster]{ + require +> Service[ngnix], + } + + File[puppet_config] { + require => [ Package[mongrel], Package[nginx], File[nginx_config] ], + } + + case $operatingsystem { + gentoo, centos: { + file{"/etc/init.d/puppetmaster": + source => "puppet://$server/puppet/init.d/puppetmaster.${operatingsystem}", + owner => root, group => 0, mode => 0755; + } + } + } +} + +define puppet::puppetmaster::hasdb( + $dbtype = 'mysql', + $dbname = 'puppet', + $dbhost = 'localhost', + # this is needed due to the collection of the databases + $dbhostfqdn = "${fqdn}", + $dbuser = 'puppet', + $dbpwd = $puppet_storeconfig_password, + $dbconnectinghost = 'locahost' +){ + + case $puppet_storeconfig_password { + '': { fail("No \$puppet_storeconfig_password is set, please set it in your manifests or site.pp to add a password") } + } + + case $dbtype { + 'mysql': { puppet::puppetmaster::hasdb::mysql{$name: dbname => $dbname, dbhost => $dbhost, dbuser => $dbuser, dbpwd => $dbpwd, } } + } +} + +# don't use this define use the general interface +define puppet::puppetmaster::hasdb::mysql( + $dbname = 'puppet', + $dbhost = 'localhost', + $dbhostfqdn = "${fqdn}", + $dbuser = 'puppet', + $dbpwd, + $dbconnectinghost = 'locahost' +){ + @@mysql_database{$dbname: + tag => "mysql_${dbhostfqdn}", + } + + @@mysql_user{"${dbuser}@$${dbconnectinghost}": + password_hash => mysql_password("$dbpwd"), + require => Mysql_database[$dbname], + tag => "mysql_${dbhostfqdn}", + } + + + @@mysql_grant{"${dbuser}@$${dbconnectinghost}/${dbname}": + privileges => all, + require => Mysql_user['munin@localhost'], + tag => "mysql_${dbhostfqdn}", + } +} diff --git a/manifests/storeconfigs.pp b/manifests/storeconfigs.pp new file mode 100644 index 0000000..32aaa7f --- /dev/null +++ b/manifests/storeconfigs.pp @@ -0,0 +1,5 @@ +# This class sets up the necessary ActiveRecord bits +# so storeconfigs works. +class puppet::puppetmaster::storeconfigs { + include rails +} |