Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firewall_zone creation doesn't add icmp_blocks on first puppet run #139

Closed
posteingang opened this issue Apr 27, 2017 · 1 comment
Closed
Labels
bug Something isn't working
Milestone

Comments

@posteingang
Copy link

I want to create a new firewalld zone with the following code:

  firewalld_zone { 'restricted':
    ensure           => present,
    target           => '%%REJECT%%',
    purge_rich_rules => true,
    purge_services   => true,
    purge_ports      => true,
    icmp_blocks      => ['redirect', 'router-solicitation', 'router-advertisement']
  }

The problem is, that I have to run puppet twice, to get the defined changes.
First run

Notice: /Stage[main]/Profile::Base::Firewall/Firewalld_zone[restricted]/ensure: created
Info: /Stage[main]/Profile::Base::Firewall/Firewalld_zone[restricted]: Scheduling refresh of Exec[firewalld::reload]
Notice: /Stage[main]/Profile::Base::Firewall/Firewalld_service[Allow SSH]/ensure: created
Info: /Stage[main]/Profile::Base::Firewall/Firewalld_service[Allow SSH]: Scheduling refresh of Exec[firewalld::reload]
Notice: /Stage[main]/Profile::Base::Firewall/Firewalld_service[Allow SNMP]/ensure: created
Info: /Stage[main]/Profile::Base::Firewall/Firewalld_service[Allow SNMP]: Scheduling refresh of Exec[firewalld::reload]
Notice: /Stage[main]/Profile::Base::Firewall/Firewalld_direct_rule[ping - icmp]/ensure: created
Info: /Stage[main]/Profile::Base::Firewall/Firewalld_direct_rule[ping - icmp]: Scheduling refresh of Exec[firewalld::reload]
Notice: /Stage[main]/Firewalld/Exec[firewalld::reload]: Triggered 'refresh' from 4 events
Notice: /Stage[main]/Firewalld/Exec[firewalld::set_default_zone]/returns: executed successfully

Second run

Info: Applying configuration version '1493303993'
Notice: /Stage[main]/Profile::Base::Firewall/Firewalld_zone[restricted]/icmp_blocks: icmp_blocks changed [] to 'redirect router-solicitation router-advertisement'
Info: /Stage[main]/Profile::Base::Firewall/Firewalld_zone[restricted]: Scheduling refresh of Exec[firewalld::reload]
Notice: /Stage[main]/Firewalld/Exec[firewalld::reload]: Triggered 'refresh' from 1 events
Notice: Applied catalog in 16.02 seconds



I played a little bit around and found a working solution in lib/puppet/provider/firewalld_zone/firewall_cmd.rb (line 25)

  def create
    self.debug("Creating new zone #{@resource[:name]} with target: '#{@resource[:target]}'")
    execute_firewall_cmd(['--new-zone', @resource[:name]], nil)

    self.target=(@resource[:target]) if @resource[:target]
    self.sources=(@resource[:sources]) if @resource[:sources]
    self.interfaces=@resource[:interfaces]
    self.icmp_blocks=(@resource[:icmp_blocks]) if @resource[:icmp_blocks] #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  end

Maybe someone can check this and push the change (i am not a ruby dev :-) ).

@crayfishx crayfishx added accepted bug Something isn't working labels Apr 28, 2017
@crayfishx crayfishx added this to the 3.3.2 milestone Apr 28, 2017
@crayfishx
Copy link
Contributor

Yep - this looks like a good fix, I'll test it out myself first and ship in a PR later. Thanks for the work tracking down the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants