-
Notifications
You must be signed in to change notification settings - Fork 104
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a7c104
Firewall changes:
arcsector 27e265b
Handlers for firewalls and merge into single yml
arcsector f93c8a1
Firewall change requests
arcsector 1acc13b
Firewall changes after tests
arcsector ef3a94c
replace with firewalld in name for task running only for firewalld
jewnix 4c7b5f3
Adding comments and desc to port dictionary
arcsector File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
splunk_firewall_ports: | ||
- "{{ splunkweb_port }}" | ||
- "{{ splunkapi_port }}" | ||
- "{{ splunktcpin_port }}" | ||
- "{{ splunkhec_port }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
splunk_firewall_ports: | ||
- "{{ splunkweb_port }}" | ||
- "{{ splunkapi_port }}" | ||
- "{{ splunktcpin_port }}" | ||
- "{{ splunkhec_port }}" | ||
- "{{ splunkidxcrep_port }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
splunk_firewall_ports: | ||
- "{{ splunkweb_port }}" | ||
- "{{ splunkapi_port }}" | ||
- "{{ splunkshcrep_port }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Ensure {{ firewall_service }} package is installed | ||
ansible.builtin.package: | ||
name: "{{ firewall_service }}" | ||
state: present | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
become: true | ||
|
||
- name: Configure firewalld for Splunk | ||
block: | ||
- name: Ensure firewalld is Started and Enabled | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ansible.builtin.systemd: | ||
name: "{{ firewall_service }}" | ||
state: started | ||
enabled: true | ||
become: true | ||
|
||
- name: Add splunk firewalld service | ||
ansible.builtin.template: | ||
src: firewalld_service.xml.j2 | ||
dest: /etc/firewalld/services/{{ splunk_firewall_service }}.xml | ||
backup: true | ||
mode: 0644 | ||
owner: root | ||
group: root | ||
become: true | ||
register: firewalld | ||
|
||
- name: reload firewalld | ||
command: firewall-cmd --reload | ||
become: true | ||
when: firewalld.changed | ||
|
||
- name: Activate splunk firewalld service | ||
ansible.posix.firewalld: | ||
service: "{{ splunk_firewall_service }}" | ||
permanent: true | ||
state: enabled | ||
immediate: true | ||
notify: reload firewalld | ||
become: true | ||
when: firewall_service == "firewalld" | ||
|
||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Configure UFW for Splunk | ||
block: | ||
- name: Ensure SSH is enabled | ||
community.general.ufw: | ||
port: 22 | ||
proto: tcp | ||
rule: allow | ||
state: enabled | ||
become: true | ||
|
||
- name: Add splunk port to UFW | ||
community.general.ufw: | ||
port: "{{ item.number }}" | ||
proto: "{{ item.protocol }}" | ||
rule: allow | ||
state: reloaded | ||
comment: "{{ item.desc | default('') }}" | ||
become: true | ||
loop: "{{ splunk_firewall_ports }}" | ||
when: firewall_service == "ufw" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<service> | ||
<short>splunk</short> | ||
<description>Ports to be configured for splunk</description> | ||
{% for port in splunk_firewall_ports %} | ||
<!-- {{ port.desc | default('') }} --> | ||
<port protocol="{{ port.protocol }}" port="{{ port.number }}"/> | ||
{% endfor %} | ||
</service> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ linux_packages: | |
- nethogs | ||
- gdb | ||
- dnsutils | ||
firewall_service: ufw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ linux_packages: | |
- nethogs | ||
- gdb | ||
- bind-utils | ||
firewall_service: firewalld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 thefull
category: