From 70eb1946152c98c4fc3dc3c9f8dafe52e826c259 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 4 May 2012 13:54:50 -0400 Subject: [PATCH] more updates anc cleanups --- .../debian-base/manifests/init.pp | 1 + .../additional-modules/nginx/manifests/init.pp | 1 - shared/additional-modules/ruby/manifests/init.pp | 2 +- shared/lib/puppet/modules/common_directories.rb | 4 ++++ shared/lib/puppet/parser/functions/share_path.rb | 2 +- .../provider/download_and_unpack/action.rb | 16 ++++++++++++++-- shared/lib/puppet/type/download_and_unpack.rb | 4 ++++ .../modules/build_and_install/manifests/init.pp | 4 +++- 8 files changed, 28 insertions(+), 6 deletions(-) diff --git a/shared/additional-modules/debian-base/manifests/init.pp b/shared/additional-modules/debian-base/manifests/init.pp index 6fe2e9a..5903312 100644 --- a/shared/additional-modules/debian-base/manifests/init.pp +++ b/shared/additional-modules/debian-base/manifests/init.pp @@ -13,6 +13,7 @@ class base { $pid_path = "/var/run" $log_path = "/var/log" $local_path = $install_path + $share_path = "/usr/local/share" } node default { diff --git a/shared/additional-modules/nginx/manifests/init.pp b/shared/additional-modules/nginx/manifests/init.pp index e6ca1c9..9df2516 100644 --- a/shared/additional-modules/nginx/manifests/init.pp +++ b/shared/additional-modules/nginx/manifests/init.pp @@ -32,7 +32,6 @@ class nginx($version, $max_pool_size = 20) { restart => "${nginx_stop} ; ${nginx_start}", pid_file => $pid_file, ensure => present, - notify => Service['god'], require => Exec['install-passenger'] } diff --git a/shared/additional-modules/ruby/manifests/init.pp b/shared/additional-modules/ruby/manifests/init.pp index 81bb271..3261246 100644 --- a/shared/additional-modules/ruby/manifests/init.pp +++ b/shared/additional-modules/ruby/manifests/init.pp @@ -9,7 +9,7 @@ class ruby($version, $configure = "--disable-install-doc", $build_path = '') { path => "${base::path}:${path}:${build_path}" } - gem { [ 'bundler', 'penchant' ]: + gem { [ 'bundler', 'penchant', 'thor' ]: require => Build_and_install[$name], path => $with_ruby_path, ensure => present diff --git a/shared/lib/puppet/modules/common_directories.rb b/shared/lib/puppet/modules/common_directories.rb index c375c66..094a9db 100644 --- a/shared/lib/puppet/modules/common_directories.rb +++ b/shared/lib/puppet/modules/common_directories.rb @@ -24,6 +24,10 @@ module Puppet def pid_path(pid_path, name) File.join(pid_path, "#{name}.pid") end + + def share_path(share_path, name) + File.join(share_path, name) + end end end end diff --git a/shared/lib/puppet/parser/functions/share_path.rb b/shared/lib/puppet/parser/functions/share_path.rb index 4dd45a4..c4459e1 100644 --- a/shared/lib/puppet/parser/functions/share_path.rb +++ b/shared/lib/puppet/parser/functions/share_path.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions newfunction(:share_path, :type => :rvalue) do |args| - File.join(lookupvar('base::share_path'), *args) + share_path(lookupvar('base::share_path'), *args) end end diff --git a/shared/lib/puppet/provider/download_and_unpack/action.rb b/shared/lib/puppet/provider/download_and_unpack/action.rb index 62bdccc..62af3aa 100644 --- a/shared/lib/puppet/provider/download_and_unpack/action.rb +++ b/shared/lib/puppet/provider/download_and_unpack/action.rb @@ -4,14 +4,18 @@ Puppet::Type.type(:download_and_unpack).provide(:action) do def create system %{bash -c 'cd #{@resource[:src_path]} ; (curl #{@resource[:url]} | tar #{tar_command} -)'} raise StandardError.new("Could not download") if $?.exitstatus != 0 + + if original_name + system %{bash -c 'cd #{@resource[:src_path]} && mv #{original_name} #{target_dir}'} + end end def destroy - FileUtils.rm_rf dir + FileUtils.rm_rf target_dir end def exists? - File.directory?(dir) + File.directory?(File.join(@resource[:src_path], target_dir)) end private @@ -19,10 +23,18 @@ Puppet::Type.type(:download_and_unpack).provide(:action) do File.join(@resource[:src_path], File.basename(@resource[:url])) end + def target_dir + "#{@resource[:name]}-#{@resource[:version]}" + end + def dir file.gsub(%r{\.tar\.(gz|bz2)$}, '') end + def original_name + (@resource[:original_name] || '').empty? ? nil : @resource[:original_name] + end + def tar_command case @resource[:url] when /\.gz/ diff --git a/shared/lib/puppet/type/download_and_unpack.rb b/shared/lib/puppet/type/download_and_unpack.rb index 67a2f46..e949ae4 100644 --- a/shared/lib/puppet/type/download_and_unpack.rb +++ b/shared/lib/puppet/type/download_and_unpack.rb @@ -18,5 +18,9 @@ Puppet::Type.newtype(:download_and_unpack) do newparam(:version) do desc "The version to install" end + + newparam(:original_name) do + desc "The directory name that the software unpacks as" + end end diff --git a/shared/modules/build_and_install/manifests/init.pp b/shared/modules/build_and_install/manifests/init.pp index 3d7f401..823e967 100644 --- a/shared/modules/build_and_install/manifests/init.pp +++ b/shared/modules/build_and_install/manifests/init.pp @@ -1,4 +1,4 @@ -define build_and_install($version, $source, $path = '', $configure = '', $config_status = 'config.status') { +define build_and_install($version, $original_name = '', $source, $path = '', $configure = '', $config_status = 'config.status') { $full_source = inline_template($source) $build_path = build_path($name, $version) @@ -8,6 +8,8 @@ define build_and_install($version, $source, $path = '', $configure = '', $config download_and_unpack { $name: url => $full_source, src_path => $base::src_path, + original_name => $original_name, + version => $version, ensure => present }