summaryrefslogtreecommitdiff
path: root/manifests/master
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/master')
-rw-r--r--manifests/master/base.pp42
-rw-r--r--manifests/master/centos.pp17
-rw-r--r--manifests/master/checklastrun.pp29
-rw-r--r--manifests/master/checklastrun/disable.pp13
-rw-r--r--manifests/master/cleanup_reports.pp7
-rw-r--r--manifests/master/cleanup_reports/disable.pp6
-rw-r--r--manifests/master/cluster.pp5
-rw-r--r--manifests/master/cluster/base.pp9
-rw-r--r--manifests/master/dashboard.pp72
-rw-r--r--manifests/master/debian.pp18
-rw-r--r--manifests/master/hasdb.pp17
-rw-r--r--manifests/master/hasdb/mysql.pp32
-rw-r--r--manifests/master/hiera.pp12
-rw-r--r--manifests/master/linux.pp18
-rw-r--r--manifests/master/munin.pp13
-rw-r--r--manifests/master/package.pp9
-rw-r--r--manifests/master/package/base.pp12
-rw-r--r--manifests/master/package/centos.pp7
-rw-r--r--manifests/master/package/debian.pp10
-rw-r--r--manifests/master/passenger.pp26
-rw-r--r--manifests/master/storeconfigs.pp8
21 files changed, 382 insertions, 0 deletions
diff --git a/manifests/master/base.pp b/manifests/master/base.pp
new file mode 100644
index 0000000..4931264
--- /dev/null
+++ b/manifests/master/base.pp
@@ -0,0 +1,42 @@
+# overwrite a few things for the master
+class puppet::master::base inherits puppet::base {
+
+ file { $puppet::master::fileserver:
+ source => ["puppet:///modules/site_puppet/master/${::fqdn}/fileserver.conf",
+ 'puppet:///modules/site_puppet/master/fileserver.conf',
+ 'puppet:///modules/puppet/master/fileserver.conf' ],
+ owner => root,
+ group => puppet,
+ mode => '0640';
+ }
+
+ if !$puppet::master::config_content {
+ File['puppet_config']{
+ source => [ "puppet:///modules/site_puppet/master/${::fqdn}/puppet.conf",
+ 'puppet:///modules/site_puppet/master/puppet.conf',
+ 'puppet:///modules/puppet/master/puppet.conf' ]
+ }
+ }
+
+ if $puppet::master::storeconfigs {
+ include puppet::master::storeconfigs
+ }
+
+
+ if $puppet::master::mode == 'passenger' {
+ include puppet::master::passenger
+ File[$puppet::master::fileserver]{
+ notify => Exec['notify_passenger_puppetmaster'],
+ }
+ File[puppet_config]{
+ notify => Exec['notify_passenger_puppetmaster'],
+ }
+ } else {
+ File[$puppet::master::fileserver]{
+ notify => Service[puppetmaster],
+ }
+ File[puppet_config]{
+ notify => Service[puppetmaster],
+ }
+ }
+}
diff --git a/manifests/master/centos.pp b/manifests/master/centos.pp
new file mode 100644
index 0000000..b684174
--- /dev/null
+++ b/manifests/master/centos.pp
@@ -0,0 +1,17 @@
+# manifests/puppetmaster/centos.pp
+class puppet::master::centos inherits puppet::master::package {
+ file { '/etc/sysconfig/puppetmaster':
+ source => [ "puppet:///modules/site_puppet/sysconfig/${::fqdn}/puppetmaster",
+ "puppet:///modules/site_puppet/sysconfig/${::domain}/puppetmaster",
+ 'puppet:///modules/site_puppet/sysconfig/puppetmaster',
+ 'puppet:///modules/puppet/sysconfig/puppetmaster' ],
+ owner => root,
+ group => 0,
+ mode => '0644';
+ }
+ if $puppet::master::mode != 'passenger' {
+ File['/etc/sysconfig/puppetmaster']{
+ notify => Service[puppetmaster],
+ }
+ }
+}
diff --git a/manifests/master/checklastrun.pp b/manifests/master/checklastrun.pp
new file mode 100644
index 0000000..2544acc
--- /dev/null
+++ b/manifests/master/checklastrun.pp
@@ -0,0 +1,29 @@
+# check for last run
+class puppet::master::checklastrun {
+
+ $puppet_lastruncheck_ignorehosts_str = $puppet::master::lastruncheck_ignorehosts ? {
+ '' => '',
+ undef => '',
+ default => "--ignore-hosts ${puppet::master::lastruncheck_ignorehosts}"
+ }
+
+ $puppet_lastruncheck_timeout_str = $puppet::master::lastruncheck_timeout ? {
+ '' => '',
+ undef => '',
+ default => "--timeout ${puppet::master::lastruncheck_timeout}"
+ }
+
+ file{
+ '/usr/local/sbin/puppetlast':
+ source => 'puppet:///modules/puppet/master/lastruncheck',
+ owner => root,
+ group => 0,
+ mode => '0700';
+ '/etc/cron.d/puppetlast':
+ content => "${puppet::master::lastruncheck_cron} root /usr/local/sbin/puppetlast ${puppet_lastruncheck_timeout_str} ${puppet_lastruncheck_ignorehosts_str} ${puppet::master::lastruncheck_additionaloptions} | grep -Ev '^OK: '\n",
+ require => File['/usr/local/sbin/puppetlast'],
+ owner => root,
+ group => 0,
+ mode => '0644';
+ }
+}
diff --git a/manifests/master/checklastrun/disable.pp b/manifests/master/checklastrun/disable.pp
new file mode 100644
index 0000000..e5a7198
--- /dev/null
+++ b/manifests/master/checklastrun/disable.pp
@@ -0,0 +1,13 @@
+# disable the check
+class puppet::master::checklastrun::disable inherits puppet::master::checklastrun {
+
+ File['/usr/local/sbin/puppetlast']{
+ source => undef,
+ ensure => absent,
+ }
+
+ File['/etc/cron.d/puppetlast']{
+ ensure => absent,
+ }
+}
+
diff --git a/manifests/master/cleanup_reports.pp b/manifests/master/cleanup_reports.pp
new file mode 100644
index 0000000..98cb81a
--- /dev/null
+++ b/manifests/master/cleanup_reports.pp
@@ -0,0 +1,7 @@
+class puppet::master::cleanup_reports {
+ # clean up reports older than $puppetmaster_cleanup_reports days
+ file { '/etc/cron.daily/puppet_reports_cleanup.sh':
+ content => "#!/bin/bash\nfind ${puppet::master::reports_dir} -maxdepth 2 -type f -ctime +${puppet::master::cleanup_reports} -exec rm {} \\;\n",
+ owner => root, group => 0, mode => 0700;
+ }
+}
diff --git a/manifests/master/cleanup_reports/disable.pp b/manifests/master/cleanup_reports/disable.pp
new file mode 100644
index 0000000..e93e72a
--- /dev/null
+++ b/manifests/master/cleanup_reports/disable.pp
@@ -0,0 +1,6 @@
+class puppet::master::cleanup_reports::disable inherits puppet::master::cleanup_reports {
+
+ File['/etc/cron.daily/puppet_reports_cleanup.sh']{
+ ensure => absent,
+ }
+}
diff --git a/manifests/master/cluster.pp b/manifests/master/cluster.pp
new file mode 100644
index 0000000..d6aa4fd
--- /dev/null
+++ b/manifests/master/cluster.pp
@@ -0,0 +1,5 @@
+class puppet::master::cluster inherits puppet::master {
+
+ include puppet::master::cluster::base
+
+}
diff --git a/manifests/master/cluster/base.pp b/manifests/master/cluster/base.pp
new file mode 100644
index 0000000..cad0d7d
--- /dev/null
+++ b/manifests/master/cluster/base.pp
@@ -0,0 +1,9 @@
+class puppet::master::cluster::base inherits puppet::master::base {
+
+ include mongrel, nginx
+
+ File[puppet_config] {
+ require +> [ Package[mongrel], Package[nginx], File[nginx_config] ],
+ }
+}
+
diff --git a/manifests/master/dashboard.pp b/manifests/master/dashboard.pp
new file mode 100644
index 0000000..4cbee12
--- /dev/null
+++ b/manifests/master/dashboard.pp
@@ -0,0 +1,72 @@
+# simple installation of a puppet dashboard
+class puppet::master::dashboard(
+ $settings = {},
+ $service = true,
+ $mysql_host = '127.0.0.1',
+ $mysql_password,
+) {
+
+ package{'puppet-dashboard':
+ ensure => installed,
+ }
+
+ if $mysql_host == '127.0.0.1' {
+ mysql::default_database{
+ 'dashboard':
+ password => mysql_password($mysql_password),
+ host => '127.0.0.1',
+ require => Package['puppet-dashboard'],
+ before => File['/usr/share/puppet-dashboard/config/database.yml'],
+ }
+ }
+
+ file{
+ '/usr/share/puppet-dashboard/config/database.yml':
+ content => template('puppet/master/dashboard/database.yml.erb'),
+ owner => root,
+ group => 'puppet-dashboard',
+ mode => '0640',
+ require => Package['puppet-dashboard'];
+ '/usr/share/puppet-dashboard/config/settings.yml':
+ content => template('puppet/master/dashboard/settings.yml.erb'),
+ owner => root,
+ group => 'puppet-dashboard',
+ mode => '0640';
+ } ~> exec{
+ 'rake RAILS_ENV=production db:migrate':
+ cwd => '/usr/share/puppet-dashboard',
+ user => 'puppet-dashboard',
+ refreshonly => true;
+ } -> service{
+ 'puppet-dashboard-workers':
+ ensure => running,
+ enable => true;
+ }
+
+ file{'/etc/cron.daily/puppet-dashboard_cleanup':
+ content => "#/bin/bash
+cd /usr/share/puppet-dashboard
+su - puppet-dashboard -s /bin/bash -c 'RAILS_ENV=production /usr/bin/rake reports:prune upto=1 unit=mon >> /usr/share/puppet-dashboard/log/cron.log'
+su - puppet-dashboard -s /bin/bash -c 'RAILS_ENV=production /usr/bin/rake reports:prune:orphaned >> /usr/share/puppet-dashboard/log/cron.log'
+su - puppet-dashboard -s /bin/bash -c 'RAILS_ENV=production /usr/bin/rake db:raw:optimize >> /usr/share/puppet-dashboard/log/cron.log'\n",
+ owner => 'root',
+ group => 0,
+ mode => '0755',
+ require => Service['puppet-dashboard-workers'];
+ }
+
+ service{'puppet-dashboard': }
+ if $service {
+ Service['puppet-dashboard']{
+ ensure => running,
+ enable => true,
+ subscribe => File['/usr/share/puppet-dashboard/config/database.yml',
+ '/usr/share/puppet-dashboard/config/settings.yml'],
+ }
+ } else {
+ Service['puppet-dashboard']{
+ ensure => stopped,
+ enable => false,
+ }
+ }
+}
diff --git a/manifests/master/debian.pp b/manifests/master/debian.pp
new file mode 100644
index 0000000..5748683
--- /dev/null
+++ b/manifests/master/debian.pp
@@ -0,0 +1,18 @@
+# debian master
+class puppet::master::debian inherits puppet::master::package {
+
+ if $puppet::master::mode != 'passenger' {
+ Service['puppetmaster'] { hasstatus => true, hasrestart => true }
+ }
+
+ 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',
+ 'puppet:///modules/puppet/master/debian/puppetmaster' ],
+ notify => Service[puppetmaster],
+ owner => root,
+ group => 0,
+ mode => '0644';
+ }
+}
diff --git a/manifests/master/hasdb.pp b/manifests/master/hasdb.pp
new file mode 100644
index 0000000..66aeb62
--- /dev/null
+++ b/manifests/master/hasdb.pp
@@ -0,0 +1,17 @@
+define puppet::master::hasdb (
+ $dbtype = 'mysql',
+ $dbname = 'puppet',
+ $dbhost = 'localhost',
+ # this is needed due to the collection of the databases
+ $dbhostfqdn = $::fqdn,
+ $dbuser = 'puppet',
+ $dbpwd = false,
+ $dbconnectinghost = 'locahost'
+) {
+
+ if !$dbpwd { fail('No $puppet_master_storeconfig_password is set, please pass it the master class') }
+
+ case $dbtype {
+ 'mysql': { puppet::master::hasdb::mysql{$name: dbname => $dbname, dbhost => $dbhost, dbuser => $dbuser, dbpwd => $dbpwd, } }
+ }
+}
diff --git a/manifests/master/hasdb/mysql.pp b/manifests/master/hasdb/mysql.pp
new file mode 100644
index 0000000..5f4985a
--- /dev/null
+++ b/manifests/master/hasdb/mysql.pp
@@ -0,0 +1,32 @@
+# don't use this define use the general interface
+define puppet::master::hasdb::mysql (
+ $dbname = 'puppet',
+ $dbhost = 'localhost',
+ $dbhostfqdn = $::fqdn,
+ $dbuser = 'puppet',
+ $dbpwd,
+ $dbconnectinghost = 'localhost' )
+{
+ @@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["${dbuser}@${dbconnectinghost}"],
+ tag => "mysql_${dbhostfqdn}",
+ }
+
+ if $puppet::master::manage_munin {
+ munin::plugin::deploy { 'puppetresources':
+ source => "puppet/munin/puppetresources.mysql",
+ config => "env.mysqlopts --user=$dbuser --password=$dbpwd -h $dbhost\nenv.puppetdb $dbname",
+ }
+ }
+}
diff --git a/manifests/master/hiera.pp b/manifests/master/hiera.pp
new file mode 100644
index 0000000..1fe5f24
--- /dev/null
+++ b/manifests/master/hiera.pp
@@ -0,0 +1,12 @@
+# manage hiera file
+class puppet::master::hiera {
+ if versioncmp($::puppetversion,'3.0') < 0 {
+ require rubygems::hiera_puppet
+ }
+ file{"${settings::confdir}/hiera.yaml":
+ source => 'puppet:///modules/site_puppet/master/hiera.yaml',
+ owner => root,
+ group => puppet,
+ mode => '0640';
+ }
+}
diff --git a/manifests/master/linux.pp b/manifests/master/linux.pp
new file mode 100644
index 0000000..e52db63
--- /dev/null
+++ b/manifests/master/linux.pp
@@ -0,0 +1,18 @@
+class puppet::master::linux inherits puppet::linux {
+
+ if $puppet::master::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':
+ ensure => running,
+ enable => true,
+ require => [ Package[puppet] ],
+ }
+ Service[puppet]{
+ require +> Service[puppetmaster],
+ }
+ }
+}
diff --git a/manifests/master/munin.pp b/manifests/master/munin.pp
new file mode 100644
index 0000000..ca6fddc
--- /dev/null
+++ b/manifests/master/munin.pp
@@ -0,0 +1,13 @@
+# deploy puppet munin plugin
+class puppet::master::munin {
+ munin::plugin::deploy{'puppet_':
+ ensure => absent,
+ source => 'puppet/munin/puppet_';
+ }
+ munin::plugin{
+ ['puppet_clients','puppet_mem']:
+ ensure => 'puppet_',
+ require => Munin::Plugin::Deploy['puppet_'],
+ config => 'user root';
+ }
+}
diff --git a/manifests/master/package.pp b/manifests/master/package.pp
new file mode 100644
index 0000000..03d8de6
--- /dev/null
+++ b/manifests/master/package.pp
@@ -0,0 +1,9 @@
+# manifests/puppetmaster/package.pp
+
+class puppet::master::package inherits puppet::master::linux {
+ case $::operatingsystem {
+ centos: { include puppet::master::package::centos }
+ debian: { include puppet::master::package::debian }
+ default: { include puppet::master::package::base }
+ }
+}
diff --git a/manifests/master/package/base.pp b/manifests/master/package/base.pp
new file mode 100644
index 0000000..2851747
--- /dev/null
+++ b/manifests/master/package/base.pp
@@ -0,0 +1,12 @@
+class puppet::master::package::base inherits puppet::master::package {
+
+ package { 'puppetmaster':
+ ensure => $puppet::ensure_version,
+ }
+
+ if $puppet::master::mode != 'passenger' {
+ Service['puppetmaster']{
+ require +> Package['puppetmaster'],
+ }
+ }
+}
diff --git a/manifests/master/package/centos.pp b/manifests/master/package/centos.pp
new file mode 100644
index 0000000..63adc64
--- /dev/null
+++ b/manifests/master/package/centos.pp
@@ -0,0 +1,7 @@
+class puppet::master::package::centos inherits puppet::master::package::base {
+
+ Package['puppetmaster']{
+ name => 'puppet-server',
+ alias => 'puppetmaster',
+ }
+}
diff --git a/manifests/master/package/debian.pp b/manifests/master/package/debian.pp
new file mode 100644
index 0000000..0cb351c
--- /dev/null
+++ b/manifests/master/package/debian.pp
@@ -0,0 +1,10 @@
+class puppet::master::package::debian inherits puppet::master::package::base {
+
+ package { 'puppetmaster-common':
+ ensure => present,
+ }
+
+ Package['puppetmaster']{
+ require => Package['puppetmaster-common']
+ }
+}
diff --git a/manifests/master/passenger.pp b/manifests/master/passenger.pp
new file mode 100644
index 0000000..cf90b1d
--- /dev/null
+++ b/manifests/master/passenger.pp
@@ -0,0 +1,26 @@
+# class to use passenger for serving puppetmaster
+class puppet::master::passenger inherits puppet::master {
+
+ include ::passenger
+
+ # A reference configuration is available at :
+ # http://github.com/reductivelabs/puppet/tree/master/ext/rack
+ file {
+ ['/etc/puppet/rack', '/etc/puppet/rack/public' ]:
+ ensure => directory,
+ owner => root,
+ group => 0,
+ mode => '0755';
+ '/etc/puppet/rack/tmp':
+ ensure => directory,
+ owner => puppet,
+ group => 0,
+ mode => '0750';
+ '/etc/puppet/rack/config.ru':
+ source => ['puppet:///modules/site_puppet/master/config.ru',
+ 'puppet:///modules/puppet/master/config.ru' ],
+ owner => puppet,
+ group => 0,
+ mode => '0644';
+ }
+}
diff --git a/manifests/master/storeconfigs.pp b/manifests/master/storeconfigs.pp
new file mode 100644
index 0000000..e3ba6fb
--- /dev/null
+++ b/manifests/master/storeconfigs.pp
@@ -0,0 +1,8 @@
+# This class sets up the necessary ActiveRecord bits
+# so storeconfigs works.
+
+class puppet::master::storeconfigs {
+ include rails
+ include mysql::server
+ include mysql::client::ruby
+}