Compare commits
No commits in common. "master" and "pre-new-stuff" have entirely different histories.
master
...
pre-new-st
@ -1,10 +0,0 @@
|
|||||||
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"
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
|||||||
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']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/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
|
|
||||||
|
|
@ -1,98 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
#!/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,110 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
|||||||
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,20 +1,9 @@
|
|||||||
require "puppet-standalone-mashup/version"
|
require "puppet-standalone-mashup/version"
|
||||||
|
|
||||||
module PuppetStandaloneMashup
|
module Puppet
|
||||||
autoload :Provider, 'puppet-standalone-mashup/provider'
|
module Standalone
|
||||||
autoload :Configuration, 'puppet-standalone-mashup/configuration'
|
module Mashup
|
||||||
|
# Your code goes here...
|
||||||
class ProvideMyself < Provider ; end
|
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,5 +1,4 @@
|
|||||||
require 'erb'
|
require 'erb'
|
||||||
require 'puppet-standalone-mashup'
|
|
||||||
|
|
||||||
def _cset(name, *args, &block)
|
def _cset(name, *args, &block)
|
||||||
unless exists?(name)
|
unless exists?(name)
|
||||||
@ -7,6 +6,10 @@ 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
|
||||||
@ -30,7 +33,6 @@ 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) { '' }
|
||||||
|
|
||||||
@ -57,24 +59,12 @@ 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} && #{as_user("./apply")}"
|
run "cd #{puppet_dir} && #{sudo} ./apply"
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrong_server_name?
|
def wrong_server_name?
|
||||||
@ -86,13 +76,7 @@ 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} && #{as_user("./bootstrap")}"
|
run "cd #{puppet_dir} && #{sudo} ./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"
|
||||||
@ -108,39 +92,25 @@ Capistrano::Configuration.instance.load do
|
|||||||
top.ensure_puppet_dir
|
top.ensure_puppet_dir
|
||||||
|
|
||||||
Dir["*"].each do |file|
|
Dir["*"].each do |file|
|
||||||
if !%w{vbox deb}.include?(file)
|
if !%w{vbox}.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
|
||||||
|
|
||||||
targets = []
|
[ '*.erb', "#{distribution}/*.erb" ].each do |dir|
|
||||||
|
Dir[PuppetStandaloneMashup::BASE.join('skel').join(dir).to_s].each do |file|
|
||||||
|
data = StringIO.new(ERB.new(File.read(file)).result(binding))
|
||||||
|
|
||||||
PuppetStandaloneMashup.paths_for('skel').each do |path|
|
top.upload data, target = File.join(puppet_dir, File.basename(file, '.erb'))
|
||||||
[ '*.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))
|
|
||||||
|
|
||||||
top.upload data, target = File.join(puppet_dir, File.basename(file, '.erb'))
|
run "chmod a+x #{target}"
|
||||||
|
|
||||||
targets << target
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
run "chmod a+x #{targets.join(' ')}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Copy shared"
|
desc "Copy shared"
|
||||||
@ -149,8 +119,8 @@ Capistrano::Configuration.instance.load do
|
|||||||
|
|
||||||
run "mkdir -p #{puppet_dir}/shared/additional-modules"
|
run "mkdir -p #{puppet_dir}/shared/additional-modules"
|
||||||
|
|
||||||
PuppetStandaloneMashup.configuration.shared_paths.each do |path|
|
(%w{lib modules templates} + additional_modules.collect { |dir| "additional-modules/#{dir}" }).each do |dir|
|
||||||
upload_directory_safely path.to_s, File.join(puppet_dir, 'shared', path.target)
|
top.upload PuppetStandaloneMashup::BASE.join('shared', dir).to_s, File.join(puppet_dir, 'shared', dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -175,22 +145,7 @@ Capistrano::Configuration.instance.load do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def with_additional_puppet_bin_path
|
def with_additional_puppet_bin_path
|
||||||
"PATH=" + (PuppetStandaloneMashup.configuration.bin_path + [ "$PATH" ]).join(':')
|
additional_puppet_bin_path ? %{PATH="#{additional_puppet_bin_path}:$PATH"} : ''
|
||||||
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,8 +5,6 @@ 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'
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
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
|
|
@ -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', 'libffi5'
|
'git-core', 'vim'
|
||||||
]
|
]
|
||||||
|
|
||||||
package { $packages: ensure => installed }
|
package { $packages: ensure => installed }
|
6
shared/additional-modules/debian/manifests/init.pp
Normal file
6
shared/additional-modules/debian/manifests/init.pp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class debian {
|
||||||
|
group { web:
|
||||||
|
gid => 30010
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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 => Class['ruby']
|
require => Make_and_install['ruby']
|
||||||
}
|
}
|
||||||
|
|
||||||
$bin = "${ruby::path}/god"
|
$bin = "${base::install_path}/ruby/bin/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)
|
38
shared/additional-modules/ruby/manifests/init.pp
Normal file
38
shared/additional-modules/ruby/manifests/init.pp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -23,5 +23,10 @@ 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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
49
shared/additional-modules/squid/manifests/init.pp
Normal file
49
shared/additional-modules/squid/manifests/init.pp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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,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') %>
|
||||||
|
|
91
shared/additional-modules/varnish/manifests/init.pp
Normal file
91
shared/additional-modules/varnish/manifests/init.pp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
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]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
|||||||
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,3 +6,4 @@ module Puppet::Parser::Functions
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
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
|
||||||
command = %{bash -c "cd #{@resource[:build_path]} && #{@resource[:preconfigure].gsub('"', '\\"')} #{path} ./configure --prefix=#{@resource[:install_path]} #{@resource[:options]}"}.tap { |o| p o }
|
system %{bash -c "cd #{@resource[:build_path]} && #{@resource[:preconfigure].gsub('"', '\\"')} #{path} ./configure --prefix=#{@resource[:install_path]} #{@resource[:options]}"}.tap { |o| p o }
|
||||||
system command
|
p $?
|
||||||
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 unless? if unless? != nil
|
return true if unless?
|
||||||
|
|
||||||
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]} "
|
@resource[:path].empty? ? '' : "PATH=#{@resource[:path]}:$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 unless? if unless? != nil
|
return true if unless?
|
||||||
|
|
||||||
File.directory?(File.join(@resource[:src_path], target_dir))
|
File.directory?(File.join(@resource[:src_path], target_dir))
|
||||||
end
|
end
|
||||||
|
@ -2,12 +2,6 @@ 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
|
||||||
@ -25,27 +19,9 @@ Puppet::Type.type(:git).provide(:clone) do
|
|||||||
|
|
||||||
private
|
private
|
||||||
def git_command(what)
|
def git_command(what)
|
||||||
path_wrap("git #{what}")
|
user_switch = @resource[:user] ? "sudo -u #{@resource[:user]} -- " : ""
|
||||||
end
|
|
||||||
|
|
||||||
def keyscan_command
|
%{bash -c 'PATH=#{@resource[:path]} #{user_switch} git #{what}'}
|
||||||
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,17 +1,7 @@
|
|||||||
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 for a non-daemonized process"
|
desc "Install a God script"
|
||||||
|
|
||||||
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)
|
||||||
@ -31,28 +21,64 @@ Puppet::Type.type(:god_init).provide(:install) do
|
|||||||
ERB.new(config).result(binding)
|
ERB.new(config).result(binding)
|
||||||
end
|
end
|
||||||
|
|
||||||
def_resources :start, :group, :name, :dir
|
|
||||||
|
|
||||||
def interval
|
|
||||||
@resource[:interval] || 30
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def file
|
def file
|
||||||
File.join(dir, "#{name}.god")
|
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
|
||||||
|
@resource[:interval] || 5
|
||||||
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.interval = <%= interval %>.seconds
|
||||||
w.group = "<%= group %>"
|
|
||||||
|
w.start = lambda { system("<%= start %>") }
|
||||||
|
w.start_grace = <%= interval %>.seconds
|
||||||
|
|
||||||
|
<% if !stop.empty? %>
|
||||||
|
w.stop = lambda { system("<%= stop %>") ; system("killall -9 <%= name %>") }
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
w.interval = <%= interval %>.seconds
|
<% if !restart.empty? %>
|
||||||
w.start = %{<%= start %>}
|
w.restart = lambda { system("<%= restart %>") }
|
||||||
w.keepalive
|
<% 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 unless? if unless? != nil
|
return true if unless?
|
||||||
|
|
||||||
File.directory?(@resource[:install_path]) && File.symlink?(symlink_path)
|
File.directory?(@resource[:install_path]) && File.symlink?(symlink_path)
|
||||||
end
|
end
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
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,9 +22,5 @@ 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,14 +11,22 @@ Puppet::Type.newtype(:god_init) do
|
|||||||
desc "The command to start the process"
|
desc "The command to start the process"
|
||||||
end
|
end
|
||||||
|
|
||||||
newparam(:group) do
|
newparam(:stop) do
|
||||||
desc "The group this process belongs to"
|
desc "The command to stop the process"
|
||||||
|
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
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
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,6 +3,7 @@
|
|||||||
rotate 10000
|
rotate 10000
|
||||||
missingok
|
missingok
|
||||||
compress
|
compress
|
||||||
|
delaycompress
|
||||||
missingok
|
missingok
|
||||||
dateext
|
dateext
|
||||||
postrotate
|
postrotate
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
define mkdir_p($path, $owner = '') {
|
define mkdir_p($path) {
|
||||||
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 +0,0 @@
|
|||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
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,8 +5,7 @@ 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
|
||||||
RUBYLIB="${PWD}/lib:${PWD}/shared/lib" \
|
<%= use_sudo ? "sudo env" : "" %> RUBYLIB="${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 \
|
--modulepath=$PWD/modules:$PWD/shared/modules:$PWD/shared/additional-modules \
|
||||||
--templatedir=$PWD/templates:$PWD/shared/templates \
|
--templatedir=$PWD/shared/templates:$PWD/templates \
|
||||||
-v --no-report $@ \
|
-v $@ \
|
||||||
manifests/site.pp
|
manifests/site.pp
|
||||||
|
|
||||||
|
@ -23,3 +23,5 @@ gem install puppet --no-ri --no-rdoc
|
|||||||
|
|
||||||
./apply
|
./apply
|
||||||
|
|
||||||
|
shutdown -r now
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#!/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 %>
|
||||||
|
|
||||||
@ -13,23 +10,26 @@ 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-$YAML_VERSION*
|
rm -Rf yaml-0.1.4*
|
||||||
curl http://pyyaml.org/download/libyaml/yaml-$YAML_VERSION.tar.gz > yaml.tar.gz
|
curl -O http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
|
||||||
tar zxvf yaml.tar.gz
|
tar zxvf yaml-0.1.4.tar.gz
|
||||||
mv yaml-$YAML_VERSION yaml-$YAML_VERSION-base
|
mv yaml-0.1.4 yaml-0.1.4-base
|
||||||
cd yaml-$YAML_VERSION-base
|
cd yaml-0.1.4-base
|
||||||
./configure --prefix=${opt_dir}
|
./configure --prefix=${opt_dir}
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
rm -Rf ruby-$RUBY_VERSION
|
RUBY=ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.9.3-p194.tar.bz2
|
||||||
curl ftp://ftp.ruby-lang.org/pub/ruby/ruby-$RUBY_VERSION.tar.bz2 > ruby.tar.bz2
|
RUBY_FILENAME=${RUBY##*/}
|
||||||
tar jxvf ruby.tar.bz2
|
RUBY_VERSION=${RUBY_FILENAME%%.tar.bz2}
|
||||||
mv ruby-$RUBY_VERSION ruby-base
|
curl $RUBY > $RUBY_FILENAME
|
||||||
|
rm -Rf $RUBY_VERSION
|
||||||
|
tar jxvf $RUBY_FILENAME
|
||||||
|
mv $RUBY_VERSION "$RUBY_VERSION-base"
|
||||||
|
|
||||||
cd ruby-base
|
cd "$RUBY_VERSION-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,4 +49,5 @@ 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