From 63b1dfe93312ac80dc156903f7cfd0f00838da1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Santos?= Date: Mon, 6 Jun 2016 16:34:57 +0100 Subject: [PATCH] Fixes #375. Assign environment via constructor. --- providers/cluster.rb | 3 +-- providers/parameter.rb | 3 +-- providers/plugin.rb | 3 +-- providers/policy.rb | 3 +-- providers/user.rb | 9 +++------ providers/vhost.rb | 3 +-- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/providers/cluster.rb b/providers/cluster.rb index b093ae0e..302b73dc 100644 --- a/providers/cluster.rb +++ b/providers/cluster.rb @@ -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 diff --git a/providers/parameter.rb b/providers/parameter.rb index 927d01d3..a6b714aa 100644 --- a/providers/parameter.rb +++ b/providers/parameter.rb @@ -29,8 +29,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! diff --git a/providers/plugin.rb b/providers/plugin.rb index eb2ca653..2092e4b5 100644 --- a/providers/plugin.rb +++ b/providers/plugin.rb @@ -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}" diff --git a/providers/policy.rb b/providers/policy.rb index e4f73455..3f5e77f7 100644 --- a/providers/policy.rb +++ b/providers/policy.rb @@ -29,8 +29,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! diff --git a/providers/user.rb b/providers/user.rb index d62fdb7e..69bafdcb 100644 --- a/providers/user.rb +++ b/providers/user.rb @@ -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}" @@ -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 @@ -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}" diff --git a/providers/vhost.rb b/providers/vhost.rb index 8310318d..a875be5b 100644 --- a/providers/vhost.rb +++ b/providers/vhost.rb @@ -23,8 +23,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}"