some refactoring, externalizing classes
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# $Id: puppetd_run.sh 2714 2009-08-01 09:52:05Z uwaechte $
|
||||
|
||||
|
||||
# a wrapper script, to run puppetd after a random time
|
||||
# this will be called by cron at the same time on each client,
|
||||
# but should not call the master at the same time as the others.
|
||||
export FACTERLIB="/var/lib/puppet/facts"
|
||||
[ -e /etc/profile ] && . /etc/profile
|
||||
|
||||
PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
PUPPET=$(which puppetd)
|
||||
ISUNIIP=$(ifconfig |grep -c -e "131\.173\.3[2345]")
|
||||
|
||||
14
manifests/common.pp
Normal file
14
manifests/common.pp
Normal file
@@ -0,0 +1,14 @@
|
||||
class puppet::common ($ensure = 'present') {
|
||||
package { 'facter':
|
||||
ensure => $ensure ? {
|
||||
'present' => 'latest',
|
||||
default => $ensure,
|
||||
}
|
||||
}
|
||||
|
||||
# add facter variable to custom facts.
|
||||
file { "/etc/profile.d/puppet.sh":
|
||||
content => "export FACTERLIB=\"${factpath}\"\n",
|
||||
ensure => $ensure,
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
# $Id: init.pp 4425 2011-06-17 11:42:17Z uwaechte $
|
||||
@@puppet::puppetmaster::privatedir { $fqdn: l_fqdn => generate('/usr/bin/env', 'perl', '-e', '$_=shift;tr/[A-Z]/[a-z]/;print $_',
|
||||
"$fqdn") }
|
||||
|
||||
import "defines/*.pp"
|
||||
|
||||
class puppet (
|
||||
$ensure = "present",
|
||||
$norunifloggedin = false,
|
||||
@@ -13,6 +17,13 @@ class puppet (
|
||||
}
|
||||
$factpath = "/var/lib/puppet/lib/facter"
|
||||
|
||||
require 'puppet::common'
|
||||
|
||||
if !defined(Class['puppet::puppetlabs_apt']) {
|
||||
class { 'puppet::puppetlabs_apt': }
|
||||
require 'puppet::puppetlabs_apt'
|
||||
}
|
||||
|
||||
case $kernel {
|
||||
"Linux" : {
|
||||
$puppetpkgs = ["puppet", "puppet-common"]
|
||||
@@ -38,8 +49,6 @@ class puppet (
|
||||
notify => Service["${puppet_service}"],
|
||||
}
|
||||
|
||||
package { ["facter"]: ensure => "${ensure}", }
|
||||
|
||||
service { "${puppet_service}":
|
||||
hasstatus => true,
|
||||
enable => "${daemonize}",
|
||||
@@ -50,7 +59,8 @@ class puppet (
|
||||
true => "absent",
|
||||
default => $ensure,
|
||||
}
|
||||
notice("${fqdn} PUPPET-CRON: cron_real: ${cron_real}, daemonize: ${daemonize}, running: ${service_running}")
|
||||
notice("${fqdn} PUPPET-CRON: cron_real: ${cron_real}, daemonize: ${daemonize}, running: ${service_running}"
|
||||
)
|
||||
|
||||
cron { puppetrun:
|
||||
command => "/usr/local/sbin/puppetd_run.sh",
|
||||
@@ -75,7 +85,8 @@ class puppet (
|
||||
before => Service["${puppet_service}"],
|
||||
}
|
||||
|
||||
file { "/opt/local/lib/ruby/site_ruby/1.8/puppet/provider/package/appdmg.rb": ensure => "absent", }
|
||||
file { "/opt/local/lib/ruby/site_ruby/1.8/puppet/provider/package/appdmg.rb"
|
||||
: ensure => "absent", }
|
||||
}
|
||||
"Linux" : {
|
||||
replace { "enable_puppet":
|
||||
@@ -118,84 +129,4 @@ class puppet (
|
||||
# require => [ Package["puppet"] ],
|
||||
}
|
||||
|
||||
# add facter variable to custom facts.
|
||||
file { "/etc/profile.d/puppet.sh":
|
||||
content => "export FACTERLIB=\"${factpath}\"\n",
|
||||
ensure => $ensure,
|
||||
}
|
||||
}
|
||||
|
||||
@@puppet::puppetmaster::privatedir { $fqdn: l_fqdn => generate('/usr/bin/env', 'perl', '-e', '$_=shift;tr/[A-Z]/[a-z]/;print $_',
|
||||
"$fqdn") }
|
||||
|
||||
class puppet::puppet-dashboard ($ensure = "present") {
|
||||
package { ["libjson-ruby", "puppet-dashboard"]:
|
||||
ensure => $ensure,
|
||||
require => Apt::Repository["puppet-dashboard"],
|
||||
}
|
||||
|
||||
apt::repository { "puppet-dashboard":
|
||||
key => "8347A27F",
|
||||
repository => "deb http://apt.puppetlabs.com ${lsbdistcodename} main\n",
|
||||
ensure => $ensure,
|
||||
}
|
||||
|
||||
cron { "purge-reports":
|
||||
command => "cd /usr/share/puppet-dashboard && rake RAILS_ENV=production reports:prune upto=14 unit=day",
|
||||
user => "www-data",
|
||||
hour => "23",
|
||||
minute => "2",
|
||||
monthday => "*/14",
|
||||
ensure => $ensure,
|
||||
}
|
||||
|
||||
cron { "purge-optimizedb":
|
||||
command => "cd /usr/share/puppet-dashboard && rake RAILS_ENV=production db:raw:optimize",
|
||||
user => "www-data",
|
||||
hour => "23",
|
||||
minute => "20",
|
||||
monthday => "*/10",
|
||||
ensure => $ensure,
|
||||
}
|
||||
}
|
||||
|
||||
class puppet::puppetmaster ($ensure = "present", $puppetqd = false) {
|
||||
if $puppetqd {
|
||||
class { "activemq": ensure => $ensure }
|
||||
|
||||
package { "libnet-arp-perl": ensure => $ensure }
|
||||
|
||||
service { "stompserver":
|
||||
ensure => false,
|
||||
enable => false,
|
||||
before => Class["activemq"],
|
||||
}
|
||||
|
||||
service { "puppetqd":
|
||||
ensure => running,
|
||||
pattern => "puppet queue queue",
|
||||
enable => true,
|
||||
}
|
||||
}
|
||||
|
||||
Ganglia::Gmetric::Cron {
|
||||
source => "puppet/ganglia",
|
||||
ensure => "${ensure}",
|
||||
}
|
||||
|
||||
ganglia::gmetric::cron { "puppetmaster.rb": runwhen => "5", }
|
||||
|
||||
ganglia::gmetric::cron { "puppetmaster_compiletime.rb": runwhen => "60", }
|
||||
|
||||
# ## remove disk reports from time to time
|
||||
tidy { "${puppet_vardir}/reports":
|
||||
age => "1d",
|
||||
recurse => true,
|
||||
backup => false,
|
||||
}
|
||||
|
||||
# create [private] directories
|
||||
# file { $puppet_privdir: ensure => directory }
|
||||
# Puppet::Puppetmaster::Privatedir <<| |>>
|
||||
}
|
||||
import "defines/*.pp"
|
||||
}
|
||||
38
manifests/puppet-dashboard.pp
Normal file
38
manifests/puppet-dashboard.pp
Normal file
@@ -0,0 +1,38 @@
|
||||
class puppet::puppet-dashboard ($ensure = "present") {
|
||||
require 'puppet::common'
|
||||
|
||||
package { ["libjson-ruby", "puppet-dashboard"]:
|
||||
ensure => $ensure,
|
||||
require => Apt::Source["puppet-dashboard"],
|
||||
}
|
||||
|
||||
if !defined(Class['puppet::puppetlabs_apt']) {
|
||||
class { 'puppet::puppetlabs_apt': }
|
||||
require 'puppet::puppetlabs_apt'
|
||||
}
|
||||
|
||||
apt::source { "puppet-dashboard":
|
||||
key => "8347A27F",
|
||||
location => "http://apt.puppetlabs.com",
|
||||
repos => "main",
|
||||
ensure => 'absent',
|
||||
}
|
||||
|
||||
cron { "purge-reports":
|
||||
command => "cd /usr/share/puppet-dashboard && rake RAILS_ENV=production reports:prune upto=14 unit=day",
|
||||
user => "www-data",
|
||||
hour => "23",
|
||||
minute => "2",
|
||||
monthday => "*/14",
|
||||
ensure => $ensure,
|
||||
}
|
||||
|
||||
cron { "purge-optimizedb":
|
||||
command => "cd /usr/share/puppet-dashboard && rake RAILS_ENV=production db:raw:optimize",
|
||||
user => "www-data",
|
||||
hour => "23",
|
||||
minute => "20",
|
||||
monthday => "*/10",
|
||||
ensure => $ensure,
|
||||
}
|
||||
}
|
||||
8
manifests/puppetlabs_apt.pp
Normal file
8
manifests/puppetlabs_apt.pp
Normal file
@@ -0,0 +1,8 @@
|
||||
class puppet::puppetlabs_apt ($ensure = 'present') {
|
||||
apt::source { 'puppetlabs':
|
||||
key => '4BD6EC30',
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
ensure => $ensure,
|
||||
}
|
||||
}
|
||||
48
manifests/puppetmaster.pp
Normal file
48
manifests/puppetmaster.pp
Normal file
@@ -0,0 +1,48 @@
|
||||
class puppet::puppetmaster ($ensure = "present", $puppetqd = false) {
|
||||
require 'puppet::common'
|
||||
|
||||
if !defined(Class['puppet::puppetlabs_apt']) {
|
||||
class { 'puppet::puppetlabs_apt': }
|
||||
require 'puppet::puppetlabs_apt'
|
||||
}
|
||||
|
||||
if $puppetqd {
|
||||
class { "activemq": ensure => $ensure }
|
||||
|
||||
package { "libnet-arp-perl": ensure => $ensure }
|
||||
|
||||
service { "stompserver":
|
||||
ensure => false,
|
||||
enable => false,
|
||||
before => Class["activemq"],
|
||||
}
|
||||
|
||||
service { "puppetqd":
|
||||
ensure => running,
|
||||
pattern => "puppet queue queue",
|
||||
enable => true,
|
||||
}
|
||||
}
|
||||
|
||||
if defined(Class['ganglia']) {
|
||||
Ganglia::Gmetric::Cron {
|
||||
source => "puppet/ganglia",
|
||||
ensure => "${ensure}",
|
||||
}
|
||||
|
||||
ganglia::gmetric::cron { "puppetmaster.rb": runwhen => "5", }
|
||||
|
||||
ganglia::gmetric::cron { "puppetmaster_compiletime.rb": runwhen => "60", }
|
||||
}
|
||||
|
||||
# ## remove disk reports from time to time
|
||||
tidy { "${puppet_vardir}/reports":
|
||||
age => "1d",
|
||||
recurse => true,
|
||||
backup => false,
|
||||
}
|
||||
|
||||
# create [private] directories
|
||||
# file { $puppet_privdir: ensure => directory }
|
||||
# Puppet::Puppetmaster::Privatedir <<| |>>
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export FACTERLIB="<%= scope.lookupvar("factpath") %>"
|
||||
PATH="/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
PUPPET=$(which puppet)
|
||||
[[ -e ${PUPPET} ]] || exit 1
|
||||
PUPPET="${PUPPET} agent"
|
||||
PUPPET="${PUPPET}"
|
||||
<% if run_if_ipmatch != "" -%>
|
||||
ISUNIIP=$(ifconfig |grep -c -e "<%= run_if_ipmatch %>")
|
||||
<% else -%>
|
||||
@@ -30,7 +30,7 @@ function cleanup {
|
||||
|
||||
if [ -e ${PIDF} ]; then
|
||||
PID=`cat ${PIDF}`
|
||||
if [ $(ps -eo pid |grep -c ${PID}) -gt 1 ]; then
|
||||
if [ $(ps -eo pid |grep -c ${PID}) -gt 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
@@ -66,7 +66,7 @@ if [ ${ISUNIIP} -gt 0 ]; then
|
||||
# wait maximally $MAXSLEEP seconds
|
||||
sleep $(expr ${SLEEP} % ${MAXSLEEP})
|
||||
# run puppetd
|
||||
nice -n 12 $PUPPET -t 2&>/var/log/puppet/puppetd_run.log
|
||||
nice -n 12 $PUPPET agent -t 2&>/var/log/puppet/puppetd_run.log
|
||||
fi
|
||||
fi
|
||||
# cleanup the pidfile
|
||||
|
||||
Reference in New Issue
Block a user