Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 0.5.1, 0.5.2
-
Fix Version/s: 0.5.4
-
Component/s: None
-
Labels:None
-
Environment:
0.5.3 HEAD
Description
- attributes
nagios Mash.new
nagios[:users] = Array.new
nagios[:users] << {:username => "admin", :password => "whatever"}
define :add_htpasswd_users do
params[:users].each do |auth|
execute "add_htpasswd_#{auth[:username]}" do
command "echo '#{auth[:username]}:#{auth[:password]}' >> #{params[:name]}"
not_if do
if File.exists?(params[:name])
File.open(params[:name]) do |password_file|
password_file.detect { |line| line =~ /#{auth[:username]}:#{auth[:password]}/ }
end
end
end
end
end
end
The following works:
blah = node[:nagios][:users]
add_htpasswd_users "/tmp/out" do
users(blah)
end
This one however doesn't work, and raises a weird TypeError
add_htpasswd_users "/tmp/out" do
users(node[:nagios][:users])
end
/var/chef/cache/cookbooks/testing/recipes/default.rb:32:in `[]': Symbol as array index (TypeError)
from /var/chef/cache/cookbooks/testing/recipes/default.rb:32:in `from_file'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/recipe.rb:165:in `instance_eval'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/recipe.rb:165:in `method_missing'
from /var/chef/cache/cookbooks/testing/recipes/default.rb:31:in `from_file'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/cookbook.rb:139:in `load_recipe'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/compile.rb:109:in `load_recipes'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/compile.rb:101:in `each'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/compile.rb:101:in `load_recipes'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/client.rb:339:in `converge'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/client.rb:76:in `run'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/bin/chef-client:114
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/bin/chef-client:108:in `loop'
from /Library/Ruby/Gems/1.8/gems/chef-0.5.3/bin/chef-client:108
from /usr/bin/chef-client:19:in `load'
from /usr/bin/chef-client:19
Need technical input on this one, Adam.