diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-01-25 17:00:46 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-01-25 17:00:46 -0200 |
commit | 7113c1868df70181bc8315c3f6ec9a7d1e3fe650 (patch) | |
tree | b916bbe6540d53d3dba054db116210b72e616e16 | |
parent | 7c570f42da2605ba53fcc54741cee7d68f028ab6 (diff) | |
download | puppet-puppet-7113c1868df70181bc8315c3f6ec9a7d1e3fe650.tar.gz puppet-puppet-7113c1868df70181bc8315c3f6ec9a7d1e3fe650.tar.bz2 |
Parametrizing more variables
-rw-r--r-- | manifests/daemon.pp | 55 | ||||
-rw-r--r-- | manifests/master.pp | 32 | ||||
-rw-r--r-- | templates/check-puppetd.sh.erb | 2 | ||||
-rw-r--r-- | templates/puppet-node.conf.erb | 10 | ||||
-rw-r--r-- | templates/puppetmaster.erb | 8 |
5 files changed, 44 insertions, 63 deletions
diff --git a/manifests/daemon.pp b/manifests/daemon.pp index 27f3651..13b81b1 100644 --- a/manifests/daemon.pp +++ b/manifests/daemon.pp @@ -1,29 +1,18 @@ # handles puppetd service class puppet::daemon( - $master = false, - $main_master = false, + $master = false, + $main_master = false, + $ensure = hiera('puppet::daemon::ensure', ''), + $port = hiera('puppet::daemon::port', "8140"), + $runinterval = hiera('puppet::daemon::runinterval', "7200"), + $configtimeout = hiera('puppet::daemon::configtimeout', "120"), + $server = hiera('puppet::daemon::server', "puppet.${::domain}" ) { include puppet - case $puppetmaster_port { - '': { $puppetmaster_port = "8140" } - } - - case $puppetd_runinterval { - '': { $puppetd_runinterval = "7200" } - } - - case $puppetd_configtimeout { - '': { $puppetd_configtimeout = "120" } - } - - case $puppetd_server { - '': { $puppetd_server = "puppet.$domain" } - } - - case $puppetd_ensure { + case $ensure { '': { - $puppetd_ensure = $lsbdistcodename ? { + $ensure = $::lsbdistcodename ? { 'squeeze' => '2.7.18-1~bpo60+1', default => installed, } @@ -31,16 +20,16 @@ class puppet::daemon( } package { "puppet-common": - ensure => $puppetd_ensure, + ensure => $ensure, } package { "puppet": - ensure => $puppetd_ensure, + ensure => $ensure, require => Package["cron", "puppet-common"], } file { "/etc/default/puppet": - source => "puppet://$server/modules/puppet/puppet", + source => "puppet:///modules/puppet/puppet", owner => "root", group => "root", mode => 0644, @@ -55,14 +44,14 @@ class puppet::daemon( require => [ Package["puppet"], File["/etc/default/puppet"] ], } - # name of puppet agent section in config file - if $puppetversion <= "0.25.4" { - $puppet_agent_name = 'puppetd' + # Name of puppet agent section in config file + if $::puppetversion <= "0.25.4" { + $agent_name = 'puppetd' } else { - $puppet_agent_name = 'agent' + $agent_name = 'agent' } - # default config file for puppet nodes + # Default config file for puppet nodes if ($master != true) or ($main_master != true) { file { "/etc/puppet/puppet.conf": ensure => file, @@ -78,7 +67,7 @@ class puppet::daemon( } } - # cron rule to restart puppet minutes after puppetmaster is restarted + # Cron rule to restart puppet minutes after puppetmaster is restarted cron { "puppet-restart": command => "/etc/init.d/puppet restart > /dev/null 2>&1", user => root, @@ -105,17 +94,17 @@ class puppet::daemon( ensure => present, } - # thanks to https://labs.riseup.net/code/projects/shared-puppet + # Thanks to https://labs.riseup.net/code/projects/shared-puppet file { "/etc/cron.d/puppetd": - source => "puppet://$server/modules/puppet/cron.d/puppetd", + source => "puppet:///modules/puppet/cron.d/puppetd", owner => root, group => root, mode => 0644; } - # restore to original state after the following bug is addressed: + # Restore to original state after the following bug is addressed: # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=625626 - if $lsbdistcodename == 'squeeze' { + if $::lsbdistcodename == 'squeeze' { file { "/etc/logrotate.d/puppetmaster": ensure => absent, } diff --git a/manifests/master.pp b/manifests/master.pp index 54898a0..f81f2b3 100644 --- a/manifests/master.pp +++ b/manifests/master.pp @@ -1,20 +1,10 @@ # handles puppetmasterd service class puppet::master( - $main = false + $main = false, + $servertype = hiera('puppet::master::servertype', 'passenger'), + $manager_ca = hiera('puppet::master::manage_ca', false) ) { - # Configuration - case $puppetmaster_servertype { - 'mongrel': { - $puppetmaster_servertype = 'mongrel' - $puppetmaster_daemon_opts = '--ssl_client_header=HTTP_X_SSL_SUBJECT' - } - default: { - $puppetmaster_servertype = 'passenger' - $puppetmaster_daemon_opts = '' - } - } - # Use this option if you want puppet to manage the certificates for all # master nodes, useful when using multiple masters as prevents issues such as # http://groups.google.com/group/puppet-users/browse_thread/thread/f24bd7500e9091bd @@ -25,7 +15,7 @@ class puppet::master( # - It doesn't refresh the proxy server (eg. nginx) upon key updates. # # A better approach is to keep certificates at /etc/puppet/ssl (and hence at your puppet repo). - if $puppetmaster_manage_ca == true { + if $manage_ca == true { include puppet::master::ca } @@ -39,20 +29,22 @@ class puppet::master( package { "sqlite3": ensure => installed; "libmysql-ruby": ensure => installed; - "ruby-hiera-puppet": ensure => $lsbdistcodename ? { + "ruby-hiera-puppet": ensure => $::lsbdistcodename ? { 'squeeze' => absent, default => installed, } } - case $puppetmaster_servertype { + case $servertype { 'mongrel': { - $puppetmaster_puppetmasters = hiera('puppet::master::worker_processes', 4) - $puppetmaster_port = hiera('puppet::master::port', '18140') + $daemon_opts = '--ssl_client_header=HTTP_X_SSL_SUBJECT' + $worker_processes = hiera('puppet::master::worker_processes', 4) + $puppetmaster_port = hiera('puppet::master::port', '18140') include puppet::master::mongrel } 'passenger': { + $daemon_opts = '' include puppet::master::passenger } default: { @@ -110,14 +102,14 @@ class puppet::master( } # cron rule to execute puppetlast once a week as a report - # currently not working for puppet 2.6.x + # currently not working for puppet 2.6+ cron { "puppetlast": command => "/usr/local/sbin/puppetlast", user => root, hour => "0", minute => "0", weekday => "0", - ensure => $puppetversion ? { + ensure => $::puppetversion ? { "0.25.4" => present, default => absent, }, diff --git a/templates/check-puppetd.sh.erb b/templates/check-puppetd.sh.erb index d467ad6..ee2fc7a 100644 --- a/templates/check-puppetd.sh.erb +++ b/templates/check-puppetd.sh.erb @@ -4,7 +4,7 @@ # PATH="$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" -PID="/var/run/puppet/<%= puppet_agent_name %>.pid" +PID="/var/run/puppet/<%= agent_name %>.pid" INIT="/etc/init.d/puppet" LOCKFILE="/var/run/puppet/check-puppetd.pid" diff --git a/templates/puppet-node.conf.erb b/templates/puppet-node.conf.erb index ac113bc..7df045c 100644 --- a/templates/puppet-node.conf.erb +++ b/templates/puppet-node.conf.erb @@ -6,11 +6,11 @@ rundir = /var/run/puppet factpath = $vardir/lib/facter pluginsync = true -[<%= puppet_agent_name %>] +[<%= agent_name %>] vardir = /var/lib/puppet ssldir = $vardir/ssl -server = <%= puppetd_server %> -runinterval = <%= puppetd_runinterval %> +server = <%= server %> +runinterval = <%= runinterval %> puppetport = 8139 -masterport = <%= puppetmaster_port %> -configtimeout = <%= puppetd_configtimeout %> +masterport = <%= port %> +configtimeout = <%= configtimeout %> diff --git a/templates/puppetmaster.erb b/templates/puppetmaster.erb index b3ce647..750e080 100644 --- a/templates/puppetmaster.erb +++ b/templates/puppetmaster.erb @@ -4,8 +4,8 @@ START=yes # Startup options -DAEMON_OPTS="<%= puppetmaster_daemon_opts %>" -<% if puppetmaster_servertype == 'mongrel' %> +DAEMON_OPTS="<%= daemon_opts %>" +<% if servertype == 'mongrel' %> # What server type to run # Options: # webrick (default, cannot handle more than ~30 nodes) @@ -15,11 +15,11 @@ DAEMON_OPTS="<%= puppetmaster_daemon_opts %>" # mongrel. Requires front-end web-proxy such as # apache, nginx, or pound) # See: http://reductivelabs.com/trac/puppet/wiki/UsingMongrel -SERVERTYPE=<%= puppetmaster_servertype %> +SERVERTYPE=<%= servertype %> # How many puppetmaster instances to start? Its pointless to set this # higher than 1 if you are not using mongrel. -PUPPETMASTERS=<%= puppetmaster_puppetmasters %> +PUPPETMASTERS=<%= worker_processes %> # What port should the puppetmaster listen on (default: 8140). If # PUPPETMASTERS is set to a number greater than 1, then the port for |