Skip to content

Commit

Permalink
Removing the PATH from the execute resource
Browse files Browse the repository at this point in the history
This leverages the environment attribute instead of the PATH which
is being deprecated with chef-client 12.
  • Loading branch information
JJ Asghar committed Dec 5, 2014
1 parent f9db2cc commit 907688e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,11 @@ rabbitmq Cookbook CHANGELOG
===========================
This file is used to list changes made in each version of the rabbitmq cookbook.

v3.5.1 (2014-12-5)
-------------------
#176 Chef-client 12 released and the `PATH` attribute was removed.
This release fixes it.

v3.5.0 (2014-12-2)
-------------------
Song of this Release: 0 to 100/The Catchup by Drake
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Expand Up @@ -3,7 +3,7 @@
maintainer_email 'cookbooks@opscode.com'
license 'Apache 2.0'
description 'Installs and configures RabbitMQ server'
version '3.5.0'
version '3.5.1'
recipe 'rabbitmq', 'Install and configure RabbitMQ'
recipe 'rabbitmq::cluster', 'Set up RabbitMQ clustering.'
recipe 'rabbitmq::plugin_management', 'Manage plugins with node attributes'
Expand Down
10 changes: 2 additions & 8 deletions providers/plugin.rb
Expand Up @@ -17,16 +17,10 @@
# limitations under the License.
#

def plugins_bin_path(return_array = false)
path = ENV.fetch('PATH') + ':/usr/lib/rabbitmq/bin'
return_array ? path.split(':') : path
end

def plugin_enabled?(name)
cmdstr = "rabbitmq-plugins list -e '#{name}\\b'"
cmd = Mixlib::ShellOut.new(cmdstr)
cmd.environment['HOME'] = ENV.fetch('HOME', '/root')
cmd.environment['PATH'] = plugins_bin_path
cmd.run_command
Chef::Log.debug "rabbitmq_plugin_enabled?: #{cmdstr}"
Chef::Log.debug "rabbitmq_plugin_enabled?: #{cmd.stdout}"
Expand All @@ -40,7 +34,7 @@ def plugin_enabled?(name)
unless plugin_enabled?(new_resource.plugin)
execute "rabbitmq-plugins enable #{new_resource.plugin}" do
Chef::Log.info "Enabling RabbitMQ plugin '#{new_resource.plugin}'."
path plugins_bin_path(true)
environment 'PATH' => "#{ENV['PATH']}:/usr/lib/rabbitmq/bin"
new_resource.updated_by_last_action(true)
end
end
Expand All @@ -50,7 +44,7 @@ def plugin_enabled?(name)
if plugin_enabled?(new_resource.plugin)
execute "rabbitmq-plugins disable #{new_resource.plugin}" do
Chef::Log.info "Disabling RabbitMQ plugin '#{new_resource.plugin}'."
path plugins_bin_path(true)
environment 'PATH' => "#{ENV['PATH']}:/usr/lib/rabbitmq/bin"
new_resource.updated_by_last_action(true)
end
end
Expand Down

0 comments on commit 907688e

Please sign in to comment.