additional module support, common things I use everywhere
This commit is contained in:
parent
7ee98959d6
commit
74e3fd9db1
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
.bundle
|
||||
Gemfile.lock
|
||||
pkg/*
|
||||
.DS_Store
|
||||
|
@ -16,6 +16,7 @@ Capistrano::Configuration.instance.load do
|
||||
_cset(:base_dir) { '/usr/local' }
|
||||
_cset(:rename_server) { true }
|
||||
_cset(:use_sudo) { true }
|
||||
_cset(:additional_modules) { [] }
|
||||
|
||||
@dir_made = false
|
||||
|
||||
@ -83,7 +84,11 @@ Capistrano::Configuration.instance.load do
|
||||
task :copy_shared do
|
||||
top.ensure_puppet_dir
|
||||
|
||||
top.upload PuppetStandaloneMashup::BASE.join('shared').to_s, File.join(puppet_dir, 'shared')
|
||||
run "mkdir -p #{puppet_dir}/shared/additional-modules"
|
||||
|
||||
(%w{lib modules} + additional_modules.collect { |dir| "additional-modules/#{dir}" }).each do |dir|
|
||||
top.upload PuppetStandaloneMashup::BASE.join('shared', dir).to_s, File.join(puppet_dir, 'shared', dir)
|
||||
end
|
||||
end
|
||||
|
||||
desc "Ensure Puppet target dir exists"
|
||||
|
34
shared/additional-modules/god/manifests/init.pp
Normal file
34
shared/additional-modules/god/manifests/init.pp
Normal file
@ -0,0 +1,34 @@
|
||||
class god {
|
||||
gem { 'god':
|
||||
path => "${ruby::path}:${base::path}",
|
||||
ensure => present,
|
||||
require => Make_and_install['ruby']
|
||||
}
|
||||
|
||||
$god_bin = "${base::install_path}/ruby/bin/god"
|
||||
$god_dir = "${base::config_path}/god.d"
|
||||
$pid_path = pid_path($name)
|
||||
|
||||
file { '/etc/init.d/god':
|
||||
content => template('god/god-init.d'),
|
||||
mode => 755
|
||||
}
|
||||
|
||||
file { $god_dir:
|
||||
ensure => directory
|
||||
}
|
||||
|
||||
update_rc_d_defaults { $name:
|
||||
require => File['/etc/init.d/god']
|
||||
}
|
||||
|
||||
running_service { $name:
|
||||
require => Update_rc_d_defaults[$name]
|
||||
}
|
||||
|
||||
file { '/usr/local/sbin/resurrect':
|
||||
content => template('god/resurrect'),
|
||||
mode => 755
|
||||
}
|
||||
}
|
||||
|
76
shared/additional-modules/god/templates/god-init.d
Normal file
76
shared/additional-modules/god/templates/god-init.d
Normal file
@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: god
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: God
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/local/ruby/bin:<%= scope.lookupvar('base::path') %>
|
||||
NAME=god
|
||||
DESC=god
|
||||
|
||||
set -e
|
||||
|
||||
# Make sure the binary and the config file are present before proceeding
|
||||
test -x <%= god_bin %> || exit 0
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
RETVAL=0
|
||||
|
||||
PID_PATH=<%= pid_path %>
|
||||
|
||||
start() {
|
||||
echo -n "Starting $DESC: "
|
||||
rm -f $PID_PATH
|
||||
<%= god_bin %> -P $PID_PATH -l /var/log/god.log
|
||||
RETVAL=$?
|
||||
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
sleep 2
|
||||
if [ -d <%= god_dir %> ]; then
|
||||
for file in $(find <%= god_dir %> -name "*.god"); do
|
||||
echo "god: loading $file ..."
|
||||
<%= god_bin %> load $file
|
||||
done
|
||||
fi
|
||||
fi
|
||||
echo "$NAME."
|
||||
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n "Stopping $DESC: "
|
||||
kill `cat $PID_PATH`
|
||||
RETVAL=$?
|
||||
echo "$NAME."
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
<%= god_bin %> status
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: god {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
8
shared/additional-modules/god/templates/resurrect
Normal file
8
shared/additional-modules/god/templates/resurrect
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
sudo killall god
|
||||
sudo killall nginx
|
||||
sudo killall thin
|
||||
sudo killall php5-fpm
|
||||
sudo service god start
|
||||
|
23
shared/additional-modules/ruby/manifests/init.pp
Normal file
23
shared/additional-modules/ruby/manifests/init.pp
Normal file
@ -0,0 +1,23 @@
|
||||
class ruby($version) {
|
||||
$path = bin_path($name)
|
||||
$with_ruby_path = "${path}:${base::path}"
|
||||
|
||||
build_and_install { $name:
|
||||
version => $version,
|
||||
source => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-<%= version %>.tar.gz",
|
||||
require => Class['base']
|
||||
}
|
||||
|
||||
gem { 'bundler':
|
||||
require => Build_and_install[$name],
|
||||
path => $with_ruby_path,
|
||||
ensure => present
|
||||
}
|
||||
|
||||
bash_rc_d { $name:
|
||||
ensure => present,
|
||||
path => $base::local_path,
|
||||
require => Build_and_install[$name]
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p ~/.puppet
|
||||
<%= use_sudo ? "sudo env" : "" %> RUBYLIB="${PWD}/shared/lib" <%= with_additional_puppet_bin_path %> puppet apply --confdir=$PWD --modulepath=$PWD/modules:$PWD/shared/modules --templatedir=$PWD/templates -v $@ manifests/site.pp
|
||||
<%= use_sudo ? "sudo env" : "" %> RUBYLIB="${PWD}/shared/lib" <%= with_additional_puppet_bin_path %> puppet apply --confdir=$PWD --modulepath=$PWD/modules:$PWD/shared/modules:$PWD/shared/additional-modules --templatedir=$PWD/templates -v $@ manifests/site.pp
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user