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

Simple Firewall Configuration #157

Merged
merged 6 commits into from
Dec 8, 2022
Merged

Simple Firewall Configuration #157

merged 6 commits into from
Dec 8, 2022

Conversation

arcsector
Copy link
Contributor

This is an attempt to improve on #114 striving for simplicity while also maintaining future portability for people who want to add more ports or decrease the current port pool. The changes at a glance are:

  • New port format to specify protocol for modularity
  • Inferring of FW type: defaults to UFW and if RHEL uses Firewalld
  • Added default firewall ports per group var
  • Checks to see if firewall package is installed and service is running and enabled
  • Using Firewalld Services instead of ephemeral commands
  • Handlers for reloading firewalls and merged into single yaml file

Hopefully this is something that will be more useful. Comments appreciated - maybe we can move the init definition of splunk_firewall_ports to group_vars/all.yml but that's just an aesthetic choice I think.

@dtwersky dtwersky added the enhancement New feature or request label Nov 30, 2022
@dtwersky
Copy link
Collaborator

@arcsector Thanks for creating this PR. I've wanted this for some time.

I was going through this, and I have a few thoughts. The group_vars for Indexers, Heavy Forwarders and search heads have a lot of things in common. How about we put the common ones in full.yml? That way we can avoid duplicate declarations.

In general, I wanted to add some vars that disable the web interface for IDX and HF as the default, as well as splunktcp for SH. I'm not sure if this will complicate things even more or not, but what are your thoughts?

Side note. Can you please for your repo directly from this one instead of the one from @zyphermonkey? This will prevent conflicts, and will be easier to be in sync with this upstream repo.

- Firewalld Services instead of ephemeral commands
- New port format to specify protocol for modularity
- Defaults to UFW and if RHEL uses firewalld
- Added default firewall ports per group var
- Checks to see if firewall package is installed and service is running and enabled
@arcsector
Copy link
Contributor Author

I was going through this, and I have a few thoughts. The group_vars for Indexers, Heavy Forwarders and search heads have a lot of things in common. How about we put the common ones in full.yml? That way we can avoid duplicate declarations.

I have the common ones in defaults/main.yml, where the splunk_firewall_ports var is initialized - this will be applied to all other systems that have this in common (license, deploy, shdeployer, idx manager), then the only repeats are in the group_vars for the cluster components.

In general, I wanted to add some vars that disable the web interface for IDX and HF as the default, as well as splunktcp for SH. I'm not sure if this will complicate things even more or not, but what are your thoughts?

I would like to do that, but I feel like that should be a separate PR which adds that config not just in the firewall config but also in web.conf. Also note I don't have splunktcpin opened for the SHC.

Side note. Can you please for your repo directly from this one instead of the one from @zyphermonkey? This will prevent conflicts, and will be easier to be in sync with this upstream repo.

Will do.

- port proto combos predefined and referenced
- super user privileges for handlers and package interactions
@zyphermonkey
Copy link
Contributor

Why aren't we just using the idempotent firewall module? Trying to manage XML templates doesn't add anything and just makes maintenance more complicated.

@arcsector
Copy link
Contributor Author

In my estimation Firewalld services are much more useful in terms of their overall introspection capabilities as well as their ease of modification and legibility. In addition, services are the best-practice in firewalld for things that are supposed to be associated with a given process.

Say for example we're not just installing splunk on here, but also mysql. I can have a service file for splunk and then one for mysql which identify each port as being associated with that application, which i can then make modifications to or disable/enable independently of one another. A more targeted approach for extensible environments with a lot of firewall configs.

@jewnix
Copy link
Collaborator

jewnix commented Dec 1, 2022

Why aren't we just using the idempotent firewall module? Trying to manage XML templates doesn't add anything and just makes maintenance more complicated.

As @arcsector said. Although using the firewall plugin would may seem to be the simpler way, but when configuring multiple ports for a specific application, the recommended method from the OS side is services.

Also, running the firewall-cmd command is a lot slower, and running it multiple time every time slows down the playbook, which is slow enough as it is.

Any experienced sys-admin would know exactly where to look and what to look for.

arcsector and others added 2 commits December 2, 2022 14:02
- SSH Allow in UFW
- Make Firewalld aware of service
- Removing unnecessary reload handle of UFW
- Adding RHEL 8 firewall_service
splunkapi_port: {protocol: "tcp", number: "{{ splunkd_port }}"}
splunkidxcrep_port: {protocol: "tcp", number: "{{ splunk_idxc_rep_port }}"}
splunkshcrep_port: {protocol: "tcp", number: "{{ splunk_shc_rep_port }}"}
splunk_firewall_ports: # List of ports to allow through local firewall in dict form
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need to define this? This will open the ports on UFs, and since the UF is no longer listening on 0.0.0.0:8089 by default, I don't think we need that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thankfully it will not - in configure_os.yml I have this so that we don't install the firewall unless it's in the full category:

- name: Configure firewall service
  include_tasks: "configure_firewall.yml"
  when:
    - firewall_service != 'undefined'
    - configure_firewall != false
    - "'full' in group_names"

@jewnix jewnix self-requested a review December 6, 2022 12:07
@jewnix
Copy link
Collaborator

jewnix commented Dec 7, 2022

I ran some tests, and it looks good.
Unless anyone has any other outstanding issues, please speak out now or forever hold your peace.

@dtwersky dtwersky merged commit e6d5ab3 into splunk:master Dec 8, 2022
@arcsector
Copy link
Contributor Author

Awesome, thanks guys! Glad we could make this happen.

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.

None yet

5 participants