0

My opsworks deployment's node doesnt have [:deploy] object This is my Chef script

if node[:deploy] === nil

    Chef::Log.info("No deployment..")
    node[:deploy].each do |app, deploy|
        Chef::Log.info("deploy -#{ app }-")
    end
elsif
    # never goes here
end

i got this error on line 4

undefined method `each' for nil:NilClass (NoMethodError)
Rahadian Kumang
  • 591
  • 6
  • 15

1 Answers1

0

firstly, i will advise you to read What does the “===” operator do in Ruby?.

i have a feeling that you meant to use ==, rather than ===. change your triple equal operator to double equal operator and give it a try...

you can use #nil? if you want to make it more readable (depending on your ruby version). change

if node[:deploy] === nil

to

node[:deploy].nil?
Mr.
  • 9,429
  • 13
  • 58
  • 82