tons of updates

This commit is contained in:
John Bintz 2012-02-28 15:07:55 -05:00
parent 4c14b0865b
commit 2853d23d3a
10 changed files with 64 additions and 21 deletions

View File

@ -61,7 +61,7 @@ Capistrano::Configuration.instance.load do
desc "Rename the server" desc "Rename the server"
task :rename do task :rename do
hostname = fetch(:hostname) || Capistrano::CLI.ui.ask("Hostname: ") hostname = fetch(:hostname, nil) || Capistrano::CLI.ui.ask("Hostname: ")
top.copy_skel top.copy_skel
run "cd #{puppet_dir} && #{sudo} ./rename #{hostname}" run "cd #{puppet_dir} && #{sudo} ./rename #{hostname}"

View File

@ -4,14 +4,16 @@ class nginx-debian {
file { $log_root: file { $log_root:
owner => root, owner => root,
group => web, group => web,
mode => 2775 mode => 2775,
ensure => directory
} }
file { "$log_root/sites": file { "$log_root/sites":
owner => root, owner => root,
group => web, group => web,
mode => 2775, mode => 2775,
require => File[$log_root] require => File[$log_root],
ensure => directory
} }
$pid_file = pid_path('nginx') $pid_file = pid_path('nginx')

View File

@ -1,4 +1,4 @@
class nginx($version) { class nginx($version, $max_pool_size = 20) {
gem { 'passenger': gem { 'passenger':
version => $version, version => $version,
path => "${ruby::with_ruby_path}", path => "${ruby::with_ruby_path}",
@ -27,6 +27,7 @@ class nginx($version) {
god_init { $name: god_init { $name:
start => "${sbin_path}/nginx -c ${config_file}", start => "${sbin_path}/nginx -c ${config_file}",
stop => "${sbin_path}/nginx -s stop -c ${config_file}", stop => "${sbin_path}/nginx -s stop -c ${config_file}",
restart => "${sbin_path}/nginx -s reload -c ${config_file}",
pid_file => $pid_file, pid_file => $pid_file,
ensure => present, ensure => present,
notify => Service['god'], notify => Service['god'],
@ -50,17 +51,22 @@ class nginx($version) {
file { "${config_path}/fastcgi.conf": file { "${config_path}/fastcgi.conf":
content => template('nginx/fastcgi.conf'), content => template('nginx/fastcgi.conf'),
mode => 644,
require => File[$config_file] require => File[$config_file]
} }
file { "${config_path}/fastcgi_params": file { "${config_path}/fastcgi_params":
content => template('nginx/fastcgi_params'), content => template('nginx/fastcgi_params'),
mode => 644,
require => File[$config_file] require => File[$config_file]
} }
file { '/var/www': ensure => directory } file { '/var/www': ensure => directory }
file { $symlink_path: ensure => $install_path } file { $symlink_path:
ensure => $install_path,
require => Exec['install-passenger']
}
file { "${base::install_path}/bin/new-site": file { "${base::install_path}/bin/new-site":
content => template('nginx/new-site'), content => template('nginx/new-site'),

View File

@ -20,9 +20,7 @@ http {
access_log /var/log/nginx/access.log; access_log /var/log/nginx/access.log;
sendfile on; sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65; keepalive_timeout 65;
tcp_nodelay on; tcp_nodelay on;
@ -34,7 +32,8 @@ http {
passenger_root /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-<%= version %>; passenger_root /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-<%= version %>;
passenger_ruby /usr/local/ruby/bin/ruby; passenger_ruby /usr/local/ruby/bin/ruby;
passenger_max_pool_size 10; passenger_max_pool_size <%= max_pool_size %>;
passenger_max_instances_per_app 2;
include /etc/nginx/fastcgi.conf; include /etc/nginx/fastcgi.conf;
include /etc/nginx/sites-enabled/*; include /etc/nginx/sites-enabled/*;

View File

@ -1,10 +1,16 @@
class ruby-debian { class ruby-debian {
$packages = [ $packages = [
'libyaml-dev', 'libreadline-dev', 'libssl-dev', 'libffi-dev', 'libyaml-dev', 'libreadline-dev', 'libssl-dev', 'libffi-dev',
'libncurses5-dev', 'libcurl4-openssl-dev', 'libncurses5-dev', 'libcurl4-openssl-dev', 'zlib1g-dev',
'libxml2', 'libxml2-dev', 'libxslt1.1', 'libxslt1-dev' 'libxml2', 'libxml2-dev', 'libxslt1.1', 'libxslt1-dev'
] ]
package { $packages: ensure => installed } package { $packages: ensure => installed }
bash_rc_d { 'ruby':
ensure => present,
path => $base::local_path,
require => Build_and_install['ruby']
}
} }

View File

@ -5,7 +5,6 @@ class ruby($version) {
build_and_install { $name: build_and_install { $name:
version => $version, version => $version,
source => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-<%= version %>.tar.gz", source => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-<%= version %>.tar.gz",
require => Class['base']
} }
gem { 'bundler': gem { 'bundler':
@ -14,11 +13,5 @@ class ruby($version) {
options => '--pre', options => '--pre',
ensure => present ensure => present
} }
bash_rc_d { $name:
ensure => present,
path => $base::local_path,
require => Build_and_install[$name]
}
} }

View File

@ -4,7 +4,7 @@ Puppet::Type.type(:god_init).provide(:install) do
desc "Install a God script" desc "Install a God script"
def create def create
File.open(file, 'wb') { |fh| fh.print(ERB.new(config).result(binding)) } File.open(file, 'wb') { |fh| fh.print processed_config }
end end
def destroy def destroy
@ -12,7 +12,11 @@ Puppet::Type.type(:god_init).provide(:install) do
end end
def exists? def exists?
File.file? file File.file?(file) && File.read(file) == processed_config
end
def processed_config
ERB.new(config).result(binding)
end end
private private
@ -28,6 +32,10 @@ Puppet::Type.type(:god_init).provide(:install) do
@resource[:stop] || '' @resource[:stop] || ''
end end
def restart
@resource[:restart] || ''
end
def name def name
@resource[:name] || '' @resource[:name] || ''
end end
@ -40,14 +48,16 @@ Puppet::Type.type(:god_init).provide(:install) do
<<-GOD <<-GOD
God.watch do |w| God.watch do |w|
w.name = "<%= name %>" w.name = "<%= name %>"
w.interval = 15.seconds w.interval = 5.seconds
w.start = lambda { system("<%= start %>") } w.start = lambda { system("<%= start %>") }
w.start_grace = 10.seconds
<% if !stop.empty? %> <% if !stop.empty? %>
w.stop = lambda { system("<%= stop %>") } w.stop = lambda { system("<%= stop %>") }
w.stop_grace = 10.seconds <% end %>
<% if !restart.empty? %>
w.restart = lambda { system("<%= restart %>") }
<% end %> <% end %>
<% if pid_file %> <% if pid_file %>

View File

@ -15,6 +15,10 @@ Puppet::Type.newtype(:god_init) do
desc "The command to stop the process" desc "The command to stop the process"
end end
newparam(:restart) do
desc "The command to restart/reload the process"
end
newparam(:pid_file) do newparam(:pid_file) do
desc "A pid file" desc "A pid file"
end end

View File

@ -0,0 +1,6 @@
class flush_software {
file { "${base::install_path}/flush-software":
content => template('flush_software/flush-software'),
mode => 0775
}
}

View File

@ -0,0 +1,17 @@
#!/bin/bash
if [ -z $1 ]; then
echo "$0 <name of software>"
exit 1
fi
echo "Are you sure you want to remove '$1'? [yes/no]"
read answer
if [ $answer == 'yes' ]; then
rm -Rf <%= scope.lookupvar('base::install_path') %>/$1*
rm -Rf <%= scope.lookupvar('base::src_path') %>/$1*
echo "$1 purged"
fi