server-config/roles/nethcfg/tasks/proxy.yml

80 lines
2.5 KiB
YAML

---
# Proxy and webfiltering configurations
- name: Installing proxy-related packages
yum:
name: "{{ item }}"
state: present
with_items:
- nethserver-squid
- nethserver-squidclamav
- nethserver-squidguard
# Squid
- name: Checking squid configuration
shell: /sbin/e-smith/db configuration printprop squid DiskCacheSize
ignore_errors: yes
register: chk_squid
changed_when: "'DiskCacheSize=2000' not in chk_squid.stdout"
- name: Configuring Squid
shell: /sbin/e-smith/db configuration setprop squid BlueMode transparent GreenMode transparent PortBlock disabled status enabled DiskCache enabled DiskCacheSize 2000
when: chk_squid is changed
- name: Activating Squid configuration
shell: /sbin/e-smith/signal-event nethserver-squid-update
when: chk_squid is changed
# Squid-clamav
- name: Checking squidclamav configuration
shell: /sbin/e-smith/db configuration printprop squidclamav status
ignore_errors: true
register: chk_squidclamav
changed_when: "'status=enabled' not in chk_squidclamav.stdout"
- name: Configuring squidclamav
shell: /sbin/e-smith/db configuration setprop squidclamav status enabled
when: chk_squidclamav is changed
- name: Activating squidclamav
shell: /sbin/e-smith/signal-event nethserver-squidclamav-update
when: chk_squidclamav is changed
# SquidGuard
- name: Verifying squidguard configuration
shell: /sbin/e-smith/db configuration printprop squidguard status
register: check_squidguard
ignore_errors: true
changed_when: '"status=enabled" not in check_squidguard.stdout'
- name: Configuring squidguard
shell: /sbin/e-smith/db configuration setprop squidguard Expressions enabled Lists shalla status enabled
when: check_squidguard is changed
- name: Activating squidguard configuration
shell: "/sbin/e-smith/signal-event nethserver-squidguard-{{ item }}"
with_items:
- save
- update
- downloadlists
when: check_squidguard is changed
# Content filtering settings
- name: Verifying content filtering
shell: /sbin/e-smith/db contentfilter printprop default Categories
register: check_cf
changed_when: "'sex' not in check_cf.stdout"
- name: Configuring content filtering
shell: /sbin/e-smith/db contentfilter setprop default Categories aggressive,alcohol,weapons,games-online,gamble,dating,webradio,webtv,sex,porn,spyware,violence,anonvpn,warez
register: cf_cat
when: check_cf is changed
- name: Activating content filtering as a whole
shell: /sbin/e-smith/signal-event nethserver-squidguard-update
when: check_cf is changed