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

[wip] Clean up iptables #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ansible/roles/check-mk-agent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
- name: add firewall rule for check_mk
lineinfile: dest="{{ iptables_config_file }}"
regexp='dport "{{ check_mk_port }}" -j monitoring$'
line='-A INPUT -s "{{ monitoring_server }}" -p tcp -m tcp --dport "{{ check_mk_port }}" -j monitoring' insertbefore='^COMMIT' state=present
line='-A INPUT -s "{{ monitoring_server }}" -p tcp -m tcp --dport "{{ check_mk_port }}" -j monitoring' insertbefore='^#HOOK' state=present
notify: restart iptables-persistent
tags: check-mk-iptables

- name: setup_plugin_checks
copy: src={{ item }}
Expand Down
11 changes: 2 additions & 9 deletions ansible/roles/iptables-persistent/templates/iptables.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
:monitoring - [0:0]
:backup - [0:0]
:fail2ban-ssh - [0:0]
:rackspace_support - [0:0]
:logging - [0:0]
:ban_abusive_ips - [0:0]

Expand All @@ -23,14 +22,12 @@
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j admin
#-A INPUT -j DROP

-A fail2ban-ssh -j RETURN
-A admin -j ACCEPT
-A application -j ACCEPT
-A monitoring -j ACCEPT
-A backup -j ACCEPT
-A rackspace_support -j ACCEPT
-A ban_abusive_ips -j DROP

#Ansible template note: indentation for jinja conditionals was not done, cause resulting space characters in the iptables file was causing issues with iptables-restore
Expand Down Expand Up @@ -59,11 +56,6 @@
-A INPUT -p tcp -m tcp --dport 80 -j application
-A INPUT -p tcp -m tcp --dport 443 -j application
{% endif %}
{% if hostvars[inventory_hostname]['rackspace_support_ips'] is defined %}
{% for ip in hostvars[inventory_hostname]['rackspace_support_ips'] %}
-A INPUT -s {{ ip }} -p tcp -m tcp -j rackspace_support
{% endfor %}
{% endif %}
{%if hostvars[inventory_hostname]['ban_abusive_ips'] is defined %}
{% for ip in hostvars[inventory_hostname]['ban_abusive_ips'] %}
-A INPUT -s {{ ip }} -j ban_abusive_ips
Expand All @@ -76,5 +68,6 @@
{% endfor %}
{% endif %}


#HOOK (used for adding new entries from roles - eg: check-mk-agent)
-A INPUT -j DROP
COMMIT