Created
February 20, 2009 20:43
-
-
Save KeithHanson/67684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@master:/etc/puppet/manifests/classes# cat poolparty.pp | |
class poolparty { | |
class varwww { | |
file { "custom": | |
name => 'custom' | |
} | |
} | |
include varwww | |
class heartbeat { | |
# Variables | |
$ha_nodenames = generate('/usr/bin/env', '/usr/bin/server-list-active', '-c', 'name', '-n', 'app') | |
$ha_node_ips = generate('/usr/bin/env', '/usr/bin/server-list-active', '-c', 'ip', '-n', 'app') | |
$ha_timeout = '5s' | |
$ha_port = '80' | |
file { "/etc/ha.d/ha.cf": | |
notify => Service['heartbeat'], | |
ensure => 'present', | |
mode => 444, | |
content => template("ha.cf"), | |
name => '/etc/ha.d/ha.cf' | |
} | |
file { "/etc/ha.d/logd.cf": | |
notify => Service['heartbeat'], | |
ensure => 'present', | |
mode => 600, | |
content => template("logd.cf"), | |
name => '/etc/ha.d/logd.cf' | |
} | |
file { "/etc/ha.d/authkeys": | |
notify => Service['heartbeat'], | |
ensure => 'present', | |
mode => 600, | |
content => template("authkeys"), | |
name => '/etc/ha.d/authkeys' | |
} | |
file { "/etc/ha.d/cib.xml": | |
notify => Exec['heartbeat-update-cib'], | |
ensure => 'present', | |
mode => 444, | |
content => template("cib.xml"), | |
name => '/etc/ha.d/cib.xml' | |
} | |
file { "/etc/ha.d/haresources": | |
ensure => 'present', | |
mode => 644, | |
content => template("haresources"), | |
name => '/etc/ha.d/haresources' | |
} | |
file { "/etc/ha.d": | |
ensure => 'directory', | |
mode => 644, | |
name => '/etc/ha.d' | |
} | |
service { "heartbeat": | |
ensure => 'running' | |
} | |
exec { "heartbeat-update-cib": | |
command => '/usr/sbin/cibadmin -R -x /etc/ha.d/cib.xml', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
refreshonly => true | |
} | |
package { "heartbeat": | |
ensure => 'installed' | |
} | |
} | |
include heartbeat | |
class haproxy { | |
# $hostnamemaster | |
case $hostname { | |
master : { | |
# Variables | |
$name_haproxy = 'app' | |
$nodenames_haproxy = generate('/usr/bin/env', '/usr/bin/server-list-active', '-c', 'name', '-n', 'app') | |
$node_ips_haproxy = generate('/usr/bin/env', '/usr/bin/server-list-active', '-c', 'ip', '-n', 'app') | |
$ports_haproxy = [ '80' ] | |
$forwarding_port = '8080' | |
$proxy_mode = 'http' | |
line { | |
'/etc/default/haproxy_line' : | |
file => '/etc/default/haproxy', | |
line => 'ENABLED=1', | |
ensure => 'present' | |
} | |
line { | |
'/etc/default/syslogd_line' : | |
file => '/etc/default/syslogd', | |
line => 'SYSLOGD="-r"', | |
ensure => 'present' | |
} | |
line { | |
'/etc/syslog.conf_line' : | |
file => '/etc/syslog.conf', | |
line => 'local0.* /var/log/haproxy.log', | |
notify => Service['sysklogd'], | |
ensure => 'present' | |
} | |
file { "/etc/haproxy.cfg": | |
notify => Service['haproxy'], | |
ensure => 'present', | |
require => Package['haproxy'], | |
mode => 644, | |
content => template("haproxy.conf"), | |
name => '/etc/haproxy.cfg' | |
} | |
package { "haproxy": | |
ensure => 'installed' | |
} | |
service { "sysklogd": | |
ensure => 'running', | |
name => 'sysklogd' | |
} | |
service { "haproxy": | |
notify => Exec['reloadhaproxy'], | |
ensure => 'running', | |
name => 'haproxy' | |
} | |
exec { "reloadhaproxy": | |
command => '/etc/init.d/haproxy reload', | |
require => Package['haproxy'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
} | |
default : {} | |
} | |
# $hostnamemaster | |
case $hostname { | |
master : { | |
# Variables | |
} | |
default : {} | |
} | |
} | |
include haproxy | |
class ruby { | |
line { | |
'/etc/profile_line' : | |
file => '/etc/profile', | |
line => 'export PATH=$PATH:/var/lib/gems/1.8/bin:/sbin', | |
ensure => 'present' | |
} | |
package { "libreadline-ruby1.8": | |
ensure => 'installed' | |
} | |
package { "libruby1.8": | |
ensure => 'installed' | |
} | |
package { "ruby1.8-dev": | |
ensure => 'installed' | |
} | |
package { "ruby1.8": | |
ensure => 'installed' | |
} | |
} | |
include ruby | |
class poolparty_base_packages { | |
# $hostnamemaster | |
case $hostname { | |
master : { | |
cron { "ensure puppetmaster is running": | |
ensure => 'present', | |
command => '. /etc/profile && puppetmasterd --verbose', | |
hour => '1', | |
name => 'ensure puppetmaster is running' | |
} | |
exec { "update_hosts": | |
command => '. /etc/profile && server-update-hosts -n app', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
exec { "Handle load": | |
command => '. /etc/profile && cloud-handle-load -n app', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
exec { "Ensure provisioning": | |
command => '. /etc/profile && server-ensure-provisioning -n app', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
exec { "start master messenger": | |
command => '. /etc/profile && server-start-master', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
exec { "start client server": | |
command => '. /etc/profile && server-start-client', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
exec { "Maintain the cloud": | |
command => '. /etc/profile && cloud-maintain -n app', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
} | |
default : {} | |
} | |
# $hostnamemaster | |
case $hostname { | |
master : { | |
} | |
default : {} | |
} | |
file { "/usr/bin/puppetrunner": | |
ensure => 'present', | |
mode => 744, | |
content => template("puppetrunner"), | |
name => '/usr/bin/puppetrunner' | |
} | |
file { "/usr/bin/puppetrerun": | |
ensure => 'present', | |
mode => 744, | |
content => template("puppetrerun"), | |
name => '/usr/bin/puppetrerun' | |
} | |
file { "/usr/bin/puppetcleaner": | |
ensure => 'present', | |
mode => 744, | |
content => template("puppetcleaner"), | |
name => '/usr/bin/puppetcleaner' | |
} | |
cron { "Run the provisioner": | |
ensure => 'present', | |
command => '/usr/bin/puppetrunner', | |
minute => '*/15', | |
name => 'Run the provisioner' | |
} | |
package { "erlang": | |
ensure => 'installed' | |
} | |
package { "erlang-dev": | |
ensure => 'installed' | |
} | |
package { "erlang-src": | |
ensure => 'installed' | |
} | |
# flexmock | |
case $hostname { | |
master : { | |
exec { "download-flexmock": | |
command => 'wget http://rubyforge.org/frs/download.php/42580/flexmock-0.8.3.gem -O flexmock.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/flexmock.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/flexmock.gem": | |
mode => 644, | |
source => 'puppet://master/files/flexmock.gem' | |
} | |
exec { "flexmock": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/flexmock.gem', | |
require => File['/var/poolparty/flexmock.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local flexmock | grep flexmock ' | |
} | |
# lockfile | |
case $hostname { | |
master : { | |
exec { "download-lockfile": | |
command => 'wget http://rubyforge.org/frs/download.php/18698/lockfile-1.4.3.gem -O lockfile.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/lockfile.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/lockfile.gem": | |
mode => 644, | |
source => 'puppet://master/files/lockfile.gem' | |
} | |
exec { "lockfile": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/lockfile.gem', | |
require => File['/var/poolparty/lockfile.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local lockfile | grep lockfile ' | |
} | |
# logging | |
case $hostname { | |
master : { | |
exec { "download-logging": | |
command => 'wget http://rubyforge.org/frs/download.php/44731/logging-0.9.4.gem -O logging.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/logging.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/logging.gem": | |
mode => 644, | |
source => 'puppet://master/files/logging.gem' | |
} | |
exec { "logging": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/logging.gem', | |
require => [ Exec['flexmock'], Exec['lockfile'], File['/var/poolparty/logging.gem'] ], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local logging | grep logging ' | |
} | |
# rubyforge | |
case $hostname { | |
master : { | |
exec { "download-rubyforge": | |
command => 'wget http://rubyforge.org/frs/download.php/45546/rubyforge-1.0.1.gem -O rubyforge.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/rubyforge.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/rubyforge.gem": | |
mode => 644, | |
source => 'puppet://master/files/rubyforge.gem' | |
} | |
exec { "rubyforge": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/rubyforge.gem', | |
require => File['/var/poolparty/rubyforge.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local rubyforge | grep rubyforge ' | |
} | |
# hoe | |
case $hostname { | |
master : { | |
exec { "download-hoe": | |
command => 'wget http://rubyforge.org/frs/download.php/45685/hoe-1.8.2.gem -O hoe.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/hoe.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/hoe.gem": | |
mode => 644, | |
source => 'puppet://master/files/hoe.gem' | |
} | |
exec { "hoe": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/hoe.gem', | |
require => [ Exec['rubyforge'], File['/var/poolparty/hoe.gem'] ], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local hoe | grep hoe | grep 1.8' | |
} | |
# ZenTest | |
case $hostname { | |
master : { | |
exec { "download-ZenTest": | |
command => 'wget http://rubyforge.org/frs/download.php/45581/ZenTest-3.11.0.gem -O ZenTest.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/ZenTest.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/ZenTest.gem": | |
mode => 644, | |
source => 'puppet://master/files/ZenTest.gem' | |
} | |
exec { "ZenTest": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/ZenTest.gem', | |
require => [ Exec['hoe'], Exec['rubyforge'], File['/var/poolparty/ZenTest.gem'] ], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local ZenTest | grep ZenTest ' | |
} | |
# rake | |
case $hostname { | |
master : { | |
exec { "download-rake": | |
command => 'wget http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem -O rake.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/rake.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/rake.gem": | |
mode => 644, | |
source => 'puppet://master/files/rake.gem' | |
} | |
exec { "rake": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/rake.gem', | |
require => File['/var/poolparty/rake.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local rake | grep rake ' | |
} | |
# xmlsimple | |
case $hostname { | |
master : { | |
exec { "download-xml-simple": | |
command => 'wget http://rubyforge.org/frs/download.php/18366/xml-simple-1.0.11.gem -O xml-simple.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/xml-simple.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/xml-simple.gem": | |
mode => 644, | |
source => 'puppet://master/files/xml-simple.gem' | |
} | |
exec { "xml-simple": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/xml-simple.gem', | |
require => File['/var/poolparty/xml-simple.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local xml-simple | grep xml-simple ' | |
} | |
# amazonec2 | |
case $hostname { | |
master : { | |
exec { "download-amazon-ec2": | |
command => 'wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/amazon-ec2.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/amazon-ec2.gem": | |
mode => 644, | |
source => 'puppet://master/files/amazon-ec2.gem' | |
} | |
exec { "amazon-ec2": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/amazon-ec2.gem', | |
require => [ Exec['xml-simple'], File['/var/poolparty/amazon-ec2.gem'] ], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local amazon-ec2 | grep amazon-ec2 ' | |
} | |
# sexp_processor | |
case $hostname { | |
master : { | |
exec { "download-sexp_processor": | |
command => 'wget http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem -O sexp_processor.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/sexp_processor.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/sexp_processor.gem": | |
mode => 644, | |
source => 'puppet://master/files/sexp_processor.gem' | |
} | |
exec { "sexp_processor": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/sexp_processor.gem', | |
require => File['/var/poolparty/sexp_processor.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local sexp_processor | grep sexp_processor ' | |
} | |
# netssh | |
case $hostname { | |
master : { | |
exec { "download-net-ssh": | |
command => 'wget http://rubyforge.org/frs/download.php/51288/net-ssh-2.0.10.gem -O net-ssh.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/net-ssh.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/net-ssh.gem": | |
mode => 644, | |
source => 'puppet://master/files/net-ssh.gem' | |
} | |
exec { "net-ssh": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/net-ssh.gem', | |
require => File['/var/poolparty/net-ssh.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local net-ssh | grep net-ssh | grep 2.0.10' | |
} | |
# netsftp | |
case $hostname { | |
master : { | |
exec { "download-net-sftp": | |
command => 'wget http://rubyforge.org/frs/download.php/37669/net-sftp-2.0.1.gem -O net-sftp.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/net-sftp.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/net-sftp.gem": | |
mode => 644, | |
source => 'puppet://master/files/net-sftp.gem' | |
} | |
exec { "net-sftp": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/net-sftp.gem', | |
require => File['/var/poolparty/net-sftp.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local net-sftp | grep net-sftp ' | |
} | |
# netscp | |
case $hostname { | |
master : { | |
exec { "download-net-scp": | |
command => 'wget http://rubyforge.org/frs/download.php/37664/net-scp-1.0.1.gem -O net-scp.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/net-scp.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/net-scp.gem": | |
mode => 644, | |
source => 'puppet://master/files/net-scp.gem' | |
} | |
exec { "net-scp": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/net-scp.gem', | |
require => File['/var/poolparty/net-scp.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local net-scp | grep net-scp ' | |
} | |
# netsshgateway | |
case $hostname { | |
master : { | |
exec { "download-net-ssh-gateway": | |
command => 'wget http://rubyforge.org/frs/download.php/36389/net-ssh-gateway-1.0.0.gem -O net-ssh-gateway.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/net-ssh-gateway.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/net-ssh-gateway.gem": | |
mode => 644, | |
source => 'puppet://master/files/net-ssh-gateway.gem' | |
} | |
exec { "net-ssh-gateway": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/net-ssh-gateway.gem', | |
require => File['/var/poolparty/net-ssh-gateway.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local net-ssh-gateway | grep net-ssh-gateway ' | |
} | |
# highline | |
case $hostname { | |
master : { | |
exec { "download-highline": | |
command => 'wget http://rubyforge.org/frs/download.php/46328/highline-1.5.0.gem -O highline.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/highline.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/highline.gem": | |
mode => 644, | |
source => 'puppet://master/files/highline.gem' | |
} | |
exec { "highline": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/highline.gem', | |
require => File['/var/poolparty/highline.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local highline | grep highline ' | |
} | |
exec { "capistrano": | |
command => 'gem install --no-ri --no-rdoc capistrano', | |
require => [ Exec['highline'] ], | |
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin', | |
cwd => '/tmp', | |
unless => 'gem list --local capistrano | grep capistrano ' | |
} | |
# ParseTree | |
case $hostname { | |
master : { | |
exec { "download-ParseTree": | |
command => 'wget http://rubyforge.org/frs/download.php/45600/ParseTree-3.0.1.gem -O ParseTree.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/ParseTree.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/ParseTree.gem": | |
mode => 644, | |
source => 'puppet://master/files/ParseTree.gem' | |
} | |
exec { "ParseTree": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/ParseTree.gem', | |
require => [ Exec['sexp_processor'], Exec['ZenTest'], File['/var/poolparty/ParseTree.gem'] ], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local ParseTree | grep ParseTree ' | |
} | |
# ruby2ruby | |
case $hostname { | |
master : { | |
exec { "download-ruby2ruby": | |
command => 'wget http://rubyforge.org/frs/download.php/45587/ruby2ruby-1.2.0.gem -O ruby2ruby.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/ruby2ruby.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/ruby2ruby.gem": | |
mode => 644, | |
source => 'puppet://master/files/ruby2ruby.gem' | |
} | |
exec { "ruby2ruby": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/ruby2ruby.gem', | |
require => [ Exec['ParseTree'], File['/var/poolparty/ruby2ruby.gem'] ], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local ruby2ruby | grep ruby2ruby ' | |
} | |
# activesupport | |
case $hostname { | |
master : { | |
exec { "download-activesupport": | |
command => 'wget http://rubyforge.org/frs/download.php/45627/activesupport-2.1.2.gem -O activesupport.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/activesupport.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/activesupport.gem": | |
mode => 644, | |
source => 'puppet://master/files/activesupport.gem' | |
} | |
exec { "activesupport": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/activesupport.gem', | |
require => File['/var/poolparty/activesupport.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local activesupport | grep activesupport ' | |
} | |
# RubyInline | |
case $hostname { | |
master : { | |
exec { "download-RubyInline": | |
command => 'wget http://rubyforge.org/frs/download.php/45683/RubyInline-3.8.1.gem -O RubyInline.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/RubyInline.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/RubyInline.gem": | |
mode => 644, | |
source => 'puppet://master/files/RubyInline.gem' | |
} | |
exec { "RubyInline": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/RubyInline.gem', | |
require => File['/var/poolparty/RubyInline.gem'], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local RubyInline | grep RubyInline ' | |
} | |
# poolparty | |
case $hostname { | |
master : { | |
exec { "download-poolparty": | |
command => 'wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty.gem?raw=true -O poolparty.gem', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
unless => 'test -f /var/poolparty/poolparty.gem', | |
cwd => '/var/poolparty' | |
} | |
} | |
default : {} | |
} | |
file { "/var/poolparty/poolparty.gem": | |
mode => 644, | |
source => 'puppet://master/files/poolparty.gem' | |
} | |
exec { "poolparty": | |
command => 'gem install --no-ri --no-rdoc /var/poolparty/poolparty.gem', | |
require => [ Exec['ruby2ruby'], Exec['RubyInline'], Exec['ParseTree'], File['/var/poolparty/poolparty.gem'] ], | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH', | |
cwd => '/var/poolparty', | |
unless => 'gem list --local poolparty | grep poolparty ' | |
} | |
package { "rubygems": | |
ensure => 'installed' | |
} | |
exec { "build_messenger": | |
command => '. /etc/profile && server-build-messenger', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
exec { "start_node": | |
command => '. /etc/profile && server-start-node', | |
path => '/usr/bin:/bin:/usr/local/bin:$PATH' | |
} | |
} | |
include poolparty_base_packages | |
class user { | |
file { "/var/www/": | |
ensure => 'directory', | |
mode => 644, | |
name => '/var/www/' | |
} | |
} | |
include user | |
# Custom functions | |
define line($file, $line, $ensure = 'present', $notify=[]) { | |
case $ensure { | |
default: { err ( "unknown ensure value ${ensure}" ) } | |
present: { | |
exec { | |
"/usr/bin/env echo '${line}' >> '${file}'": unless => "/usr/bin/env grep -qFx '${line}' '${file}'", | |
notify => $notify | |
} | |
} | |
absent: { | |
exec { | |
"/usr/bin/env sed -i '' -e '/^${line}$/d' '${file}'": onlyif => "/usr/bin/env grep -qFx '${line}' '${file}'", | |
notify => $notify | |
} | |
} | |
} | |
} | |
define append_if_no_such_line($file, $line, $refreshonly = 'false') { | |
exec { "/bin/echo '$line' >> '$file'": | |
unless => "/bin/grep -Fxqe '$line' '$file'", | |
path => "/bin", | |
refreshonly => $refreshonly, | |
} | |
} | |
define delete_lines($file, $pattern) { | |
exec { "sed -i -r -e '/$pattern/d' $file": | |
path => "/bin", | |
onlyif => "/bin/grep -E '$pattern' '$file'", | |
} | |
} | |
define runit_service ($directory = "/etc/sv", $downif = "/bin/false", $templatedir) { | |
file { "$directory-$name": | |
path => "$directory/$name", | |
ensure => directory, | |
owner => root, | |
group => root, | |
mode => 0755, | |
require => Class["runit"] | |
} | |
file { "$directory/$name/log": | |
ensure => directory, | |
owner => root, | |
group => root, | |
mode => 0755, | |
require => File["$directory-$name"] | |
} | |
file { "$directory/$name/log/main": | |
ensure => directory, | |
owner => root, | |
group => root, | |
mode => 0755, | |
require => File["$directory/$name/log"] | |
} | |
file { "/etc/init.d/$name": | |
ensure => $lsbdistid ? { | |
'CentOS' => "/usr/local/bin/sv", | |
default => "/usr/bin/sv", | |
}, | |
require => [ File["$directory/$name/run"], File["$directory/$name/log/run"] ] | |
} | |
file { "/var/service/$name": | |
ensure => "$directory/$name", | |
require => [ File["$directory-$name"], File["$directory/$name/run"], File["$directory/$name/log/run"] ] | |
} | |
file { "$directory/$name/log/run": | |
content => template("$templatedir/log-run.erb"), | |
owner => root, | |
group => root, | |
mode => 755, | |
require => File["$directory/$name/log"], | |
notify => Service[$name] | |
} | |
file { "$directory/$name/run": | |
content => template("$templatedir/run.erb"), | |
owner => root, | |
group => root, | |
mode => 755, | |
require => File["$directory-$name"], | |
notify => Service[$name] | |
} | |
service { "$name": | |
hasrestart => true, | |
hasstatus => true, | |
require => File["/etc/init.d/$name"] | |
} | |
exec { "$name-down": | |
command => "/etc/init.d/$name down", | |
onlyif => $downif, | |
require => File["/etc/init.d/$name"] | |
} | |
} | |
# Serve subversion-based code from a local location. The job of this | |
# module is to check the data out from subversion and keep it up to | |
# date, especially useful for providing data to your Puppet server. | |
define svnserve($source, $path, $user = false, $password = false) { | |
file { $path: | |
ensure => directory, | |
owner => root, | |
group => root | |
} | |
$svncmd = $user ? { | |
false => "/usr/bin/svn co --non-interactive $source/$name .", | |
default => "/usr/bin/svn co --non-interactive --username $user --password '$password' $source/$name ." | |
} | |
exec { "svnco-$name": | |
command => $svncmd, | |
cwd => $path, | |
require => File[$path], | |
creates => "$path/.svn" | |
} | |
exec { "svnupdate-$name": | |
command => "/usr/bin/svn update", | |
require => Exec["svnco-$name"], | |
onlyif => '/usr/bin/svn status -u --non-interactive | /bin/grep "*"', | |
cwd => $path | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment