whoa even more awesoms

This commit is contained in:
John Bintz 2012-04-30 12:02:19 -04:00
parent cdccad6183
commit 6f540ca3a2
9 changed files with 104 additions and 11 deletions

View File

@ -0,0 +1,25 @@
class basics {
$packages = [ "ntp", "ntpdate", "gcc", "curl", "build-essential", "patch", 'sysstat', 'git-core' ]
package { $packages: ensure => installed }
bash_rc { "/etc/bash.bashrc": ensure => present }
}
class base {
$path = "/usr/bin:/bin:/usr/sbin:/sbin"
$src_path = "/usr/src"
$install_path = "/usr/local"
$config_path = "/etc"
$pid_path = "/var/run"
$local_path = $install_path
}
node default {
include basics
include debian
class { base: require => Class['basics'] }
include umask
}

View File

@ -46,11 +46,15 @@ start() {
stop() {
echo -n "Stopping $DESC: "
if [ -f $PID_PATH ]; then
kill `cat $PID_PATH`
rm $PID_PATH
killall -9 god
RETVAL=$?
fi
killall -9 <%= god_bin %> || true
echo "$NAME."
return 0
}
case "$1" in

View File

@ -1,4 +1,6 @@
class nginx-debian {
class nginx-debian($version, $max_pool_size = 20) {
class { nginx: version => $version, max_pool_size => $max_pool_size }
$log_root = "/var/log/nginx"
file { $log_root:

View File

@ -1,8 +1,6 @@
require 'puppet/modules/common_directories'
module Puppet::Parser::Functions
$stdout.puts "here"
newfunction(:bin_path, :type => :rvalue) do |args|
$stdout.puts args.inspect

View File

@ -35,8 +35,7 @@ Puppet::Type.type(:gem).provide(:install) do
end
def gem_command(what)
command = %{bash -c 'PATH=#{@resource[:path]} gem #{what} #{@resource[:name]} #{options} #{version}'}
command
%{bash -c 'PATH=#{@resource[:path]} gem #{what} #{@resource[:name]} #{options} #{version}'}
end
end

View File

@ -0,0 +1,31 @@
Puppet::Type.type(:git).provide(:clone) do
desc "Clone/pull a git repo"
def create
if File.directory?(path)
Dir.chdir(path) { system git_command("pull origin master") }
else
Dir.chdir(@resource[:cwd]) { system git_command("clone #{@resource[:repo]}") }
end
end
def destroy
FileUtils.rm_rf(path) if File.directory?(path)
end
def exists?
false
end
private
def git_command(what)
user_switch = @resource[:user] ? "sudo -u #{@resource[:user]} -- " : ""
%{bash -c 'PATH=#{@resource[:path]} #{user_switch} git #{what}'}
end
def path
File.join(@resource[:cwd], @resource[:name])
end
end

View File

@ -44,11 +44,15 @@ Puppet::Type.type(:god_init).provide(:install) do
@resource[:pid_file] || ''
end
def interval
@resource[:interval] || 5
end
def config
<<-GOD
God.watch do |w|
w.name = "<%= name %>"
w.interval = 5.seconds
w.interval = <%= interval %>.seconds
w.start = lambda { system("<%= start %>") }
@ -68,7 +72,7 @@ God.watch do |w|
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 5.seconds
c.interval = <%= interval %>.seconds
c.running = false
end
end

View File

@ -0,0 +1,26 @@
Puppet::Type.newtype(:git) do
@doc = 'Cloning/pulling a git repo'
ensurable
newparam(:name) do
desc "The name of the repo"
end
newparam(:repo) do
desc "The address of the repo"
end
newparam(:cwd) do
desc "The working directory into which the repo should be pulled"
end
newparam(:path) do
desc "The binary search path"
end
newparam(:user) do
desc "The user to perform the command as"
end
end

View File

@ -22,5 +22,9 @@ Puppet::Type.newtype(:god_init) do
newparam(:pid_file) do
desc "A pid file"
end
newparam(:interval) do
desc "The check interval"
end
end