From 6ead3f7c5fb40ffe94b6919530ecf346de3aa9b2 Mon Sep 17 00:00:00 2001 From: drag00n Date: Fri, 16 Jan 2015 11:08:03 -0500 Subject: [PATCH 1/2] Add gpg-check to user_install recipe. RVM fails on machines with gpg installed. This fix checks for the existence of gpg on the system and imports the appropriate key as defined by the attribute. Use of a ruby_block will allow for some code reuse in the LWRP release. --- recipes/user_install.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/recipes/user_install.rb b/recipes/user_install.rb index 386eb668..e67a4057 100644 --- a/recipes/user_install.rb +++ b/recipes/user_install.rb @@ -26,6 +26,27 @@ # if user hash is not a hash (i.e. set to true), init an empty Hash opts = Hash.new if opts == true + ruby_block 'Conditionally add RVM gpg key' do + block do + cmd = Mixlib::ShellOut.new('which gpg2 || which gpg') + cmd.run_command + + if cmd.exitstatus == 0 + gpg_command = cmd.stdout.chomp + + exec = Chef::Resource::Execute.new 'Add RVM gpg key', run_context + exec.command "#{gpg_command} --keyserver hkp://keys.gnupg.net --recv-keys #{node['rvm']['gpg_key']}" + exec.user rvm_user['user'] + exec.environment 'HOME' => rvm_prefix + exec.guard_interpreter :bash + exec.not_if "#{gpg_command} -k #{node['rvm']['gpg_key']} > /dev/null", user: rvm_user['user'], environment: { 'HOME' => rvm_prefix } + exec.run_action :run + else + Chef::Log.info 'Skipping adding RVM key because gpg/gpg2 not installed' + end + end + end + rvm_installation(user.to_s) do %w(installer_url installer_flags install_pkgs rvmrc_template_source rvmrc_template_cookbook rvmrc_env action From 9aefc997b23ce792f6c72a00ac15584cad4eac32 Mon Sep 17 00:00:00 2001 From: cmluciano Date: Wed, 4 Mar 2015 12:29:16 -0500 Subject: [PATCH 2/2] Add a user tag so that the foodcritic can maybe sense uniqueness --- recipes/user_install.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/user_install.rb b/recipes/user_install.rb index e67a4057..0c134325 100644 --- a/recipes/user_install.rb +++ b/recipes/user_install.rb @@ -26,7 +26,7 @@ # if user hash is not a hash (i.e. set to true), init an empty Hash opts = Hash.new if opts == true - ruby_block 'Conditionally add RVM gpg key' do + ruby_block "Conditionally add RVM gpg key #{user}" do block do cmd = Mixlib::ShellOut.new('which gpg2 || which gpg') cmd.run_command