Method: Puppet::Provider::Firewallchain::Firewallchain#delete

Defined in:
lib/puppet/provider/firewallchain/firewallchain.rb

#delete(context, name, is) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/puppet/provider/firewallchain/firewallchain.rb', line 124

def delete(context, name, is)
  # Before we can delete a chain we must first flush it of any active rules
  context.notice("Flushing Chain '#{name}'")
  Puppet::Provider.execute([$base_command[is[:protocol]], is[:table], $chain_flush_command, is[:chain]].join(' '))

  # For Inbuilt chains we cannot delete them and so instead simply ensure they are reverted to the default policy
  if $built_in_regex.match(is[:chain])
    context.notice("Reverting Internal Chain '#{name}' to its default")
    Puppet::Provider.execute([$base_command[is[:protocol]], is[:table], $chain_policy_command, is[:chain], 'ACCEPT'].join(' '))
  else
    context.notice("Deleting Chain '#{name}'")
    Puppet::Provider.execute([$base_command[is[:protocol]], is[:table], $chain_delete_command, is[:chain]].join(' '))
  end
  PuppetX::Firewall::Utility.persist_iptables(context, name, is[:protocol])
end