How to allow HTTP traffic using chef cookbook?

Previously, I have installed nginx using chef cookbook. Then I did research about firewall rules. For allowing HTTP traffic I have below script.

firewall_rule 'http' do
  port     80
  protocol :tcp
  position 1
  command   :allow
end

But I am getting error

 NoMethodError: undefined method `firewall_rule' for cookbook: firewall, recipe: default :Chef::Recipe

How can I resolve this? I did some research but no success.

Answer

There is no “firewall_rule” resource in Chef by default. As far as I can see this is a custom resource that is a part of cookbook named “firewall” which you can get here: https://supermarket.chef.io/cookbooks/firewall#readme

Are you sure that you used this cookbook, and did not just create an empty cookbook named “firewall” and tried to use “firewall_rule” there?

Attribution
Source : Link , Question Author : Janith , Answer Author : Learner

Leave a Comment