Skip to content

Commit

Permalink
Resolve chef-12 warnings in chain.rb
Browse files Browse the repository at this point in the history
  Cloning resource attributes for directory[/etc/iptables.d/filter/INPUT] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/filter/INPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/filter/INPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/filter/INPUT/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/filter/INPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/filter/INPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/filter/INPUT] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/filter/INPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/filter/INPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/rule.rb:52:in `block in edit_rule' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/rule.rb:52:in `block in edit_rule'
  Cloning resource attributes for directory[/etc/iptables.d/filter/INPUT] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/filter/INPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/rule.rb:52:in `block in edit_rule'
Current  directory[/etc/iptables.d/filter/INPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/filter/OUTPUT] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/filter/OUTPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/filter/OUTPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/filter/OUTPUT/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/filter/OUTPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/filter/OUTPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/filter/FORWARD] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/filter/FORWARD]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/filter/FORWARD]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/filter/FORWARD/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/filter/FORWARD/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/filter/FORWARD/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/nat/OUTPUT] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/nat/OUTPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/nat/OUTPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/nat/OUTPUT/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/nat/OUTPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/nat/OUTPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/nat/PREROUTING] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/nat/PREROUTING]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/nat/PREROUTING]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/nat/PREROUTING/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/nat/PREROUTING/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/nat/PREROUTING/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/nat/POSTROUTING] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/nat/POSTROUTING]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/nat/POSTROUTING]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/nat/POSTROUTING/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/nat/POSTROUTING/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/nat/POSTROUTING/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/mangle/INPUT] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/mangle/INPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/mangle/INPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/mangle/INPUT/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/mangle/INPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/mangle/INPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/mangle/OUTPUT] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/mangle/OUTPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/mangle/OUTPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/mangle/OUTPUT/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/mangle/OUTPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/mangle/OUTPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/mangle/FORWARD] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/mangle/FORWARD]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/mangle/FORWARD]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/mangle/FORWARD/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/mangle/FORWARD/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/mangle/FORWARD/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/mangle/PREROUTING] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/mangle/PREROUTING]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/mangle/PREROUTING]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/mangle/PREROUTING/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/mangle/PREROUTING/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/mangle/PREROUTING/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/mangle/POSTROUTING] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/mangle/POSTROUTING]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/mangle/POSTROUTING]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/mangle/POSTROUTING/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/mangle/POSTROUTING/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/mangle/POSTROUTING/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
  Cloning resource attributes for directory[/etc/iptables.d/raw/OUTPUT] from prior resource (CHEF-3694)
Previous directory[/etc/iptables.d/raw/OUTPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
Current  directory[/etc/iptables.d/raw/OUTPUT]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain' at 1 location:
    - /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:41:in `edit_chain'
  Cloning resource attributes for file[/etc/iptables.d/raw/OUTPUT/default] from prior resource (CHEF-3694)
Previous file[/etc/iptables.d/raw/OUTPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain'
Current  file[/etc/iptables.d/raw/OUTPUT/default]: /var/chef/cache/cookbooks/iptables-ng/providers/chain.rb:50:in `edit_chain' at 1 location:
  • Loading branch information
sspans committed Aug 24, 2016
1 parent 4035c56 commit 476871e
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions providers/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,33 @@ def edit_chain(exec_action)
'- [0:0]'
end

directory "/etc/iptables.d/#{new_resource.table}/#{new_resource.chain}" do
owner 'root'
group node['root_group']
mode 0o700
not_if { exec_action == :delete }
begin
run_context.resource_collection.find(:directory => "/etc/iptables.d/#{new_resource.table}/#{new_resource.chain}")
rescue
directory "/etc/iptables.d/#{new_resource.table}/#{new_resource.chain}" do
owner 'root'
group node['root_group']
mode 0o700
not_if { exec_action == :delete }
end
end

rule_path = "/etc/iptables.d/#{new_resource.table}/#{new_resource.chain}/default"

r = file rule_path do
owner 'root'
group node['root_group']
mode 0o600
content "#{policy}\n"
notifies :create, 'ruby_block[create_rules]', :delayed
notifies :create, 'ruby_block[restart_iptables]', :delayed
action exec_action
begin
r = run_context.resource_collection.find(:file => rule_path)
r.content = "#{policy}\n"
r.updated_by_last_action?
rescue
r = file rule_path do
owner 'root'
group node['root_group']
mode 0o600
content "#{policy}\n"
notifies :create, 'ruby_block[create_rules]', :delayed
notifies :create, 'ruby_block[restart_iptables]', :delayed
action exec_action
end
r.updated_by_last_action?
end

r.updated_by_last_action?
end

0 comments on commit 476871e

Please sign in to comment.