Skip to content

Commit

Permalink
Fixes #375. Assign environment via constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruizink committed Jun 6, 2016
1 parent 1253a71 commit 0fe801d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 16 deletions.
3 changes: 1 addition & 2 deletions providers/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

# Get ShellOut
def get_shellout(cmd)
sh_cmd = Mixlib::ShellOut.new(cmd)
sh_cmd.environment = shell_environment
sh_cmd = Mixlib::ShellOut.new(cmd, :env => shell_environment)
sh_cmd
end

Expand Down
3 changes: 1 addition & 2 deletions providers/parameter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def parameter_exists?(vhost, name)
cmd << " -p #{Shellwords.escape vhost}" unless vhost.nil?
cmd << " |grep '#{name}\\b'"

cmd = Mixlib::ShellOut.new(cmd)
cmd.environment = shell_environment
cmd = Mixlib::ShellOut.new(cmd, :env => shell_environment)
cmd.run_command
begin
cmd.error!
Expand Down
3 changes: 1 addition & 2 deletions providers/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
def plugin_enabled?(name)
ENV['PATH'] = "#{ENV['PATH']}:/usr/lib/rabbitmq/bin"
cmdstr = "rabbitmq-plugins list -e '#{name}\\b'"
cmd = Mixlib::ShellOut.new(cmdstr)
cmd.environment = shell_environment
cmd = Mixlib::ShellOut.new(cmdstr, :env => shell_environment)
cmd.run_command
Chef::Log.debug "rabbitmq_plugin_enabled?: #{cmdstr}"
Chef::Log.debug "rabbitmq_plugin_enabled?: #{cmd.stdout}"
Expand Down
3 changes: 1 addition & 2 deletions providers/policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def policy_exists?(vhost, name)
cmd << " -p #{Shellwords.escape vhost}" unless vhost.nil?
cmd << " |grep '#{name}\\b'"

cmd = Mixlib::ShellOut.new(cmd)
cmd.environment = shell_environment
cmd = Mixlib::ShellOut.new(cmd, :env => shell_environment)
cmd.run_command
begin
cmd.error!
Expand Down
9 changes: 3 additions & 6 deletions providers/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

def user_exists?(name)
cmd = "rabbitmqctl -q list_users |grep '^#{name}\\s'"
cmd = Mixlib::ShellOut.new(cmd)
cmd.environment = shell_environment
cmd = Mixlib::ShellOut.new(cmd, :env => shell_environment)
cmd.run_command
Chef::Log.debug "rabbitmq_user_exists?: #{cmd}"
Chef::Log.debug "rabbitmq_user_exists?: #{cmd.stdout}"
Expand All @@ -38,8 +37,7 @@ def user_exists?(name)

def user_has_tag?(name, tag)
cmd = 'rabbitmqctl -q list_users'
cmd = Mixlib::ShellOut.new(cmd)
cmd.environment = shell_environment
cmd = Mixlib::ShellOut.new(cmd, :env => shell_environment)
cmd.run_command
user_list = cmd.stdout
tags = user_list.match(/^#{name}\s+\[(.*?)\]/)[1].split
Expand All @@ -62,8 +60,7 @@ def user_has_tag?(name, tag)
def user_has_permissions?(name, vhost, perm_list = nil)
vhost = '/' if vhost.nil? # rubocop:enable all
cmd = "rabbitmqctl -q list_user_permissions #{name} | grep \"^#{vhost}\\s\""
cmd = Mixlib::ShellOut.new(cmd)
cmd.environment = shell_environment
cmd = Mixlib::ShellOut.new(cmd, :env => shell_environment)
cmd.run_command
Chef::Log.debug "rabbitmq_user_has_permissions?: #{cmd}"
Chef::Log.debug "rabbitmq_user_has_permissions?: #{cmd.stdout}"
Expand Down
3 changes: 1 addition & 2 deletions providers/vhost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

def vhost_exists?(name)
cmd = "rabbitmqctl -q list_vhosts | grep ^#{name}$"
cmd = Mixlib::ShellOut.new(cmd)
cmd.environment = shell_environment
cmd = Mixlib::ShellOut.new(cmd, :env => shell_environment)
cmd.run_command
Chef::Log.debug "rabbitmq_vhost_exists?: #{cmd}"
Chef::Log.debug "rabbitmq_vhost_exists?: #{cmd.stdout}"
Expand Down

0 comments on commit 0fe801d

Please sign in to comment.