From 64c306bed80ac65cb254074beed81f58d7bff6c3 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 8 Dec 2011 08:58:22 -0500 Subject: [PATCH] a ton of stuff --- README.md | 6 ++++++ shared/lib/puppet/modules/common_directories.rb | 5 +++++ shared/lib/puppet/parser/functions/pid_path.rb | 8 ++++++++ shared/lib/puppet/provider/make_and_install/action.rb | 6 +++++- shared/lib/puppet/type/make_and_install.rb | 4 ++++ shared/modules/build_and_install/manifests/init.pp | 1 + shared/modules/installed_package/manifests/init.pp | 4 ++++ shared/modules/running_service/manifests/init.pp | 3 +++ shared/modules/update_rc_d_defaults/manifests/init.pp | 7 +++++++ 9 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 README.md create mode 100644 shared/lib/puppet/parser/functions/pid_path.rb create mode 100644 shared/modules/installed_package/manifests/init.pp create mode 100644 shared/modules/running_service/manifests/init.pp create mode 100644 shared/modules/update_rc_d_defaults/manifests/init.pp diff --git a/README.md b/README.md new file mode 100644 index 0000000..3610a25 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +My Puppet stuff, all collected together into one gem. Uses +Capistrano to deploy to a remote server and execute the +configs. + +`require "puppet-standalone-mashup/capistrano"` + diff --git a/shared/lib/puppet/modules/common_directories.rb b/shared/lib/puppet/modules/common_directories.rb index 971e2f9..c375c66 100644 --- a/shared/lib/puppet/modules/common_directories.rb +++ b/shared/lib/puppet/modules/common_directories.rb @@ -20,6 +20,10 @@ module Puppet def sbin_path(install_path, name) File.join(install_path, name, 'sbin') end + + def pid_path(pid_path, name) + File.join(pid_path, "#{name}.pid") + end end end end @@ -27,3 +31,4 @@ end class Puppet::Parser::Scope include Puppet::Modules::CommonDirectories end + diff --git a/shared/lib/puppet/parser/functions/pid_path.rb b/shared/lib/puppet/parser/functions/pid_path.rb new file mode 100644 index 0000000..4684cb8 --- /dev/null +++ b/shared/lib/puppet/parser/functions/pid_path.rb @@ -0,0 +1,8 @@ +require 'puppet/modules/common_directories' + +module Puppet::Parser::Functions + newfunction(:pid_path, :type => :rvalue) do |args| + pid_path(lookupvar('base::pid_path'), *args) + end +end + diff --git a/shared/lib/puppet/provider/make_and_install/action.rb b/shared/lib/puppet/provider/make_and_install/action.rb index 188a89a..5cfbcf7 100644 --- a/shared/lib/puppet/provider/make_and_install/action.rb +++ b/shared/lib/puppet/provider/make_and_install/action.rb @@ -4,7 +4,7 @@ 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'} + system %{bash -c '#{path} cd #{@resource[:build_path]} ; make && make install'} File.symlink(@resource[:install_path], symlink_path) end @@ -21,4 +21,8 @@ Puppet::Type.type(:make_and_install).provide(:action) do def symlink_path File.join(File.dirname(@resource[:install_path]), @resource[:name]) end + + def path + @resource[:path].empty? ? '' : "export PATH=#{@resource[:path]}:$PATH ; " + end end diff --git a/shared/lib/puppet/type/make_and_install.rb b/shared/lib/puppet/type/make_and_install.rb index 2445b87..6a9913e 100644 --- a/shared/lib/puppet/type/make_and_install.rb +++ b/shared/lib/puppet/type/make_and_install.rb @@ -18,5 +18,9 @@ Puppet::Type.newtype(:make_and_install) do newparam(:options) do desc "Options to build the software" end + + newparam(:path) do + desc "Binary path to add" + end end diff --git a/shared/modules/build_and_install/manifests/init.pp b/shared/modules/build_and_install/manifests/init.pp index 4380f0c..c8b20ed 100644 --- a/shared/modules/build_and_install/manifests/init.pp +++ b/shared/modules/build_and_install/manifests/init.pp @@ -23,6 +23,7 @@ define build_and_install($version, $source, $path = '', $configure = '') { make_and_install { $name: build_path => $build_path, install_path => $install_path, + path => $path, require => Configure[$name], ensure => present } diff --git a/shared/modules/installed_package/manifests/init.pp b/shared/modules/installed_package/manifests/init.pp new file mode 100644 index 0000000..31a039d --- /dev/null +++ b/shared/modules/installed_package/manifests/init.pp @@ -0,0 +1,4 @@ +define installed_package { + package { $name: ensure => installed } +} + diff --git a/shared/modules/running_service/manifests/init.pp b/shared/modules/running_service/manifests/init.pp new file mode 100644 index 0000000..cefb90c --- /dev/null +++ b/shared/modules/running_service/manifests/init.pp @@ -0,0 +1,3 @@ +define running_service { + service { $name: ensure => running } +} diff --git a/shared/modules/update_rc_d_defaults/manifests/init.pp b/shared/modules/update_rc_d_defaults/manifests/init.pp new file mode 100644 index 0000000..c7c4732 --- /dev/null +++ b/shared/modules/update_rc_d_defaults/manifests/init.pp @@ -0,0 +1,7 @@ +define update_rc_d_defaults { + exec { "update-rc.d-${name}": + command => "update-rc.d ${name} defaults", + path => $base::path + } +} +