40 lines
1.2 KiB
YAML
40 lines
1.2 KiB
YAML
---
|
|
- name: Check if Minifirewall is present
|
|
stat:
|
|
path: /etc/default/minifirewall
|
|
check_mode: no
|
|
|
|
register: minifirewall_test
|
|
|
|
- block:
|
|
- name: HTTPSITES list is commented in minifirewall
|
|
replace:
|
|
dest: /etc/default/minifirewall
|
|
regexp: "^(HTTPSITES='[^0-9])"
|
|
replace: '#\1'
|
|
|
|
- name: all HTTPSITES are authorized in minifirewall
|
|
lineinfile:
|
|
dest: /etc/default/minifirewall
|
|
line: "HTTPSITES='0.0.0.0/0'"
|
|
insertafter: "^#HTTPSITES="
|
|
|
|
- name: add iptables rules for the proxy
|
|
lineinfile:
|
|
dest: /etc/default/minifirewall
|
|
regexp: "^#? *{{ item }}"
|
|
line: "{{ item }}"
|
|
insertafter: "^# Proxy"
|
|
with_items:
|
|
- "/sbin/iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --uid-owner proxy -j ACCEPT"
|
|
- "/sbin/iptables -t nat -A OUTPUT -p tcp --dport 80 -d {{ squid_address }} -j ACCEPT"
|
|
- "/sbin/iptables -t nat -A OUTPUT -p tcp --dport 80 -d 127.0.0.0/8 -j ACCEPT"
|
|
- "/sbin/iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-port 8888"
|
|
|
|
- name: remove minifirewall example rule for the proxy
|
|
lineinfile:
|
|
dest: /etc/default/minifirewall
|
|
regexp: '^#.*(-t nat).*(-d X\.X\.X\.X)'
|
|
state: absent
|
|
when: minifirewall_test.stat.exists
|