diff --git a/lib/puppet-standalone-mashup/capistrano.rb b/lib/puppet-standalone-mashup/capistrano.rb index 1781443..ff2a9a2 100644 --- a/lib/puppet-standalone-mashup/capistrano.rb +++ b/lib/puppet-standalone-mashup/capistrano.rb @@ -59,12 +59,20 @@ Capistrano::Configuration.instance.load do top.copy_skel end + def as_user(cmd) + if use_sudo + %{#{sudo} su -c "#{cmd}" #{user}} + else + cmd + end + end + desc "Apply the configuration" task :apply do top.copy_files top.rename if rename_server && wrong_server_name? - run "cd #{puppet_dir} && #{sudo} ./apply" + run "cd #{puppet_dir} && #{as_user("./apply")}" end def wrong_server_name? @@ -76,12 +84,12 @@ Capistrano::Configuration.instance.load do top.copy_files top.rename if rename_server - run "cd #{puppet_dir} && #{sudo} ./bootstrap" - top.reboot + run "cd #{puppet_dir} && #{as_user("./bootstrap")}" + top.bootstrap_reboot end desc "Reboot the server after bootstrapping" - task :reboot do + task :bootstrap_reboot do run "#{sudo} shutdown -r now" end diff --git a/skel/apply.erb b/skel/apply.erb index 6eb7503..3d83096 100644 --- a/skel/apply.erb +++ b/skel/apply.erb @@ -1,7 +1,7 @@ #!/bin/bash mkdir -p ~/.puppet -<%= use_sudo ? "sudo env" : "" %> RUBYLIB="${PWD}/lib:${PWD}/shared/lib" \ +RUBYLIB="${PWD}/lib:${PWD}/shared/lib" \ <%= with_additional_puppet_bin_path %> \ puppet apply <%= additional_puppet_options %> \ --confdir=$PWD \ diff --git a/skel/redhat/bootstrap.erb b/skel/redhat/bootstrap.erb index ebcb96a..a021d7c 100644 --- a/skel/redhat/bootstrap.erb +++ b/skel/redhat/bootstrap.erb @@ -15,7 +15,7 @@ if [ ! -f ${base_dir}/ruby-base/bin/ruby ]; then rm -Rf yaml-$YAML_VERSION* curl http://pyyaml.org/download/libyaml/yaml-$YAML_VERSION.tar.gz > yaml.tar.gz - tar zxvf c$yaml.tar.gz + tar zxvf yaml.tar.gz mv yaml-$YAML_VERSION yaml-$YAML_VERSION-base cd yaml-$YAML_VERSION-base ./configure --prefix=${opt_dir} @@ -49,5 +49,4 @@ if [ ! -f ${base_dir}/ruby-base/bin/puppet ]; then fi mkdir -p ~/.puppet -cd /tmp/puppet -./apply +