initial commit, starting to centralize configs
This commit is contained in:
commit
6abf601231
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.gem
|
||||
.bundle
|
||||
Gemfile.lock
|
||||
pkg/*
|
4
Gemfile
Normal file
4
Gemfile
Normal file
@ -0,0 +1,4 @@
|
||||
source "http://rubygems.org"
|
||||
|
||||
# Specify your gem's dependencies in puppet-standalone-mashup.gemspec
|
||||
gemspec
|
9
lib/puppet-standalone-mashup.rb
Normal file
9
lib/puppet-standalone-mashup.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require "puppet-standalone-mashup/version"
|
||||
|
||||
module Puppet
|
||||
module Standalone
|
||||
module Mashup
|
||||
# Your code goes here...
|
||||
end
|
||||
end
|
||||
end
|
108
lib/puppet-standalone-mashup/capistrano.rb
Normal file
108
lib/puppet-standalone-mashup/capistrano.rb
Normal file
@ -0,0 +1,108 @@
|
||||
require 'erb'
|
||||
|
||||
def _cset(name, *args, &block)
|
||||
unless exists?(name)
|
||||
set(name, *args, &block)
|
||||
end
|
||||
end
|
||||
|
||||
module PuppetStandaloneMashup
|
||||
BASE = Pathname(File.expand_path('../../..', __FILE__))
|
||||
end
|
||||
|
||||
Capistrano::Configuration.instance.load do
|
||||
_cset(:puppet_dir) { '/tmp/puppet' }
|
||||
_cset(:additional_puppet_bin_path) { nil }
|
||||
_cset(:base_dir) { '/usr/local' }
|
||||
_cset(:rename_server) { true }
|
||||
_cset(:use_sudo) { true }
|
||||
|
||||
@dir_made = false
|
||||
|
||||
def sudo
|
||||
use_sudo ? "sudo -p 'sudo password: '" : ""
|
||||
end
|
||||
|
||||
desc "Apply the configuration"
|
||||
task :apply do
|
||||
top.copy
|
||||
top.copy_shared
|
||||
top.copy_skel
|
||||
|
||||
run "cd #{puppet_dir} && #{sudo} ./apply"
|
||||
end
|
||||
|
||||
desc "Bootstrap the server"
|
||||
task :bootstrap do
|
||||
top.copy
|
||||
top.copy_shared
|
||||
top.copy_skel
|
||||
|
||||
if rename_server
|
||||
top.rename
|
||||
end
|
||||
|
||||
run "cd #{puppet_dir} && #{sudo} ./bootstrap"
|
||||
end
|
||||
|
||||
desc "Rename the server"
|
||||
task :rename do
|
||||
hostname = Capistrano::CLI.ui.ask("Hostname: ")
|
||||
|
||||
run "cd #{puppet_dir} && #{sudo} ./rename #{hostname}"
|
||||
end
|
||||
|
||||
desc "Copy puppet configs to remote server"
|
||||
task :copy do
|
||||
top.ensure_puppet_dir
|
||||
|
||||
Dir["*"].each { |file| top.upload file, File.join(puppet_dir, file) }
|
||||
end
|
||||
|
||||
desc "Copy skel files to remote server"
|
||||
task :copy_skel do
|
||||
top.ensure_puppet_dir
|
||||
|
||||
[ '*.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))
|
||||
|
||||
top.upload data, target = File.join(puppet_dir, File.basename(file, '.erb'))
|
||||
|
||||
run "chmod a+x #{target}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Copy shared"
|
||||
task :copy_shared do
|
||||
top.ensure_puppet_dir
|
||||
|
||||
top.upload PuppetStandaloneMashup::BASE.join('shared').to_s, File.join(puppet_dir, 'shared')
|
||||
end
|
||||
|
||||
desc "Ensure Puppet target dir exists"
|
||||
task :ensure_puppet_dir do
|
||||
if !@dir_made
|
||||
run "#{sudo} rm -Rf #{puppet_dir}"
|
||||
run "mkdir -p #{puppet_dir}"
|
||||
|
||||
@dir_made = true
|
||||
end
|
||||
end
|
||||
|
||||
desc "Make sudo nice"
|
||||
task :make_sudo_nice do
|
||||
make_nice = "~/make_nice"
|
||||
|
||||
run %{echo "%sudo ALL=NOPASSWD: /bin/rm, /tmp/puppet/apply" > #{make_nice}}
|
||||
run %{#{sudo} chmod 440 #{make_nice}}
|
||||
run %{#{sudo} chown root:root #{make_nice}}
|
||||
run %{#{sudo} mv ~/make_nice /etc/sudoers.d/}
|
||||
end
|
||||
|
||||
def with_additional_puppet_bin_path
|
||||
additional_puppet_bin_path ? %{PATH="#{additional_puppet_bin_path}:$PATH"} : ''
|
||||
end
|
||||
end
|
||||
|
7
lib/puppet-standalone-mashup/version.rb
Normal file
7
lib/puppet-standalone-mashup/version.rb
Normal file
@ -0,0 +1,7 @@
|
||||
module Puppet
|
||||
module Standalone
|
||||
module Mashup
|
||||
VERSION = "0.0.1"
|
||||
end
|
||||
end
|
||||
end
|
29
puppet-standalone-mashup.gemspec
Normal file
29
puppet-standalone-mashup.gemspec
Normal file
@ -0,0 +1,29 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
$:.push File.expand_path("../lib", __FILE__)
|
||||
require "puppet-standalone-mashup/version"
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "puppet-standalone-mashup"
|
||||
s.version = Puppet::Standalone::Mashup::VERSION
|
||||
s.authors = ["John Bintz"]
|
||||
s.email = ["john@coswellproductions.com"]
|
||||
s.homepage = ""
|
||||
s.summary = %q{TODO: Write a gem summary}
|
||||
s.description = %q{TODO: Write a gem description}
|
||||
|
||||
s.rubyforge_project = "puppet-standalone-mashup"
|
||||
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||
s.require_paths = ["lib"]
|
||||
|
||||
# specify any dependencies here; for example:
|
||||
# s.add_development_dependency "rspec"
|
||||
# s.add_runtime_dependency "rest-client"
|
||||
|
||||
s.add_runtime_dependency 'guard'
|
||||
s.add_runtime_dependency 'guard-shell'
|
||||
s.add_runtime_dependency 'capistrano'
|
||||
s.add_runtime_dependency 'capistrano-ext'
|
||||
end
|
29
shared/lib/puppet/modules/common_directories.rb
Normal file
29
shared/lib/puppet/modules/common_directories.rb
Normal file
@ -0,0 +1,29 @@
|
||||
module Puppet
|
||||
module Modules
|
||||
module CommonDirectories
|
||||
def build_path(src_path, name, version)
|
||||
File.join(src_path, "#{name}-#{version}")
|
||||
end
|
||||
|
||||
def install_path(install_path, name, version)
|
||||
File.join(install_path, "#{name}-#{version}")
|
||||
end
|
||||
|
||||
def symlink_path(install_path, name)
|
||||
File.join(install_path, name)
|
||||
end
|
||||
|
||||
def bin_path(install_path, name)
|
||||
File.join(install_path, name, 'bin')
|
||||
end
|
||||
|
||||
def sbin_path(install_path, name)
|
||||
File.join(install_path, name, 'sbin')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Puppet::Parser::Scope
|
||||
include Puppet::Modules::CommonDirectories
|
||||
end
|
9
shared/lib/puppet/parser/functions/bin_path.rb
Normal file
9
shared/lib/puppet/parser/functions/bin_path.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require 'puppet/modules/common_directories'
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:bin_path, :type => :rvalue) do |args|
|
||||
bin_path(lookupvar('base::install_path'), *args)
|
||||
end
|
||||
end
|
||||
|
||||
|
8
shared/lib/puppet/parser/functions/build_path.rb
Normal file
8
shared/lib/puppet/parser/functions/build_path.rb
Normal file
@ -0,0 +1,8 @@
|
||||
require 'puppet/modules/common_directories'
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:build_path, :type => :rvalue) do |args|
|
||||
build_path(lookupvar('base::src_path'), *args)
|
||||
end
|
||||
end
|
||||
|
8
shared/lib/puppet/parser/functions/install_path.rb
Normal file
8
shared/lib/puppet/parser/functions/install_path.rb
Normal file
@ -0,0 +1,8 @@
|
||||
require 'puppet/modules/common_directories'
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:install_path, :type => :rvalue) do |args|
|
||||
install_path(lookupvar('base::install_path'), *args)
|
||||
end
|
||||
end
|
||||
|
9
shared/lib/puppet/parser/functions/sbin_path.rb
Normal file
9
shared/lib/puppet/parser/functions/sbin_path.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require 'puppet/modules/common_directories'
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:sbin_path, :type => :rvalue) do |args|
|
||||
sbin_path(lookupvar('base::install_path'), *args)
|
||||
end
|
||||
end
|
||||
|
||||
|
8
shared/lib/puppet/parser/functions/symlink_path.rb
Normal file
8
shared/lib/puppet/parser/functions/symlink_path.rb
Normal file
@ -0,0 +1,8 @@
|
||||
require 'puppet/modules/common_directories'
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:symlink_path, :type => :rvalue) do |args|
|
||||
symlink_path(lookupvar('base::install_path'), *args)
|
||||
end
|
||||
end
|
||||
|
38
shared/lib/puppet/provider/bash_rc/install.rb
Normal file
38
shared/lib/puppet/provider/bash_rc/install.rb
Normal file
@ -0,0 +1,38 @@
|
||||
Puppet::Type.type(:bash_rc).provide(:install) do
|
||||
desc "Configure /etc/bash.bashrc to also load from /etc/bash.bashrc.d/*.sh"
|
||||
|
||||
def create
|
||||
data.unshift %{for file in `find #{dir} -name "*.sh" -type f`; do source $file; done}
|
||||
data.unshift %{# #{file} managed by puppet}
|
||||
|
||||
save
|
||||
|
||||
FileUtils.mkdir_p dir
|
||||
end
|
||||
|
||||
def destroy
|
||||
data.shift
|
||||
data.shift
|
||||
|
||||
save
|
||||
|
||||
FileUtils.rm_rf dir
|
||||
end
|
||||
|
||||
def exists?
|
||||
data.first['puppet']
|
||||
end
|
||||
|
||||
private
|
||||
def data
|
||||
@data ||= File.readlines(file)
|
||||
end
|
||||
|
||||
def save
|
||||
File.open(file, 'wb') { |fh| fh.print data.collect(&:strip).join("\n") }
|
||||
end
|
||||
|
||||
def file ; '/etc/bash.bashrc' ; end
|
||||
def dir ; '/etc/bash.bashrc.d' ; end
|
||||
end
|
||||
|
21
shared/lib/puppet/provider/bash_rc_d/install.rb
Normal file
21
shared/lib/puppet/provider/bash_rc_d/install.rb
Normal file
@ -0,0 +1,21 @@
|
||||
Puppet::Type.type(:bash_rc_d).provide(:install) do
|
||||
desc "Configure a new directory to be added to every user's PATH"
|
||||
|
||||
def create
|
||||
file.open('wb') { |fh| fh.puts "export PATH=#{@resource[:path]}/#{@resource[:name]}/bin:$PATH" }
|
||||
end
|
||||
|
||||
def destroy
|
||||
file.unlink
|
||||
end
|
||||
|
||||
def exists?
|
||||
file.file?
|
||||
end
|
||||
|
||||
private
|
||||
def file
|
||||
Pathname("/etc/bash.bashrc.d/#{@resource[:name]}.sh")
|
||||
end
|
||||
end
|
||||
|
25
shared/lib/puppet/provider/configure/action.rb
Normal file
25
shared/lib/puppet/provider/configure/action.rb
Normal file
@ -0,0 +1,25 @@
|
||||
Puppet::Type.type(:configure).provide(:action) do
|
||||
desc "Configure a program to install"
|
||||
|
||||
def create
|
||||
system %{bash -c '#{path} cd #{@resource[:build_path]} ; make clean ; make distclean ; ./configure --prefix=#{@resource[:install_path]} #{@resource[:options]}'}.tap { |o| p o }
|
||||
end
|
||||
|
||||
def destroy
|
||||
File.unlink config_status
|
||||
end
|
||||
|
||||
def exists?
|
||||
File.file? config_status
|
||||
end
|
||||
|
||||
private
|
||||
def config_status
|
||||
File.join(@resource[:build_path], 'config.status')
|
||||
end
|
||||
|
||||
def path
|
||||
@resource[:path].empty? ? '' : "export PATH=#{@resource[:path]}:$PATH ; "
|
||||
end
|
||||
end
|
||||
|
36
shared/lib/puppet/provider/download_and_unpack/action.rb
Normal file
36
shared/lib/puppet/provider/download_and_unpack/action.rb
Normal file
@ -0,0 +1,36 @@
|
||||
Puppet::Type.type(:download_and_unpack).provide(:action) do
|
||||
desc "Download an unpack a remote repository"
|
||||
|
||||
def create
|
||||
system %{bash -c 'cd #{@resource[:src_path]} ; (curl #{@resource[:url]} | tar #{tar_command} -)'}
|
||||
end
|
||||
|
||||
def destroy
|
||||
FileUtils.rm_rf dir
|
||||
end
|
||||
|
||||
def exists?
|
||||
File.directory?(dir)
|
||||
end
|
||||
|
||||
private
|
||||
def file
|
||||
File.join(@resource[:src_path], File.basename(@resource[:url]))
|
||||
end
|
||||
|
||||
def dir
|
||||
file.gsub(%r{\.tar\.(gz|bz2)$}, '')
|
||||
end
|
||||
|
||||
def tar_command
|
||||
case @resource[:url]
|
||||
when /\.gz/
|
||||
"zxvf"
|
||||
when /\.bz2/
|
||||
"jxvf"
|
||||
else
|
||||
raise StandardError.new("Unknown format: #{@resource[:src_path]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
31
shared/lib/puppet/provider/gem/gem_install.rb
Normal file
31
shared/lib/puppet/provider/gem/gem_install.rb
Normal file
@ -0,0 +1,31 @@
|
||||
Puppet::Type.type(:gem).provide(:install) do
|
||||
desc "Install a Ruby Gem"
|
||||
|
||||
def create
|
||||
gem_command('install --no-ri --no-rdoc')
|
||||
end
|
||||
|
||||
def destroy
|
||||
system gem_command('uninstall -x -I')
|
||||
end
|
||||
|
||||
def exists?
|
||||
system gem_command('list -i')
|
||||
$?.exitstatus == 0
|
||||
end
|
||||
|
||||
private
|
||||
def version
|
||||
version = ''
|
||||
if @resource[:version] && !@resource[:version].empty?
|
||||
version = " -v #{@resource[:version]}"
|
||||
end
|
||||
version
|
||||
end
|
||||
|
||||
def gem_command(what)
|
||||
command = %{bash -c 'PATH=#{@resource[:path]} gem #{what} #{@resource[:name]} #{version}'}
|
||||
%x{#{command}}
|
||||
end
|
||||
end
|
||||
|
69
shared/lib/puppet/provider/god_init/install.rb
Normal file
69
shared/lib/puppet/provider/god_init/install.rb
Normal file
@ -0,0 +1,69 @@
|
||||
require 'erb'
|
||||
|
||||
Puppet::Type.type(:god_init).provide(:install) do
|
||||
desc "Install a God script"
|
||||
|
||||
def create
|
||||
File.open(file, 'wb') { |fh| fh.print(ERB.new(config).result(binding)) }
|
||||
end
|
||||
|
||||
def destroy
|
||||
File.unlink file
|
||||
end
|
||||
|
||||
def exists?
|
||||
File.file? file
|
||||
end
|
||||
|
||||
private
|
||||
def file
|
||||
"/etc/god.d/#{@resource[:name]}.god"
|
||||
end
|
||||
|
||||
def start
|
||||
@resource[:start] || ''
|
||||
end
|
||||
|
||||
def stop
|
||||
@resource[:stop] || ''
|
||||
end
|
||||
|
||||
def name
|
||||
@resource[:name] || ''
|
||||
end
|
||||
|
||||
def pid_file
|
||||
@resource[:pid_file] || ''
|
||||
end
|
||||
|
||||
def config
|
||||
<<-GOD
|
||||
God.watch do |w|
|
||||
w.name = "<%= name %>"
|
||||
w.interval = 15.seconds
|
||||
|
||||
w.start = lambda { system("<%= start %>") }
|
||||
w.start_grace = 15.seconds
|
||||
|
||||
<% if !stop.empty? %>
|
||||
w.stop = lambda { system("<%= stop %>") }
|
||||
w.stop_grace = 15.seconds
|
||||
<% 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 = 5.seconds
|
||||
c.running = false
|
||||
end
|
||||
end
|
||||
end
|
||||
GOD
|
||||
end
|
||||
end
|
||||
|
24
shared/lib/puppet/provider/make_and_install/action.rb
Normal file
24
shared/lib/puppet/provider/make_and_install/action.rb
Normal file
@ -0,0 +1,24 @@
|
||||
require 'fileutils'
|
||||
|
||||
Puppet::Type.type(:make_and_install).provide(:action) do
|
||||
desc "Configure a program to install"
|
||||
|
||||
def create
|
||||
system %{bash -c 'cd #{@resource[:build_path]} ; make && make install'}
|
||||
File.symlink(@resource[:install_path], symlink_path)
|
||||
end
|
||||
|
||||
def destroy
|
||||
FileUtils.rm_rf @resource[:install_path]
|
||||
FileUtils.rm_rf symlink_path
|
||||
end
|
||||
|
||||
def exists?
|
||||
File.directory?(@resource[:install_path]) && File.symlink?(symlink_path)
|
||||
end
|
||||
|
||||
private
|
||||
def symlink_path
|
||||
File.join(File.dirname(@resource[:install_path]), @resource[:name])
|
||||
end
|
||||
end
|
11
shared/lib/puppet/type/bash_rc.rb
Normal file
11
shared/lib/puppet/type/bash_rc.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require 'fileutils'
|
||||
|
||||
Puppet::Type.newtype(:bash_rc) do
|
||||
@doc = "An /etc/bash.bashrc file configured to also load from /etc/bash.bashrc.d/*.sh"
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name) do
|
||||
desc "The useless name"
|
||||
end
|
||||
end
|
14
shared/lib/puppet/type/bash_rc_d.rb
Normal file
14
shared/lib/puppet/type/bash_rc_d.rb
Normal file
@ -0,0 +1,14 @@
|
||||
Puppet::Type.newtype(:bash_rc_d) do
|
||||
@doc = "A /etc/bash.bashrc.d/*.sh file, used to add vendored applications to the path"
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name) do
|
||||
desc "The name of the application to add"
|
||||
end
|
||||
|
||||
newparam(:path) do
|
||||
desc "The base path for vendored applications"
|
||||
end
|
||||
end
|
||||
|
26
shared/lib/puppet/type/configure.rb
Normal file
26
shared/lib/puppet/type/configure.rb
Normal file
@ -0,0 +1,26 @@
|
||||
Puppet::Type.newtype(:configure) do
|
||||
@doc = "Configuring a program to install"
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name) do
|
||||
desc "The name of the program"
|
||||
end
|
||||
|
||||
newparam(:build_path) do
|
||||
desc "The location of downloaded sources"
|
||||
end
|
||||
|
||||
newparam(:install_path) do
|
||||
desc "The location to install builds"
|
||||
end
|
||||
|
||||
newparam(:options) do
|
||||
desc "Options to build the software"
|
||||
end
|
||||
|
||||
newparam(:path) do
|
||||
desc "Path for executables"
|
||||
end
|
||||
end
|
||||
|
22
shared/lib/puppet/type/download_and_unpack.rb
Normal file
22
shared/lib/puppet/type/download_and_unpack.rb
Normal file
@ -0,0 +1,22 @@
|
||||
Puppet::Type.newtype(:download_and_unpack) do
|
||||
@doc = "A downloaded file, unpacked"
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name) do
|
||||
desc "The name of the file"
|
||||
end
|
||||
|
||||
newparam(:url) do
|
||||
desc "The source of the file"
|
||||
end
|
||||
|
||||
newparam(:src_path) do
|
||||
desc "The location where the file should be downloaded"
|
||||
end
|
||||
|
||||
newparam(:version) do
|
||||
desc "The version to install"
|
||||
end
|
||||
end
|
||||
|
18
shared/lib/puppet/type/gem.rb
Normal file
18
shared/lib/puppet/type/gem.rb
Normal file
@ -0,0 +1,18 @@
|
||||
Puppet::Type.newtype(:gem) do
|
||||
@doc = 'A Ruby Gem'
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name) do
|
||||
desc "The name of the gem"
|
||||
end
|
||||
|
||||
newparam(:version) do
|
||||
desc "The version of the gem"
|
||||
end
|
||||
|
||||
newparam(:path) do
|
||||
desc "The binary search path"
|
||||
end
|
||||
end
|
||||
|
22
shared/lib/puppet/type/god_init.rb
Normal file
22
shared/lib/puppet/type/god_init.rb
Normal file
@ -0,0 +1,22 @@
|
||||
Puppet::Type.newtype(:god_init) do
|
||||
@doc = "A God configuration"
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name) do
|
||||
desc "The name of the process"
|
||||
end
|
||||
|
||||
newparam(:start) do
|
||||
desc "The command to start the process"
|
||||
end
|
||||
|
||||
newparam(:stop) do
|
||||
desc "The command to stop the process"
|
||||
end
|
||||
|
||||
newparam(:pid_file) do
|
||||
desc "A pid file"
|
||||
end
|
||||
end
|
||||
|
22
shared/lib/puppet/type/make_and_install.rb
Normal file
22
shared/lib/puppet/type/make_and_install.rb
Normal file
@ -0,0 +1,22 @@
|
||||
Puppet::Type.newtype(:make_and_install) do
|
||||
@doc = "Make and install a program"
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name) do
|
||||
desc "The name of the program"
|
||||
end
|
||||
|
||||
newparam(:build_path) do
|
||||
desc "The location of downloaded sources"
|
||||
end
|
||||
|
||||
newparam(:install_path) do
|
||||
desc "The location to install builds"
|
||||
end
|
||||
|
||||
newparam(:options) do
|
||||
desc "Options to build the software"
|
||||
end
|
||||
end
|
||||
|
30
shared/modules/build_and_install/manifests/init.pp
Normal file
30
shared/modules/build_and_install/manifests/init.pp
Normal file
@ -0,0 +1,30 @@
|
||||
define build_and_install($version, $source, $path = '', $configure = '') {
|
||||
$full_source = inline_template($source)
|
||||
|
||||
$build_path = build_path($name, $version)
|
||||
$install_path = install_path($name, $version)
|
||||
$symlink_path = symlink_path($name)
|
||||
|
||||
download_and_unpack { $name:
|
||||
url => $full_source,
|
||||
src_path => $base::src_path,
|
||||
ensure => present
|
||||
}
|
||||
|
||||
configure { $name:
|
||||
build_path => $build_path,
|
||||
install_path => $install_path,
|
||||
options => $configure,
|
||||
path => $path,
|
||||
require => Download_and_unpack[$name],
|
||||
ensure => present
|
||||
}
|
||||
|
||||
make_and_install { $name:
|
||||
build_path => $build_path,
|
||||
install_path => $install_path,
|
||||
require => Configure[$name],
|
||||
ensure => present
|
||||
}
|
||||
}
|
||||
|
5
skel/apply.erb
Normal file
5
skel/apply.erb
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p ~/.puppet
|
||||
<%= use_sudo ? "sudo env" : "" %> RUBYLIB="${PWD}/shared/lib" <%= with_additional_puppet_bin_path %> puppet apply --confdir=$PWD --modulepath=$PWD/modules:$PWD/shared/modules --templatedir=$PWD/templates -v $@ manifests/site.pp
|
||||
|
16
skel/debian/bootstrap.erb
Normal file
16
skel/debian/bootstrap.erb
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! $UID -eq 0 ]; then
|
||||
sudo $0
|
||||
exit
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
apt-get -y upgrade
|
||||
apt-get -y dist-upgrade
|
||||
apt-get install -y rubygems1.8 puppet
|
||||
apt-get remove -y puppet facter
|
||||
gem install puppet --no-ri --no-rdoc
|
||||
./apply
|
||||
shutdown -r now
|
||||
|
33
skel/redhat/bootstrap.erb
Normal file
33
skel/redhat/bootstrap.erb
Normal file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
base_dir=<%= base_dir %>
|
||||
|
||||
if [ ! -f ${base_dir}/ruby-base/bin/ruby ]; then
|
||||
echo "Installing Ruby to ${base_dir}/ruby-base..."
|
||||
mkdir -p ${base_dir}/tmp
|
||||
cd ${base_dir}/tmp
|
||||
|
||||
RUBY=ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.9.2-p290.tar.bz2
|
||||
RUBY_FILENAME=${RUBY##*/}
|
||||
RUBY_VERSION=${RUBY_FILENAME%%.tar.bz2}
|
||||
curl $RUBY > $RUBY_FILENAME
|
||||
rm -Rf $RUBY_VERSION
|
||||
tar jxvf $RUBY_FILENAME
|
||||
mv $RUBY_VERSION "$RUBY_VERSION-base"
|
||||
|
||||
cd "$RUBY_VERSION-base"
|
||||
|
||||
./configure --prefix=${base_dir}/ruby-base --disable-pthread
|
||||
make
|
||||
make install
|
||||
fi
|
||||
|
||||
PATH=${base_dir}/ruby-base/bin:$PATH
|
||||
|
||||
if [ ! -f ${base_dir}/ruby-base/bin/puppet ]; then
|
||||
echo "Installing Puppet..."
|
||||
gem install puppet
|
||||
fi
|
||||
|
||||
mkdir ~/.puppet
|
||||
./apply
|
14
skel/rename.erb
Normal file
14
skel/rename.erb
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! $UID -eq 0 ]; then
|
||||
sudo $0 $1
|
||||
exit
|
||||
fi
|
||||
|
||||
echo $1 > /etc/hostname
|
||||
cat /etc/hosts | sed "s#^\\(127.0.0.1\\)\\(.*\\)\$#\\1 $1 \\2#g" > /etc/hosts.tmp
|
||||
mv /etc/hosts.tmp /etc/hosts
|
||||
hostname $1
|
||||
|
||||
echo "Server renamed to $1"
|
||||
|
Loading…
Reference in New Issue
Block a user