Compare commits
20 Commits
pre-new-st
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
2e2e94ddef | ||
|
2cc210c520 | ||
|
2d5cfed24a | ||
|
882ec74fe0 | ||
|
c615943cc0 | ||
|
ff3fffc206 | ||
|
885c685e1a | ||
|
5d8aefeee3 | ||
|
00e10a4b96 | ||
|
b9231ec890 | ||
|
0f0a081177 | ||
|
a3dcdbcece | ||
|
63a75fdb36 | ||
|
9d66fe8943 | ||
|
0ac18b0e94 | ||
|
5a3cd42244 | ||
|
cf5170fbb1 | ||
|
dc101f527b | ||
|
5ef3806a32 | ||
|
9b33e9dd17 |
@ -2,7 +2,7 @@ class basics {
|
|||||||
$packages = [
|
$packages = [
|
||||||
"ntp", "ntpdate", "gcc", "curl",
|
"ntp", "ntpdate", "gcc", "curl",
|
||||||
"build-essential", "patch", 'sysstat',
|
"build-essential", "patch", 'sysstat',
|
||||||
'git-core', 'vim'
|
'git-core', 'vim', 'libffi5'
|
||||||
]
|
]
|
||||||
|
|
||||||
package { $packages: ensure => installed }
|
package { $packages: ensure => installed }
|
10
additional-modules/debian/manifests/init.pp
Normal file
10
additional-modules/debian/manifests/init.pp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
class debian {
|
||||||
|
$varnish_apt_source = "deb http://repo.varnish-cache.org/debian/ squeeze varnish-3.0"
|
||||||
|
$varnish_keyfile = "http://repo.varnish-cache.org/debian/GPG-key.txt"
|
||||||
|
$varnish_hash = "C4DEFFEB"
|
||||||
|
|
||||||
|
$mongo_apt_source = "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen"
|
||||||
|
$mongo_host = "keyserver.ubuntu.com"
|
||||||
|
$mongo_hash = "7F0CEB10"
|
||||||
|
}
|
||||||
|
|
@ -2,10 +2,10 @@ class god {
|
|||||||
gem { 'god':
|
gem { 'god':
|
||||||
path => "${ruby::path}:${base::path}",
|
path => "${ruby::path}:${base::path}",
|
||||||
ensure => present,
|
ensure => present,
|
||||||
require => Make_and_install['ruby']
|
require => Class['ruby']
|
||||||
}
|
}
|
||||||
|
|
||||||
$bin = "${base::install_path}/ruby/bin/god"
|
$bin = "${ruby::path}/god"
|
||||||
$dir = config_path("god.d")
|
$dir = config_path("god.d")
|
||||||
$pid = pid_path($name)
|
$pid = pid_path($name)
|
||||||
$log = log_path($name)
|
$log = log_path($name)
|
23
additional-modules/ruby/manifests/falcon.pp
Normal file
23
additional-modules/ruby/manifests/falcon.pp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
class ruby::falcon($version, $configure, $build_path) {
|
||||||
|
class { ruby:
|
||||||
|
version => $version,
|
||||||
|
configure => $configure,
|
||||||
|
build_path => $build_path
|
||||||
|
}
|
||||||
|
|
||||||
|
file { '/tmp/ruby-falcon-patch.sh':
|
||||||
|
content => template('ruby/falcon-patch.sh'),
|
||||||
|
before => Configure['ruby'],
|
||||||
|
mode => 755
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { 'patch-ruby':
|
||||||
|
command => "ruby-falcon-patch.sh",
|
||||||
|
before => Configure['ruby'],
|
||||||
|
cwd => build_path('ruby', $version),
|
||||||
|
unless => 'test -f patched',
|
||||||
|
logoutput => true,
|
||||||
|
path => "/tmp:$base::path"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
49
additional-modules/ruby/manifests/init.pp
Normal file
49
additional-modules/ruby/manifests/init.pp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
class ruby($version = '', $deb_url = '', $configure = "--disable-install-doc", $build_path = '') {
|
||||||
|
gem { [ 'bundler', 'penchant' ]:
|
||||||
|
path => "${path}:${base::path}",
|
||||||
|
ensure => present
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($::osfamily == 'debian') {
|
||||||
|
$path = '/usr/bin'
|
||||||
|
|
||||||
|
remotedeb { ruby:
|
||||||
|
url => $deb_url,
|
||||||
|
version => $version
|
||||||
|
}
|
||||||
|
|
||||||
|
Remotedeb[ruby] -> Gem['bundler', 'penchant']
|
||||||
|
} else {
|
||||||
|
$path = bin_path($name)
|
||||||
|
|
||||||
|
build_and_install { $name:
|
||||||
|
version => $version,
|
||||||
|
source => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-<%= version %>.tar.gz",
|
||||||
|
configure => $configure,
|
||||||
|
preconfigure => "LDFLAGS='-rdynamic -Wl,-export-dynamic'",
|
||||||
|
path => $build_path
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($osfamily == 'debian') {
|
||||||
|
$packages = [
|
||||||
|
'libyaml-dev', 'libreadline-dev', 'libssl-dev', 'libffi-dev',
|
||||||
|
'libncurses5-dev', 'libcurl4-openssl-dev', 'zlib1g-dev',
|
||||||
|
'libxml2', 'libxml2-dev', 'libxslt1.1', 'libxslt1-dev'
|
||||||
|
]
|
||||||
|
|
||||||
|
package { $packages:
|
||||||
|
ensure => installed,
|
||||||
|
before => Build_and_install[$name]
|
||||||
|
}
|
||||||
|
|
||||||
|
bash_rc_d { 'ruby':
|
||||||
|
ensure => present,
|
||||||
|
path => $base::local_path,
|
||||||
|
require => Build_and_install[$name]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Build_and_install[ruby] -> Gem['bundler', 'penchant']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
10
additional-modules/ruby/templates/falcon-patch.sh
Normal file
10
additional-modules/ruby/templates/falcon-patch.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
curl https://raw.github.com/gist/2593385/perf_and_gc.diff | patch -p1
|
||||||
|
if [ $? -ne 0 ]; then exit 1; fi
|
||||||
|
|
||||||
|
curl https://raw.github.com/gist/2502451/46c9fbc07abf7ea5670ba0e23a11ff93d6e3c9db/yaml.rb.diff | patch -p1
|
||||||
|
if [ $? -ne 0 ]; then exit 1; fi
|
||||||
|
|
||||||
|
touch patched
|
||||||
|
|
@ -23,10 +23,5 @@ class squid::debian($version, $config_template, $error_template) {
|
|||||||
path => $base::path,
|
path => $base::path,
|
||||||
require => Class['squid']
|
require => Class['squid']
|
||||||
}
|
}
|
||||||
|
|
||||||
logrotate_d { 'squid':
|
|
||||||
postrotate => 'service squid rotate',
|
|
||||||
pattern => "${squid::log_dir}/access.log"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
98
additional-modules/squid/manifests/init.pp
Normal file
98
additional-modules/squid/manifests/init.pp
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
class squid($version = '', $user = 'proxy', $group = 'proxy', $config_template, $error_template) {
|
||||||
|
if ($::osfamily == 'debian') {
|
||||||
|
$cache_dir = '/var/spool/squid3'
|
||||||
|
$config_dir = "/etc/squid3"
|
||||||
|
$config = "${config_dir}/squid.conf"
|
||||||
|
$log_dir = "/var/log/squid3"
|
||||||
|
$sbin = '/usr/sbin'
|
||||||
|
|
||||||
|
package { 'squid3': ensure => latest }
|
||||||
|
package { 'squidclient': ensure => latest }
|
||||||
|
|
||||||
|
service { squid3:
|
||||||
|
ensure => stopped,
|
||||||
|
require => Package[squid3]
|
||||||
|
}
|
||||||
|
|
||||||
|
Package['squid3'] -> File[$config]
|
||||||
|
Package['squid3'] -> Exec['stop-squid-for-good'] -> Exec['squid-cache']
|
||||||
|
|
||||||
|
exec { 'stop-squid-for-good':
|
||||||
|
command => 'service squid3 stop ; update-rc.d -f squid3 remove',
|
||||||
|
path => $::base::path
|
||||||
|
}
|
||||||
|
|
||||||
|
logrotate_d { 'squid3':
|
||||||
|
postrotate => 'god signal squid HUP',
|
||||||
|
pattern => "${log_dir}/access.log"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$bin = bin_path($name)
|
||||||
|
$sbin = sbin_path($name)
|
||||||
|
|
||||||
|
$build_dir = build_path($name, $version)
|
||||||
|
$log_dir = log_path($name)
|
||||||
|
$pid = pid_path($name)
|
||||||
|
$cache_dir = data_path($name)
|
||||||
|
$config_dir = config_path($name)
|
||||||
|
$config = "${config_dir}/squid.conf"
|
||||||
|
|
||||||
|
build_and_install { $name:
|
||||||
|
version => $version,
|
||||||
|
source => "http://www.squid-cache.org/Versions/v3/3.1/squid-${version}.tar.bz2",
|
||||||
|
configure => template('squid/configure'),
|
||||||
|
preconfigure => template('squid/preconfigure')
|
||||||
|
}
|
||||||
|
|
||||||
|
Build_and_install[$name] -> File[$config]
|
||||||
|
Build_and_install[$name] -> Exec[cache_dir_perms]
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir_p { [ $log_dir, $cache_dir, $config_dir ]:
|
||||||
|
path => $base::path
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { log_dir_params:
|
||||||
|
command => "chown -R ${user}:${group} ${log_dir}",
|
||||||
|
path => $::base::path,
|
||||||
|
require => Mkdir_p[$log_dir]
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { 'cache_dir_perms':
|
||||||
|
command => "chown -R ${user}:${group} ${cache_dir}",
|
||||||
|
path => $::base::path,
|
||||||
|
require => Mkdir_p[$cache_dir]
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { 'squid-cache':
|
||||||
|
command => "${sbin}/squid3 -z",
|
||||||
|
logoutput => true,
|
||||||
|
require => Exec[cache_dir_perms, log_dir_params],
|
||||||
|
unless => "test -d ${cache_dir}/00",
|
||||||
|
path => $::base::path
|
||||||
|
}
|
||||||
|
|
||||||
|
file { "${sbin}/clear-squid-cache":
|
||||||
|
content => template('squid/clear-squid-cache'),
|
||||||
|
mode => 0755
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { 'cache_dir_perms_again':
|
||||||
|
command => "chown -R ${user}:${group} ${cache_dir}",
|
||||||
|
path => $::base::path,
|
||||||
|
require => Exec['squid-cache']
|
||||||
|
}
|
||||||
|
|
||||||
|
file { $config:
|
||||||
|
content => template($config_template)
|
||||||
|
}
|
||||||
|
|
||||||
|
god_init { $name:
|
||||||
|
start => "${sbin}/squid3 -YC -f ${config} -N -a 80",
|
||||||
|
dir => config_path('god.d'),
|
||||||
|
ensure => present,
|
||||||
|
require => File[$config],
|
||||||
|
interval => 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
20
additional-modules/squid/templates/clear-squid-cache
Normal file
20
additional-modules/squid/templates/clear-squid-cache
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
target="<%= @cache_dir %>$(date +%Y%m%d%H%M%S)"
|
||||||
|
|
||||||
|
if [ $UID -ne 0 ]; then
|
||||||
|
sudo $0
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
god stop squid
|
||||||
|
while [ "$(pgrep squid3 | wc -l)" -ne 0 ]; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
mv <%= @cache_dir %> "$target"
|
||||||
|
mkdir <%= @cache_dir %>
|
||||||
|
chown -R <%= @user %>:<%= @group %> <%= @cache_dir %>
|
||||||
|
squid3 -z
|
||||||
|
god start squid
|
||||||
|
rm -Rf "$target"
|
@ -1,4 +1,4 @@
|
|||||||
<%= scope.function_template('base/init-d-header') %>
|
<%= scope.function_template([ 'base/init-d-header' ]) %>
|
||||||
|
|
||||||
<%= init_d_prolog %>
|
<%= init_d_prolog %>
|
||||||
<%= init_d_prerun %>
|
<%= init_d_prerun %>
|
||||||
@ -19,5 +19,5 @@ stop() {
|
|||||||
echo "done"
|
echo "done"
|
||||||
}
|
}
|
||||||
|
|
||||||
<%= scope.function_template('base/init-d-actions') %>
|
<%= scope.function_template([ 'base/init-d-actions' ]) %>
|
||||||
|
|
110
additional-modules/varnish/manifests/init.pp
Normal file
110
additional-modules/varnish/manifests/init.pp
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
class varnish($version = '', $vcl, $user = 'varnish', $group = 'varnish') {
|
||||||
|
if ($::osfamily == 'debian') {
|
||||||
|
$config = '/etc/varnish'
|
||||||
|
|
||||||
|
$default_varnish = '/etc/default/varnish'
|
||||||
|
$bin = "/usr/sbin/varnishd"
|
||||||
|
} else {
|
||||||
|
$install_path = install_path($name, $version)
|
||||||
|
$config = config_path($name)
|
||||||
|
$share = share_path($name)
|
||||||
|
$data = data_path($name)
|
||||||
|
$sbin = sbin_path($name)
|
||||||
|
$bin_path = bin_path($name)
|
||||||
|
|
||||||
|
$bin = "${sbin}/${name}d"
|
||||||
|
$pid = pid_path($name)
|
||||||
|
$log = log_path($name)
|
||||||
|
|
||||||
|
$default_varnish = "${config}/defaults"
|
||||||
|
}
|
||||||
|
|
||||||
|
$vcl_path = "${config}/default.vcl"
|
||||||
|
|
||||||
|
if ($::osfamily == 'debian') {
|
||||||
|
debsource { varnish:
|
||||||
|
apt_source => $debian::varnish_apt_source,
|
||||||
|
keyfile => $debian::varnish_keyfile,
|
||||||
|
hash => $debian::varnish_hash
|
||||||
|
}
|
||||||
|
|
||||||
|
$cache_root = "/var/lib"
|
||||||
|
$cache_dir = "${cache_root}/varnish"
|
||||||
|
|
||||||
|
package { varnish:
|
||||||
|
ensure => latest,
|
||||||
|
require => [
|
||||||
|
Debsource['varnish'], Mkdir_p[$cache_dir]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
service { varnish:
|
||||||
|
ensure => stopped,
|
||||||
|
require => Package[varnish]
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { 'update-rc.d -f varnish remove':
|
||||||
|
path => $::base::path,
|
||||||
|
require => Package[varnish]
|
||||||
|
}
|
||||||
|
|
||||||
|
$store_file_size = dir_size($cache_root)
|
||||||
|
|
||||||
|
Package['varnish'] -> File[$default_varnish, $vcl_path]
|
||||||
|
} else {
|
||||||
|
$source = "http://repo.varnish-cache.org/source/varnish-${version}.tar.gz"
|
||||||
|
$dirs = [ $config, $log, $share, $data ]
|
||||||
|
|
||||||
|
$cache_dir = "${data}/store"
|
||||||
|
|
||||||
|
build_and_install { $name:
|
||||||
|
version => $version,
|
||||||
|
source => $source
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir_p { $dirs:
|
||||||
|
path => $base::path,
|
||||||
|
require => Build_and_install[$name]
|
||||||
|
}
|
||||||
|
|
||||||
|
init_d { $name:
|
||||||
|
require => Mkdir_p[$dirs]
|
||||||
|
}
|
||||||
|
|
||||||
|
Build_and_install['varnish'] -> File[$default_varnish, $vcl_path]
|
||||||
|
|
||||||
|
/*
|
||||||
|
$ncsa_bin = "${bin_path}/varnishncsa"
|
||||||
|
$ncsa_pid = pid_path('varnishncsa')
|
||||||
|
$ncsa_log = "${log}/access.log"
|
||||||
|
|
||||||
|
logrotate_d { 'varnishncsa':
|
||||||
|
postrotate => 'service varnish rotate',
|
||||||
|
pattern => "${log}/access.log"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
file { $default_varnish:
|
||||||
|
content => template("varnish/default"),
|
||||||
|
notify => Service['god']
|
||||||
|
}
|
||||||
|
|
||||||
|
file { $vcl_path:
|
||||||
|
content => $vcl,
|
||||||
|
notify => Service['god']
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir_p { $cache_dir:
|
||||||
|
path => $base::path
|
||||||
|
}
|
||||||
|
|
||||||
|
god_init { $name:
|
||||||
|
start => "${bin} -T 127.0.0.1:6082 -F -u ${user} -g ${group} -w 1,1,3600 -f ${vcl_path} -s file,${cache_dir}/varnish",
|
||||||
|
dir => config_path('god.d'),
|
||||||
|
ensure => present,
|
||||||
|
require => File[$vcl_path],
|
||||||
|
interval => 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
12
additional-modules/varnish/templates/default
Normal file
12
additional-modules/varnish/templates/default
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
START=1
|
||||||
|
|
||||||
|
DAEMON_OPTS=" \
|
||||||
|
-a :80 \
|
||||||
|
-T 127.0.0.1:6082 \
|
||||||
|
-f <%= vcl_path %> \
|
||||||
|
-s file,<%= cache_dir %>/cache,<%= store_file_size %>M \
|
||||||
|
-u nobody \
|
||||||
|
-g nogroup \
|
||||||
|
-w <%= scope.lookupvar('::processorcount') %>,<%= scope.lookupvar('::processorcount').to_i * 2 %>,600 \
|
||||||
|
"
|
||||||
|
|
@ -1,9 +1,20 @@
|
|||||||
require "puppet-standalone-mashup/version"
|
require "puppet-standalone-mashup/version"
|
||||||
|
|
||||||
module Puppet
|
module PuppetStandaloneMashup
|
||||||
module Standalone
|
autoload :Provider, 'puppet-standalone-mashup/provider'
|
||||||
module Mashup
|
autoload :Configuration, 'puppet-standalone-mashup/configuration'
|
||||||
# Your code goes here...
|
|
||||||
end
|
class ProvideMyself < Provider ; end
|
||||||
|
|
||||||
|
def self.configure
|
||||||
|
yield configuration
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.configuration
|
||||||
|
@configuration ||= Configuration.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.paths_for(*args)
|
||||||
|
Provider.paths_for(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
require 'erb'
|
require 'erb'
|
||||||
|
require 'puppet-standalone-mashup'
|
||||||
|
|
||||||
def _cset(name, *args, &block)
|
def _cset(name, *args, &block)
|
||||||
unless exists?(name)
|
unless exists?(name)
|
||||||
@ -6,10 +7,6 @@ def _cset(name, *args, &block)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module PuppetStandaloneMashup
|
|
||||||
BASE = Pathname(File.expand_path('../../..', __FILE__))
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'capistrano/command'
|
require 'capistrano/command'
|
||||||
|
|
||||||
module Capistrano
|
module Capistrano
|
||||||
@ -33,6 +30,7 @@ Capistrano::Configuration.instance.load do
|
|||||||
|
|
||||||
_cset(:rename_server) { true }
|
_cset(:rename_server) { true }
|
||||||
_cset(:use_sudo) { true }
|
_cset(:use_sudo) { true }
|
||||||
|
_cset(:run_as_user) { false }
|
||||||
_cset(:additional_modules) { [] }
|
_cset(:additional_modules) { [] }
|
||||||
_cset(:additional_puppet_options) { '' }
|
_cset(:additional_puppet_options) { '' }
|
||||||
|
|
||||||
@ -59,12 +57,24 @@ Capistrano::Configuration.instance.load do
|
|||||||
top.copy_skel
|
top.copy_skel
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_user(cmd)
|
||||||
|
if use_sudo
|
||||||
|
if run_as_user
|
||||||
|
%{#{sudo} su -c "#{cmd}" #{user}}
|
||||||
|
else
|
||||||
|
%{#{sudo} #{cmd}}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
cmd
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc "Apply the configuration"
|
desc "Apply the configuration"
|
||||||
task :apply do
|
task :apply do
|
||||||
top.copy_files
|
top.copy_files
|
||||||
top.rename if rename_server && wrong_server_name?
|
top.rename if rename_server && wrong_server_name?
|
||||||
|
|
||||||
run "cd #{puppet_dir} && #{sudo} ./apply"
|
run "cd #{puppet_dir} && #{as_user("./apply")}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrong_server_name?
|
def wrong_server_name?
|
||||||
@ -76,7 +86,13 @@ Capistrano::Configuration.instance.load do
|
|||||||
top.copy_files
|
top.copy_files
|
||||||
top.rename if rename_server
|
top.rename if rename_server
|
||||||
|
|
||||||
run "cd #{puppet_dir} && #{sudo} ./bootstrap"
|
run "cd #{puppet_dir} && #{as_user("./bootstrap")}"
|
||||||
|
top.bootstrap_reboot
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Reboot the server after bootstrapping"
|
||||||
|
task :bootstrap_reboot do
|
||||||
|
run "#{sudo} shutdown -r now"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Rename the server"
|
desc "Rename the server"
|
||||||
@ -92,25 +108,39 @@ Capistrano::Configuration.instance.load do
|
|||||||
top.ensure_puppet_dir
|
top.ensure_puppet_dir
|
||||||
|
|
||||||
Dir["*"].each do |file|
|
Dir["*"].each do |file|
|
||||||
if !%w{vbox}.include?(file)
|
if !%w{vbox deb}.include?(file)
|
||||||
top.upload file, File.join(puppet_dir, file)
|
top.upload file, File.join(puppet_dir, file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def upload_directory_safely(source, target, options = {})
|
||||||
|
run "mkdir -p #{target}"
|
||||||
|
|
||||||
|
Dir["#{source}/*"].each do |child|
|
||||||
|
top.upload child, File.join(target, File.basename(child)), options
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc "Copy skel files to remote server"
|
desc "Copy skel files to remote server"
|
||||||
task :copy_skel do
|
task :copy_skel do
|
||||||
top.ensure_puppet_dir
|
top.ensure_puppet_dir
|
||||||
|
|
||||||
[ '*.erb', "#{distribution}/*.erb" ].each do |dir|
|
targets = []
|
||||||
Dir[PuppetStandaloneMashup::BASE.join('skel').join(dir).to_s].each do |file|
|
|
||||||
data = StringIO.new(ERB.new(File.read(file)).result(binding))
|
|
||||||
|
|
||||||
top.upload data, target = File.join(puppet_dir, File.basename(file, '.erb'))
|
PuppetStandaloneMashup.paths_for('skel').each do |path|
|
||||||
|
[ '*.erb', "#{distribution}/*.erb" ].each do |dir|
|
||||||
|
Dir[path.join(dir).to_s].each do |file|
|
||||||
|
data = StringIO.new(ERB.new(File.read(file)).result(binding))
|
||||||
|
|
||||||
run "chmod a+x #{target}"
|
top.upload data, target = File.join(puppet_dir, File.basename(file, '.erb'))
|
||||||
|
|
||||||
|
targets << target
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
run "chmod a+x #{targets.join(' ')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Copy shared"
|
desc "Copy shared"
|
||||||
@ -119,8 +149,8 @@ Capistrano::Configuration.instance.load do
|
|||||||
|
|
||||||
run "mkdir -p #{puppet_dir}/shared/additional-modules"
|
run "mkdir -p #{puppet_dir}/shared/additional-modules"
|
||||||
|
|
||||||
(%w{lib modules templates} + additional_modules.collect { |dir| "additional-modules/#{dir}" }).each do |dir|
|
PuppetStandaloneMashup.configuration.shared_paths.each do |path|
|
||||||
top.upload PuppetStandaloneMashup::BASE.join('shared', dir).to_s, File.join(puppet_dir, 'shared', dir)
|
upload_directory_safely path.to_s, File.join(puppet_dir, 'shared', path.target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -145,7 +175,22 @@ Capistrano::Configuration.instance.load do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def with_additional_puppet_bin_path
|
def with_additional_puppet_bin_path
|
||||||
additional_puppet_bin_path ? %{PATH="#{additional_puppet_bin_path}:$PATH"} : ''
|
"PATH=" + (PuppetStandaloneMashup.configuration.bin_path + [ "$PATH" ]).join(':')
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Get managing user's public key"
|
||||||
|
task :public_key do
|
||||||
|
as_user = ->(command) { %{sudo -u #{user} -- #{command}} }
|
||||||
|
|
||||||
|
key = capture(as_user.("cat ~/.ssh/id_dsa.pub 2>/dev/null ; true"))
|
||||||
|
if key.empty?
|
||||||
|
if Capistrano::CLI.ui.ask("No key found. Generate a key?")
|
||||||
|
run as_user.("ssh-keygen -f ~/.ssh/id_dsa -t dsa -N ''")
|
||||||
|
key = capture(as_user("cat ~/.ssh/id_dsa.pub"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
$stdout.puts "\n#{key}\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ Capistrano::Configuration.instance.load do
|
|||||||
|
|
||||||
set(:user) { 'vagrant' }
|
set(:user) { 'vagrant' }
|
||||||
set(:password) { 'vagrant' }
|
set(:password) { 'vagrant' }
|
||||||
|
set(:use_sudo) { true }
|
||||||
|
set(:run_as_user) { false }
|
||||||
|
|
||||||
task :ensure_puppet do
|
task :ensure_puppet do
|
||||||
require 'socket'
|
require 'socket'
|
||||||
|
60
lib/puppet-standalone-mashup/configuration.rb
Normal file
60
lib/puppet-standalone-mashup/configuration.rb
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
require 'delegate'
|
||||||
|
|
||||||
|
class Pathname
|
||||||
|
def only_valid_paths_for_directories(*dirs)
|
||||||
|
valid_paths = []
|
||||||
|
|
||||||
|
dirs.flatten.each do |dir|
|
||||||
|
target = self.join(dir)
|
||||||
|
|
||||||
|
if target.directory?
|
||||||
|
valid_paths << target
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
valid_paths
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module PuppetStandaloneMashup
|
||||||
|
class TargetedPath < SimpleDelegator
|
||||||
|
attr_reader :path, :target
|
||||||
|
|
||||||
|
def initialize(path, target = path.basename)
|
||||||
|
@path, @target = path, target
|
||||||
|
end
|
||||||
|
|
||||||
|
def __getobj__
|
||||||
|
@path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Configuration
|
||||||
|
SHARED_DIRS = %w{lib modules templates}
|
||||||
|
|
||||||
|
def additional_modules
|
||||||
|
@additional_modules ||= []
|
||||||
|
end
|
||||||
|
|
||||||
|
def bin_path
|
||||||
|
@bin_path ||= []
|
||||||
|
end
|
||||||
|
|
||||||
|
def shared_paths
|
||||||
|
return @shared_paths if @shared_paths
|
||||||
|
|
||||||
|
@shared_paths = []
|
||||||
|
|
||||||
|
Provider.paths_for('shared').each do |path|
|
||||||
|
@shared_paths += path.only_valid_paths_for_directories(SHARED_DIRS).collect { |dirpath| TargetedPath.new(dirpath) }
|
||||||
|
end
|
||||||
|
|
||||||
|
Provider.paths_for('additional-modules').each do |path|
|
||||||
|
@shared_paths += path.only_valid_paths_for_directories(additional_modules).collect { |dirpath| TargetedPath.new(dirpath, "modules/#{dirpath.basename}") }
|
||||||
|
end
|
||||||
|
|
||||||
|
@shared_paths
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
15
lib/puppet-standalone-mashup/provider.rb
Normal file
15
lib/puppet-standalone-mashup/provider.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
class PuppetStandaloneMashup::Provider
|
||||||
|
def self.shared_sources
|
||||||
|
@shared_sources ||= []
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.inherited(klass)
|
||||||
|
shared_sources << Pathname(caller.first.gsub(%r{lib/.*}, ''))
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.paths_for(*paths)
|
||||||
|
shared_sources.collect do |source|
|
||||||
|
paths.collect { |path| source.join(path) }
|
||||||
|
end.flatten
|
||||||
|
end
|
||||||
|
end
|
@ -1,6 +0,0 @@
|
|||||||
class debian {
|
|
||||||
group { web:
|
|
||||||
gid => 30010
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
|||||||
class ruby($version, $configure = "--disable-install-doc", $build_path = '') {
|
|
||||||
$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",
|
|
||||||
configure => $configure,
|
|
||||||
preconfigure => "LDFLAGS='-rdynamic -Wl,-export-dynamic'",
|
|
||||||
path => "${build_path}:${with_ruby_path}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($osfamily == 'debian') {
|
|
||||||
$packages = [
|
|
||||||
'libyaml-dev', 'libreadline-dev', 'libssl-dev', 'libffi-dev',
|
|
||||||
'libncurses5-dev', 'libcurl4-openssl-dev', 'zlib1g-dev',
|
|
||||||
'libxml2', 'libxml2-dev', 'libxslt1.1', 'libxslt1-dev'
|
|
||||||
]
|
|
||||||
|
|
||||||
package { $packages:
|
|
||||||
ensure => installed,
|
|
||||||
before => Build_and_install[$name]
|
|
||||||
}
|
|
||||||
|
|
||||||
bash_rc_d { 'ruby':
|
|
||||||
ensure => present,
|
|
||||||
path => $base::local_path,
|
|
||||||
require => Build_and_install[$name]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gem { [ 'bundler', 'penchant' ]:
|
|
||||||
require => Build_and_install[$name],
|
|
||||||
path => $with_ruby_path,
|
|
||||||
ensure => present
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
|||||||
class squid($version, $user, $config_template, $error_template) {
|
|
||||||
$bin = bin_path($name)
|
|
||||||
$sbin = sbin_path($name)
|
|
||||||
|
|
||||||
$build_dir = build_path($name, $version)
|
|
||||||
$log_dir = log_path($name)
|
|
||||||
$pid = pid_path($name)
|
|
||||||
$data_dir = data_path($name)
|
|
||||||
$config_dir = config_path($name)
|
|
||||||
$config = "${config_dir}/squid.conf"
|
|
||||||
|
|
||||||
mkdir_p { [ $log_dir, $data_dir, $config_dir ]:
|
|
||||||
path => $base::path
|
|
||||||
}
|
|
||||||
|
|
||||||
build_and_install { $name:
|
|
||||||
version => $version,
|
|
||||||
source => "http://www.squid-cache.org/Versions/v3/3.1/squid-${version}.tar.bz2",
|
|
||||||
configure => template('squid/configure'),
|
|
||||||
preconfigure => template('squid/preconfigure')
|
|
||||||
}
|
|
||||||
|
|
||||||
file { $config:
|
|
||||||
content => template($config_template),
|
|
||||||
require => Build_and_install[$name]
|
|
||||||
}
|
|
||||||
|
|
||||||
$squid_start = 'service squid start'
|
|
||||||
$squid_stop = 'service squid stop'
|
|
||||||
|
|
||||||
god_init { $name:
|
|
||||||
start => $squid_start,
|
|
||||||
stop => $squid_stop,
|
|
||||||
restart => "${squid_stop} && ${squid_start}",
|
|
||||||
pid_file => $pid,
|
|
||||||
ensure => present,
|
|
||||||
require => File[$config],
|
|
||||||
interval => 10
|
|
||||||
}
|
|
||||||
|
|
||||||
file { [
|
|
||||||
"${data_dir}/errors/en/ERR_CANNOT_FORWARD",
|
|
||||||
"${data_dir}/errors/templates/ERR_CANNOT_FORWARD"
|
|
||||||
]:
|
|
||||||
content => template($error_template),
|
|
||||||
require => Build_and_install['squid']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
|||||||
class varnish($version, $vcl, $user = 'varnish', $group = 'varnish', $store_file_mb = 1024) {
|
|
||||||
$install_path = install_path($name, $version)
|
|
||||||
$config = config_path($name)
|
|
||||||
$share = share_path($name)
|
|
||||||
$data = data_path($name)
|
|
||||||
$sbin = sbin_path($name)
|
|
||||||
$bin_path = bin_path($name)
|
|
||||||
|
|
||||||
$bin = "${sbin}/${name}d"
|
|
||||||
$pid = pid_path($name)
|
|
||||||
$log = log_path($name)
|
|
||||||
|
|
||||||
$ncsa_bin = "${bin_path}/varnishncsa"
|
|
||||||
$ncsa_pid = pid_path('varnishncsa')
|
|
||||||
$ncsa_log = "${log}/access.log"
|
|
||||||
|
|
||||||
$vcl_path = "${config}/default.vcl"
|
|
||||||
|
|
||||||
$store_file_path = "${data}/store"
|
|
||||||
$store_file_size = $store_file_mb * 1024 * 1024
|
|
||||||
|
|
||||||
$varnish_start = "service varnish start"
|
|
||||||
$varnish_stop = "service varnish stop"
|
|
||||||
$varnish_rotate = "service varnish rotate"
|
|
||||||
|
|
||||||
$source = "http://repo.varnish-cache.org/source/varnish-${version}.tar.gz"
|
|
||||||
$dirs = [ $config, $log, $share, $data ]
|
|
||||||
|
|
||||||
build_and_install { $name:
|
|
||||||
version => $version,
|
|
||||||
source => $source
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir_p { $dirs:
|
|
||||||
path => $base::path,
|
|
||||||
require => Build_and_install[$name]
|
|
||||||
}
|
|
||||||
|
|
||||||
exec { "${name} create-store-file":
|
|
||||||
command => "dd if=/dev/zero of=${store_file_path} bs=${store_file_size} count=1",
|
|
||||||
timeout => 0,
|
|
||||||
unless => "test -f ${store_file_path}",
|
|
||||||
path => $base::path,
|
|
||||||
require => Mkdir_p[$data],
|
|
||||||
logoutput => true
|
|
||||||
}
|
|
||||||
|
|
||||||
file { $vcl_path:
|
|
||||||
content => $vcl,
|
|
||||||
require => Build_and_install[$name]
|
|
||||||
}
|
|
||||||
|
|
||||||
god_init { $name:
|
|
||||||
start => $varnish_start,
|
|
||||||
stop => $varnish_stop,
|
|
||||||
dir => config_path('god.d'),
|
|
||||||
restart => "${varnish_stop} && ${varnish_start}",
|
|
||||||
pid_file => $pid,
|
|
||||||
ensure => present,
|
|
||||||
require => File[$vcl_path],
|
|
||||||
interval => 10
|
|
||||||
}
|
|
||||||
|
|
||||||
/* debian stuff */
|
|
||||||
if ($::osfamily == 'debian') {
|
|
||||||
user { $user: uid => 27835 }
|
|
||||||
|
|
||||||
$packages = [ 'libpcre3', 'libpcre3-dev', 'pkg-config' ]
|
|
||||||
|
|
||||||
package { $packages:
|
|
||||||
ensure => installed,
|
|
||||||
before => Build_and_install[$name]
|
|
||||||
}
|
|
||||||
|
|
||||||
exec { 'ensure-data-store-ownership':
|
|
||||||
command => "chown -R ${user}:${group} ${data}",
|
|
||||||
path => $base::path,
|
|
||||||
require => Exec["${name} create-store-file"]
|
|
||||||
}
|
|
||||||
|
|
||||||
logrotate_d { 'varnishncsa':
|
|
||||||
postrotate => 'service varnish rotate',
|
|
||||||
pattern => "${log}/access.log"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init_d { $name:
|
|
||||||
require => Mkdir_p[$dirs]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
8
shared/lib/facter/all_ip_addresses.rb
Normal file
8
shared/lib/facter/all_ip_addresses.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Facter.add('all_ip_addresses') do
|
||||||
|
setcode do
|
||||||
|
Facter.collection.list.find_all { |fact| fact[%r{^ipaddress_}] }.collect do |fact|
|
||||||
|
Facter[fact].value
|
||||||
|
end.compact.join(',')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
6
shared/lib/facter/varnish_cache_size.rb
Normal file
6
shared/lib/facter/varnish_cache_size.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Facter.add("varnish_cache_size") do
|
||||||
|
setcode do
|
||||||
|
%x{df -m /var}.lines.to_a.last.strip.split(/ +/)[1].to_i / 4
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -6,4 +6,3 @@ module Puppet::Parser::Functions
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
6
shared/lib/puppet/parser/functions/dir_size.rb
Normal file
6
shared/lib/puppet/parser/functions/dir_size.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module Puppet::Parser::Functions
|
||||||
|
newfunction(:dir_size, :type => :rvalue) do |path|
|
||||||
|
%x{df -m #{path}}.lines.to_a.last.strip.split(/ +/)[1].to_i / 4
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
10
shared/lib/puppet/parser/functions/find_path.rb
Normal file
10
shared/lib/puppet/parser/functions/find_path.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module Puppet::Parser::Functions
|
||||||
|
newfunction(:find_path, :type => :rvalue) do |name, root|
|
||||||
|
Pathname(root).find do |file|
|
||||||
|
return file.to_s if file.basename == name
|
||||||
|
end
|
||||||
|
|
||||||
|
raise StandardError.new("File not found in #{root}: #{name}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -2,8 +2,8 @@ Puppet::Type.type(:configure).provide(:action) do
|
|||||||
desc "Configure a program to install"
|
desc "Configure a program to install"
|
||||||
|
|
||||||
def create
|
def create
|
||||||
system %{bash -c "cd #{@resource[:build_path]} && #{@resource[:preconfigure].gsub('"', '\\"')} #{path} ./configure --prefix=#{@resource[:install_path]} #{@resource[:options]}"}.tap { |o| p o }
|
command = %{bash -c "cd #{@resource[:build_path]} && #{@resource[:preconfigure].gsub('"', '\\"')} #{path} ./configure --prefix=#{@resource[:install_path]} #{@resource[:options]}"}.tap { |o| p o }
|
||||||
p $?
|
system command
|
||||||
raise StandardError.new("Could not configure") if $?.exitstatus != 0
|
raise StandardError.new("Could not configure") if $?.exitstatus != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ Puppet::Type.type(:configure).provide(:action) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exists?
|
||||||
return true if unless?
|
return unless? if unless? != nil
|
||||||
|
|
||||||
File.file?(config_status)
|
File.file?(config_status)
|
||||||
end
|
end
|
||||||
@ -31,7 +31,7 @@ Puppet::Type.type(:configure).provide(:action) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
@resource[:path].empty? ? '' : "PATH=#{@resource[:path]}:$PATH "
|
@resource[:path].empty? ? '' : "PATH=#{@resource[:path]} "
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ Puppet::Type.type(:download_and_unpack).provide(:action) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exists?
|
||||||
return true if unless?
|
return unless? if unless? != nil
|
||||||
|
|
||||||
File.directory?(File.join(@resource[:src_path], target_dir))
|
File.directory?(File.join(@resource[:src_path], target_dir))
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,12 @@ Puppet::Type.type(:git).provide(:clone) do
|
|||||||
desc "Clone/pull a git repo"
|
desc "Clone/pull a git repo"
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
system key_check_command
|
||||||
|
|
||||||
|
if $?.exitstatus != 0
|
||||||
|
system keyscan_command
|
||||||
|
end
|
||||||
|
|
||||||
if File.directory?(path)
|
if File.directory?(path)
|
||||||
Dir.chdir(path) { system git_command("pull origin master") }
|
Dir.chdir(path) { system git_command("pull origin master") }
|
||||||
else
|
else
|
||||||
@ -19,9 +25,27 @@ Puppet::Type.type(:git).provide(:clone) do
|
|||||||
|
|
||||||
private
|
private
|
||||||
def git_command(what)
|
def git_command(what)
|
||||||
user_switch = @resource[:user] ? "sudo -u #{@resource[:user]} -- " : ""
|
path_wrap("git #{what}")
|
||||||
|
end
|
||||||
|
|
||||||
%{bash -c 'PATH=#{@resource[:path]} #{user_switch} git #{what}'}
|
def keyscan_command
|
||||||
|
path_wrap("ssh-keyscan -t dsa,rsa #{@resource[:host]} >> ~/.ssh/known_hosts")
|
||||||
|
end
|
||||||
|
|
||||||
|
def key_check_command
|
||||||
|
path_wrap("ssh-keygen -F #{@resource[:host]}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def path_wrap(command)
|
||||||
|
command = %{PATH=#{@resource[:path]} #{command}}
|
||||||
|
|
||||||
|
if @resource[:user]
|
||||||
|
command = %{su -c "#{command}" #{@resource[:user]}}
|
||||||
|
else
|
||||||
|
command = %{sh -c "#{command}"}
|
||||||
|
end
|
||||||
|
|
||||||
|
command
|
||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
require 'erb'
|
require 'erb'
|
||||||
|
|
||||||
Puppet::Type.type(:god_init).provide(:install) do
|
Puppet::Type.type(:god_init).provide(:install) do
|
||||||
desc "Install a God script"
|
desc "Install a God script for a non-daemonized process"
|
||||||
|
|
||||||
|
def self.def_resources(*args)
|
||||||
|
args.each do |arg|
|
||||||
|
class_eval <<-RB
|
||||||
|
def #{arg}
|
||||||
|
@resource[:#{arg}] || ''
|
||||||
|
end
|
||||||
|
RB
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
FileUtils.mkdir_p File.dirname(file)
|
FileUtils.mkdir_p File.dirname(file)
|
||||||
@ -21,64 +31,28 @@ Puppet::Type.type(:god_init).provide(:install) do
|
|||||||
ERB.new(config).result(binding)
|
ERB.new(config).result(binding)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def_resources :start, :group, :name, :dir
|
||||||
def file
|
|
||||||
File.join(@resource[:dir], "#{@resource[:name]}.god")
|
|
||||||
end
|
|
||||||
|
|
||||||
def start
|
|
||||||
@resource[:start] || ''
|
|
||||||
end
|
|
||||||
|
|
||||||
def stop
|
|
||||||
@resource[:stop] || ''
|
|
||||||
end
|
|
||||||
|
|
||||||
def restart
|
|
||||||
@resource[:restart] || ''
|
|
||||||
end
|
|
||||||
|
|
||||||
def name
|
|
||||||
@resource[:name] || ''
|
|
||||||
end
|
|
||||||
|
|
||||||
def pid_file
|
|
||||||
@resource[:pid_file] || ''
|
|
||||||
end
|
|
||||||
|
|
||||||
def interval
|
def interval
|
||||||
@resource[:interval] || 5
|
@resource[:interval] || 30
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def file
|
||||||
|
File.join(dir, "#{name}.god")
|
||||||
end
|
end
|
||||||
|
|
||||||
def config
|
def config
|
||||||
<<-GOD
|
<<-GOD
|
||||||
God.watch do |w|
|
God.watch do |w|
|
||||||
w.name = "<%= name %>"
|
w.name = "<%= name %>"
|
||||||
|
<% if !group.empty? %>
|
||||||
|
w.group = "<%= group %>"
|
||||||
|
<% end %>
|
||||||
|
|
||||||
w.interval = <%= interval %>.seconds
|
w.interval = <%= interval %>.seconds
|
||||||
|
w.start = %{<%= start %>}
|
||||||
w.start = lambda { system("<%= start %>") }
|
w.keepalive
|
||||||
w.start_grace = <%= interval %>.seconds
|
|
||||||
|
|
||||||
<% if !stop.empty? %>
|
|
||||||
w.stop = lambda { system("<%= stop %>") ; system("killall -9 <%= name %>") }
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if !restart.empty? %>
|
|
||||||
w.restart = lambda { system("<%= restart %>") }
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if pid_file %>
|
|
||||||
w.pid_file = "<%= pid_file %>";
|
|
||||||
<% else %>
|
|
||||||
w.behavior(:clean_pid_file)
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
w.start_if do |start|
|
|
||||||
start.condition(:process_running) do |c|
|
|
||||||
c.interval = <%= interval %>.seconds
|
|
||||||
c.running = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
GOD
|
GOD
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ Puppet::Type.type(:make_and_install).provide(:action) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exists?
|
||||||
return true if unless?
|
return unless? if unless? != nil
|
||||||
|
|
||||||
File.directory?(@resource[:install_path]) && File.symlink?(symlink_path)
|
File.directory?(@resource[:install_path]) && File.symlink?(symlink_path)
|
||||||
end
|
end
|
||||||
|
33
shared/lib/puppet/provider/sudoers_d/install.rb
Normal file
33
shared/lib/puppet/provider/sudoers_d/install.rb
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
require 'pathname'
|
||||||
|
|
||||||
|
Puppet::Type.type(:sudoers_d).provide(:install) do
|
||||||
|
desc "Install a sudoers.d file"
|
||||||
|
|
||||||
|
def create
|
||||||
|
temp_target.open('w') { |fh| fh.puts content }
|
||||||
|
temp_target.chmod 0440
|
||||||
|
temp_target.rename(target)
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
target.unlink
|
||||||
|
end
|
||||||
|
|
||||||
|
def exists?
|
||||||
|
target.file? and target.read == content
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def target
|
||||||
|
@target ||= Pathname("/etc/sudoers.d/#{@resource[:name]}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def temp_target
|
||||||
|
@temp_target ||= Pathname("/tmp/sudoers.d-#{@resource[:name]}-#{Time.now.to_f}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def content
|
||||||
|
@resource[:content]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -22,5 +22,9 @@ Puppet::Type.newtype(:git) do
|
|||||||
newparam(:user) do
|
newparam(:user) do
|
||||||
desc "The user to perform the command as"
|
desc "The user to perform the command as"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
newparam(:host) do
|
||||||
|
desc "The host to connect to"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,22 +11,14 @@ Puppet::Type.newtype(:god_init) do
|
|||||||
desc "The command to start the process"
|
desc "The command to start the process"
|
||||||
end
|
end
|
||||||
|
|
||||||
newparam(:stop) do
|
newparam(:group) do
|
||||||
desc "The command to stop the process"
|
desc "The group this process belongs to"
|
||||||
end
|
|
||||||
|
|
||||||
newparam(:restart) do
|
|
||||||
desc "The command to restart/reload the process"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
newparam(:dir) do
|
newparam(:dir) do
|
||||||
desc "The directory where god configs are held"
|
desc "The directory where god configs are held"
|
||||||
end
|
end
|
||||||
|
|
||||||
newparam(:pid_file) do
|
|
||||||
desc "A pid file"
|
|
||||||
end
|
|
||||||
|
|
||||||
newparam(:interval) do
|
newparam(:interval) do
|
||||||
desc "The check interval"
|
desc "The check interval"
|
||||||
end
|
end
|
||||||
|
14
shared/lib/puppet/type/sudoers_d.rb
Normal file
14
shared/lib/puppet/type/sudoers_d.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Puppet::Type.newtype(:sudoers_d) do
|
||||||
|
@doc = "Add a file to /etc/sudoers.d"
|
||||||
|
|
||||||
|
ensurable
|
||||||
|
|
||||||
|
newparam(:name) do
|
||||||
|
desc "The file to create"
|
||||||
|
end
|
||||||
|
|
||||||
|
newparam(:content) do
|
||||||
|
desc "The content of the file"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
23
shared/modules/debsource/manifests/init.pp
Normal file
23
shared/modules/debsource/manifests/init.pp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
define debsource($apt_source, $keyfile = '', $host = '', $hash = '') {
|
||||||
|
$file = "/etc/apt/sources.list.d/${name}.list"
|
||||||
|
file { $file: content => $apt_source }
|
||||||
|
|
||||||
|
if ($host != '') {
|
||||||
|
exec { "debsource-${name}":
|
||||||
|
command => "apt-key adv --keyserver ${host} --recv ${hash} && apt-get update",
|
||||||
|
unless => "test $(apt-key list | grep ${hash} | wc -l) -ne 0",
|
||||||
|
path => $base::path,
|
||||||
|
require => File[$file]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($keyfile != '') {
|
||||||
|
exec { "debsource-${name}":
|
||||||
|
command => "curl $keyfile | apt-key add - && apt-get update",
|
||||||
|
path => $base::path,
|
||||||
|
require => File[$file],
|
||||||
|
unless => "test $(apt-key list | grep ${hash} | wc -l) -ne 0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,6 @@
|
|||||||
rotate 10000
|
rotate 10000
|
||||||
missingok
|
missingok
|
||||||
compress
|
compress
|
||||||
delaycompress
|
|
||||||
missingok
|
missingok
|
||||||
dateext
|
dateext
|
||||||
postrotate
|
postrotate
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
define mkdir_p($path) {
|
define mkdir_p($path, $owner = '') {
|
||||||
exec { "mkdir -p ${name}":
|
exec { "mkdir -p ${name}":
|
||||||
path => $path,
|
path => $path,
|
||||||
unless => "test -d ${name}"
|
unless => "test -d ${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($owner != '') {
|
||||||
|
exec { "chown ${owner} ${name}":
|
||||||
|
path => $path,
|
||||||
|
require => Exec["mkdir -p ${name}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
shared/modules/package_data/manifests/init.pp
Normal file
1
shared/modules/package_data/manifests/init.pp
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
10
shared/modules/remotedeb/manifests/init.pp
Normal file
10
shared/modules/remotedeb/manifests/init.pp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
define remotedeb($url, $version) {
|
||||||
|
$deb = "/tmp/${name}.deb"
|
||||||
|
|
||||||
|
exec { "remotedeb-${name}":
|
||||||
|
command => "curl -o ${deb} ${url} && dpkg -i ${deb}",
|
||||||
|
unless => "test $(dpkg -l ${name} | grep ${version} | wc -l) -ne 0",
|
||||||
|
path => $base::path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,8 @@ define ssh {
|
|||||||
ensure => directory,
|
ensure => directory,
|
||||||
mode => '0700',
|
mode => '0700',
|
||||||
owner => $name,
|
owner => $name,
|
||||||
group => $name
|
group => $name,
|
||||||
|
require => User[$name]
|
||||||
}
|
}
|
||||||
|
|
||||||
file { "${ssh_dir}/authorized_keys":
|
file { "${ssh_dir}/authorized_keys":
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
mkdir -p ~/.puppet
|
mkdir -p ~/.puppet
|
||||||
<%= use_sudo ? "sudo env" : "" %> RUBYLIB="${PWD}/shared/lib" \
|
RUBYLIB="${PWD}/lib:${PWD}/shared/lib" \
|
||||||
<%= with_additional_puppet_bin_path %> \
|
<%= with_additional_puppet_bin_path %> \
|
||||||
puppet apply <%= additional_puppet_options %> \
|
puppet apply <%= additional_puppet_options %> \
|
||||||
--confdir=$PWD \
|
--confdir=$PWD \
|
||||||
--modulepath=$PWD/modules:$PWD/shared/modules:$PWD/shared/additional-modules \
|
--modulepath=$PWD/modules:$PWD/shared/modules \
|
||||||
--templatedir=$PWD/shared/templates:$PWD/templates \
|
--templatedir=$PWD/templates:$PWD/shared/templates \
|
||||||
-v $@ \
|
-v --no-report $@ \
|
||||||
manifests/site.pp
|
manifests/site.pp
|
||||||
|
|
||||||
|
@ -23,5 +23,3 @@ gem install puppet --no-ri --no-rdoc
|
|||||||
|
|
||||||
./apply
|
./apply
|
||||||
|
|
||||||
shutdown -r now
|
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
YAML_VERSION=0.1.4
|
||||||
|
RUBY_VERSION=1.9.3-p194
|
||||||
|
|
||||||
pwd=$PWD
|
pwd=$PWD
|
||||||
base_dir=<%= base_dir %>
|
base_dir=<%= base_dir %>
|
||||||
|
|
||||||
@ -10,26 +13,23 @@ if [ ! -f ${base_dir}/ruby-base/bin/ruby ]; then
|
|||||||
|
|
||||||
opt_dir=${base_dir}/tmp/ruby-opt
|
opt_dir=${base_dir}/tmp/ruby-opt
|
||||||
|
|
||||||
rm -Rf yaml-0.1.4*
|
rm -Rf yaml-$YAML_VERSION*
|
||||||
curl -O http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
|
curl http://pyyaml.org/download/libyaml/yaml-$YAML_VERSION.tar.gz > yaml.tar.gz
|
||||||
tar zxvf yaml-0.1.4.tar.gz
|
tar zxvf yaml.tar.gz
|
||||||
mv yaml-0.1.4 yaml-0.1.4-base
|
mv yaml-$YAML_VERSION yaml-$YAML_VERSION-base
|
||||||
cd yaml-0.1.4-base
|
cd yaml-$YAML_VERSION-base
|
||||||
./configure --prefix=${opt_dir}
|
./configure --prefix=${opt_dir}
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
RUBY=ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.9.3-p194.tar.bz2
|
rm -Rf ruby-$RUBY_VERSION
|
||||||
RUBY_FILENAME=${RUBY##*/}
|
curl ftp://ftp.ruby-lang.org/pub/ruby/ruby-$RUBY_VERSION.tar.bz2 > ruby.tar.bz2
|
||||||
RUBY_VERSION=${RUBY_FILENAME%%.tar.bz2}
|
tar jxvf ruby.tar.bz2
|
||||||
curl $RUBY > $RUBY_FILENAME
|
mv ruby-$RUBY_VERSION ruby-base
|
||||||
rm -Rf $RUBY_VERSION
|
|
||||||
tar jxvf $RUBY_FILENAME
|
|
||||||
mv $RUBY_VERSION "$RUBY_VERSION-base"
|
|
||||||
|
|
||||||
cd "$RUBY_VERSION-base"
|
cd ruby-base
|
||||||
|
|
||||||
./configure --prefix=${base_dir}/ruby-base --with-opt-dir=${opt_dir} --disable-pthread --disable-install-doc
|
./configure --prefix=${base_dir}/ruby-base --with-opt-dir=${opt_dir} --disable-pthread --disable-install-doc
|
||||||
make
|
make
|
||||||
@ -49,5 +49,4 @@ if [ ! -f ${base_dir}/ruby-base/bin/puppet ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p ~/.puppet
|
mkdir -p ~/.puppet
|
||||||
cd /tmp/puppet
|
|
||||||
./apply
|
|
||||||
|
Loading…
Reference in New Issue
Block a user