2022-04-28 12:40:02 +02:00
|
|
|
---
|
|
|
|
- name: Check if Minifirewall is present
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.stat:
|
2022-04-28 12:40:02 +02:00
|
|
|
path: "/etc/default/minifirewall"
|
|
|
|
check_mode: no
|
|
|
|
register: minifirewall_test
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: HTTPSITES list is commented in minifirewall
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.replace:
|
2022-04-28 12:40:02 +02:00
|
|
|
dest: "/etc/default/minifirewall"
|
|
|
|
regexp: "^(HTTPSITES='[^0-9])"
|
|
|
|
replace: '#\1'
|
|
|
|
notify: restart minifirewall
|
|
|
|
|
|
|
|
- name: all HTTPSITES are authorized in minifirewall
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.lineinfile:
|
2022-04-28 12:40:02 +02:00
|
|
|
dest: "/etc/default/minifirewall"
|
|
|
|
line: "HTTPSITES='0.0.0.0/0'"
|
|
|
|
regexp: "HTTPSITES='.*'"
|
|
|
|
insertafter: "^#HTTPSITES="
|
|
|
|
notify: restart minifirewall
|
|
|
|
|
|
|
|
- name: add iptables rules for the proxy
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.lineinfile:
|
2022-04-28 12:40:02 +02:00
|
|
|
dest: "/etc/default/minifirewall"
|
|
|
|
regexp: "^#? *{{ item }}"
|
|
|
|
line: "{{ item }}"
|
|
|
|
insertafter: "^# Proxy"
|
|
|
|
loop:
|
|
|
|
- "/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"
|
|
|
|
notify: restart minifirewall
|
|
|
|
|
|
|
|
- name: remove minifirewall example rule for the proxy
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.lineinfile:
|
2022-04-28 12:40:02 +02:00
|
|
|
dest: "/etc/default/minifirewall"
|
|
|
|
regexp: '^#.*(-t nat).*(-d X\.X\.X\.X)'
|
|
|
|
state: absent
|
|
|
|
notify: restart minifirewall
|
|
|
|
when: minifirewall_test.stat.exists
|