From 9dca0f98bfa4e186246ce9c981b205d66476d411 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 14 Mar 2017 18:06:07 +0100 Subject: [PATCH] Squid: deal with Jessie and Stretch --- squid/files/logrotate_squid3 | 11 ----------- squid/handlers/main.yml | 5 +++++ squid/tasks/logrotate.yml | 6 +++--- squid/tasks/main.yml | 22 ++++++++++------------ squid/templates/logrotate.j2 | 11 +++++++++++ squid/templates/squid.j2 | 4 ++-- squid/vars/Debian-jessie.yml | 5 +++++ squid/vars/Debian-stretch.yml | 5 +++++ 8 files changed, 41 insertions(+), 28 deletions(-) delete mode 100644 squid/files/logrotate_squid3 create mode 100644 squid/templates/logrotate.j2 create mode 100644 squid/vars/Debian-jessie.yml create mode 100644 squid/vars/Debian-stretch.yml diff --git a/squid/files/logrotate_squid3 b/squid/files/logrotate_squid3 deleted file mode 100644 index 95946eb9..00000000 --- a/squid/files/logrotate_squid3 +++ /dev/null @@ -1,11 +0,0 @@ -/var/log/squid3/*.log { - monthly - compress - rotate 12 - missingok - create 640 proxy adm - sharedscripts - postrotate - test ! -e /var/run/squid3.pid || /usr/sbin/squid3 -k rotate - endscript -} \ No newline at end of file diff --git a/squid/handlers/main.yml b/squid/handlers/main.yml index c623bc19..da5cf20f 100644 --- a/squid/handlers/main.yml +++ b/squid/handlers/main.yml @@ -5,6 +5,11 @@ state: restarted - name: restart squid + service: + name: squid + state: restarted + +- name: restart squid3 service: name: squid3 state: restarted diff --git a/squid/tasks/logrotate.yml b/squid/tasks/logrotate.yml index 7f1066b4..3ac53a6e 100644 --- a/squid/tasks/logrotate.yml +++ b/squid/tasks/logrotate.yml @@ -1,6 +1,6 @@ --- - name: logrotate configuration - copy: - src: logrotate_squid3 - dest: /etc/logrotate.d/squid3 + template: + src: logrotate.j2 + dest: /etc/logrotate.d/{{ squid_daemon }} force: no diff --git a/squid/tasks/main.yml b/squid/tasks/main.yml index 09a66da4..57ecf31b 100644 --- a/squid/tasks/main.yml +++ b/squid/tasks/main.yml @@ -1,35 +1,33 @@ --- +- name: Include OS-specific variables + include_vars: "{{ ansible_os_family }}-{{ ansible_distribution_release }}.yml" + - name: package is installed apt: - name: squid3 + name: "{{ squid_package }}" state: present - name: squid.conf is present template: src: squid.j2 - dest: /etc/squid3/squid.conf - notify: restart squid - -- name: logrotate configuration - copy: - src: logrotate_squid3 - dest: /etc/logrotate.d/squid3 + dest: "{{ squid_conf_file }}" + notify: "restart {{ squid_daemon }}" - name: evolix whitelist is present copy: src: whitelist-evolinux.conf - dest: /etc/squid3/whitelist-evolinux.conf + dest: "{{ squid_conf_path }}/whitelist-evolinux.conf" force: yes backup: yes - notify: restart squid + notify: "restart {{ squid_daemon }}" - name: custom whitelist is present copy: src: whitelist-custom.conf - dest: /etc/squid3/whitelist-custom.conf + dest: "{{ squid_conf_path }}/whitelist-custom.conf" force: no - notify: restart squid + notify: "restart {{ squid_daemon }}" - include: logrotate.yml diff --git a/squid/templates/logrotate.j2 b/squid/templates/logrotate.j2 new file mode 100644 index 00000000..409776b2 --- /dev/null +++ b/squid/templates/logrotate.j2 @@ -0,0 +1,11 @@ +/var/log/{{ squid_daemon }}/*.log { + monthly + compress + rotate 12 + missingok + create 640 proxy adm + sharedscripts + postrotate + test ! -e /var/run/{{ squid_daemon }}.pid || /usr/sbin/{{ squid_daemon }} -k rotate + endscript +} diff --git a/squid/templates/squid.j2 b/squid/templates/squid.j2 index 7fe7f36b..f0bafb91 100644 --- a/squid/templates/squid.j2 +++ b/squid/templates/squid.j2 @@ -8,8 +8,8 @@ acl localhost src 127.0.0.0/32 acl INTERNE src {{ squid_address }}/32 127.0.0.0/8 acl Safe_ports port 80 # http acl SSL_ports port 443 563 -acl WHITELIST url_regex "/etc/squid3/whitelist-evolinux.conf" -acl WHITELIST url_regex "/etc/squid3/whitelist-custom.conf" +acl WHITELIST url_regex "{{ squid_conf_path }}/whitelist-evolinux.conf" +acl WHITELIST url_regex "{{ squid_conf_path }}/whitelist-custom.conf" http_access deny !WHITELIST http_access allow INTERNE http_access deny all diff --git a/squid/vars/Debian-jessie.yml b/squid/vars/Debian-jessie.yml new file mode 100644 index 00000000..c5326e3b --- /dev/null +++ b/squid/vars/Debian-jessie.yml @@ -0,0 +1,5 @@ +--- +squid_package: squid3 +squid_daemon: squid3 +squid_conf_path: /etc/squid3 +squid_conf_file: /etc/squid3/squid.conf diff --git a/squid/vars/Debian-stretch.yml b/squid/vars/Debian-stretch.yml new file mode 100644 index 00000000..5e455921 --- /dev/null +++ b/squid/vars/Debian-stretch.yml @@ -0,0 +1,5 @@ +--- +squid_package: squid +squid_daemon: squid +squid_conf_path: /etc/squid +squid_conf_file: /etc/squid/squid.conf