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

Add new properties to firewalld_ipset type and improve logging of changes #170

Merged
merged 16 commits into from
Jun 13, 2018

Conversation

jfroche
Copy link
Contributor

@jfroche jfroche commented Apr 4, 2018

Improve firewalld_ipset type:

  • Declare new properties
  • Improve logging of ipset member changes
  • Gather current state at once using prefetch "pattern" to avoid declaration of many getter

Add more tests

jfroche added 7 commits April 4, 2018 11:12
Define firewalld ipset options using properties:

 - family
 - hashsize
 - maxelem
 - timeout

This change is backward compatible with the definition of options using
the `options` property.
/32 is stripped by ipset when the rules is created.
When you have a long list of ips in a set, it is easier to only show what
actually changed (removal and addition).
We parse actual ipset rules to define existing resource. We avoid
declaration of getter.
Sometimes firewalld ipset entries are modified by another process than puppet.
If you want to declare the ipset with puppet but not manage the entries,
we add the `manage_entries` option.

Obviously, by default entries are managed by puppet.

We throw an error if you try to define ipset entries with puppet and
don't want to manage entries (`manage_entries = false`)
jfroche added 2 commits April 12, 2018 16:42
 Add new firewalld_ipset option: manage_entries
From documentation: Parameters change how Puppet manages a resource, but
do not necessarily map directly to something measurable.
jfroche added 2 commits April 19, 2018 16:26
This option is useful if you want to control ipsets only with puppet.
jfroche added 2 commits April 26, 2018 14:02
If ipset is created with `instances` and `prefetch`, there is no need to
verify if the set exists using firewalld-cmd
@@ -0,0 +1,15 @@
module PuppetX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a bit overkill to create a PuppetX class for this property rather than just using a validate block in the type? This would fall outside of environment isolation provided by puppet generate types.....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it is more code but validate is not specific to a field/property. We might want to reuse that validation for other fields and avoid code duplication

@crayfishx crayfishx added enhancement New feature or request accepted labels Apr 26, 2018
jfroche added 2 commits May 3, 2018 13:21
self.instances method on the provider class did not verify if firewalld had a
correct state before issuing `firewall-cmd` commands.
This was a problem as we were trying to collect ipset informations
without checking if firewalld was ready.

So we move the `available?` implementation to the class method to be
able to verify the current firewalld state.
Verify if firewalld is online before self.execute_firewall_cmd
@crayfishx crayfishx added this to the 3.5.0 milestone Jun 6, 2018
@crayfishx crayfishx merged commit 017e6bd into voxpupuli:master Jun 13, 2018
@alexjfisher alexjfisher changed the title Ipset options Add new properties to firewalld_ipset type and improve logging of changes Oct 14, 2019

it 'removes /32 in set members' do
expect(resource[:entries]).to eq ['8.8.8.8', '9.9.9.9']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference I'd avoid using public IPs. RFC5735 describes subnets exactly for this use case:

192.0.2.0/24 - This block is assigned as "TEST-NET-1" for use in documentation and example code.

There's also TEST-NET-2 (198.51.100.0/24) and TEST-NET-3 (203.0.113.0/24).

@alexjfisher
Copy link
Member

Also... @jfroche sorry for the notifications I may be spamming you with. We're adjusting PR titles for the benefit of the changelog that is about to accompany a new 4.0.0 release :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants