diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/init.pp | 4 | ||||
-rw-r--r-- | manifests/puppet.pp | 41 | ||||
-rw-r--r-- | manifests/puppetd.pp | 40 | ||||
-rw-r--r-- | manifests/puppetmasterd.pp | 62 |
4 files changed, 147 insertions, 0 deletions
diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..0c34393 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,4 @@ +# This file imports the files for puppet puppet module. +import "puppet.pp" +import "puppetd.pp" +import "puppetmasterd.pp" diff --git a/manifests/puppet.pp b/manifests/puppet.pp new file mode 100644 index 0000000..b783e99 --- /dev/null +++ b/manifests/puppet.pp @@ -0,0 +1,41 @@ +# This classes manage a puppet installation, and provide for a puppetd +# service and a puppetmasterd service, the latter constantly updated by a +# cron-job which git-pushes from '/var/git/repositories/puppet.git'. + +# guarantees puppet user, group and ownerships +class puppet { + user { "puppet": + ensure => present, + allowdupe => false, + } + + group { "puppet": + ensure => present, + allowdupe => false, + } + + file { "/etc/puppet": + ensure => directory, + owner => puppet, + group => puppet, + recurse => inf, + require => User["puppet"], + } + + file { "/usr/local/sbin/check-puppetd.sh": + source => "puppet://$server/modules/puppet/check-puppetd.sh", + owner => "puppet", + group => "puppet", + mode => 0755, + ensure => present, + } + + cron { "puppetd-check": + command => "/usr/local/sbin/check-puppetd.sh &> /dev/null", + user => root, + hour => "*/1", + minute => "0", + require => File["/usr/local/sbin/check-puppetd.sh"], + ensure => present, + } +} diff --git a/manifests/puppetd.pp b/manifests/puppetd.pp new file mode 100644 index 0000000..a26bba2 --- /dev/null +++ b/manifests/puppetd.pp @@ -0,0 +1,40 @@ +# handles puppetd service +class puppetd inherits puppet { + + package { "cron": ensure => installed, } + + package { "puppet": + ensure => installed, + require => Package["cron"], + } + + service { "puppet": + enable => true, + ensure => running, + hasrestart => true, + require => Package["puppet"], + } + + # default config file for puppet nodes + case $puppetmasterd_present { + false: { + file { "/etc/puppet/puppet.conf": + ensure => file, + owner => puppet, + group => puppet, + mode => 0644, + content => template("puppet/puppet-node.conf.erb"), + } + } + } + + # cron rule to restart puppet minutes after puppetmaster is restarted + cron { "puppet-restart": + command => "/etc/init.d/puppet restart &> /dev/null", + user => root, + hour => "*/1", + minute => "10", + ensure => absent, + require => Service["puppet"], + } +} diff --git a/manifests/puppetmasterd.pp b/manifests/puppetmasterd.pp new file mode 100644 index 0000000..c12082e --- /dev/null +++ b/manifests/puppetmasterd.pp @@ -0,0 +1,62 @@ +# handles puppetmasterd service + +# warns that this node has a puppetmaster +$puppetmasterd_present = true + +class puppetmasterd inherits puppet { + + # needed packages + package { + "puppetmaster": ensure => installed; + "sqlite3": ensure => installed; + } + + # for storeconfigs + include mysql::server + + service { "puppetmaster": + enable => true, + ensure => running, + hasrestart => true, + } + + # cron rule to update puppet config repository every 5 minutes + cron { "puppet-update": + command => "/usr/local/sbin/update-puppet-conf.sh &> /dev/null", + user => puppet, + minute => "*/5", + ensure => present, + require => [ File["/usr/local/sbin/update-puppet-conf.sh"], User["puppet"] ], + } + + # cron rule to restart puppetmaster before restarting the nodes + cron { "puppetmaster-restart": + command => "/etc/init.d/puppetmaster restart &> /dev/null", + user => root, + hour => "*/1", + minute => "0", + ensure => absent, + } + + # and the script to the cron-job above + file { "/usr/local/sbin/update-puppet-conf.sh": + source => "puppet://$server/modules/puppet/update-puppet-conf.sh", + owner => "puppet", + group => "puppet", + mode => 0755, + ensure => present, + } + + # TODO: database creation as suggested by + # http://reductivelabs.com/trac/puppet/wiki/Recipes/MySQLStoredConfiguration + #exec { "create-storeconfigs-db": + # command => "/usr/bin/mysqladmin create puppet", + # unless => "/usr/bin/mysqlcheck -s puppet", + # notify => Exec["create-storeconfigs-user"], + #} + #exec { "create-storeconfigs-user": + # command => "/usr/bin/mysql -e 'grant all privileges on puppet.* to puppet@localhost identified by \"puppet\"'", + # refreshonly => true, + #} + +} |