opscode-cookbooks/ufw — pull request #7 by cjoudrey (2013-05-19 22:28:08+00:00)
Title: Prevent crash and rule stacking

This is a regression to #2.

Using `ufw::databag`, Chef crashes on initial run because `node.firewall.rules` is not set:

```

================================================================================
Recipe Compile Error in /var/cache/chef/cookbooks/ufw/recipes/databag.rb
================================================================================

NoMethodError
-------------
Undefined node attribute or method `concat' on `node'. To set an attribute, use `concat=value' instead.

Cookbook Trace:
---------------
/var/cache/chef/cookbooks/ufw/recipes/databag.rb:53:in `block in from_file'
/var/cache/chef/cookbooks/ufw/recipes/databag.rb:47:in `each'
/var/cache/chef/cookbooks/ufw/recipes/databag.rb:47:in `from_file'

Relevant File Content:
----------------------
/var/cache/chef/cookbooks/ufw/recipes/databag.rb:

46:
47: rlist.each do |entry|
48: Chef::Log.debug "ufw::databag: \"#{entry}\""
49: if fw_db.member?(entry)
50: #add the list of firewall rules to the current list
51: item = data_bag_item('firewall', entry)
52: rules = item['rules']
53>> node.set['firewall']['rules'].concat(rules) unless rules.nil?
54: end
55: end
56:
57: #now go apply the rules
58: include_recipe "ufw::default"
59:
```

This pull request also addresses an issue where `rules` will stack after each run.