Squid: replace logrotate file if default

This commit is contained in:
Jérémy Lecour 2017-12-28 11:16:06 +01:00 committed by Jérémy Lecour
parent 432a89fe40
commit c1169f86f1
7 changed files with 95 additions and 18 deletions

View File

@ -1,6 +0,0 @@
---
- name: logrotate configuration
template:
src: logrotate.j2
dest: /etc/logrotate.d/{{ squid_daemon_name }}
force: no

View File

@ -0,0 +1,29 @@
---
# md5sum for squid logrotate file :
#
# --check reads stdin for a list of files and md5 sums
# the list contains the checksum for the file provided by Jessie
#
# We don't use --status so we can debug if needed
#
# With that command we can check if the logrotate file for squid
# is the one provided by the package.
- name: check if logrotate file is default
shell: 'printf "43994674706b672ae5018f592beccf2e /etc/logrotate.d/{{ squid_daemon_name }}" | md5sum --check'
changed_when: False
failed_when: False
check_mode: no
register: squid_logrotate_md5
tags:
- squid
- name: logrotate configuration
template:
src: logrotate.j2
dest: /etc/logrotate.d/{{ squid_daemon_name }}
force: yes
when: squid_logrotate_md5.rc == 0
tags:
- squid

View File

@ -0,0 +1,29 @@
---
# md5sum for squid logrotate file :
#
# --check reads stdin for a list of files and md5 sums
# the list contains the checksum for the file provided by Stretch
#
# We don't use --status so we can debug if needed
#
# With that command we can check if the logrotate file for squid
# is the one provided by the package.
- name: check if logrotate file is default
shell: 'printf "c210feea019412adac8a5d5dcba427af /etc/logrotate.d/{{ squid_daemon_name }}" | md5sum --check'
changed_when: False
failed_when: False
check_mode: no
register: squid_logrotate_md5
tags:
- squid
- name: logrotate configuration
template:
src: logrotate_stretch.j2
dest: /etc/logrotate.d/{{ squid_daemon_name }}
force: yes
when: squid_logrotate_md5.rc == 0
tags:
- squid

View File

@ -134,7 +134,11 @@
notify: "reload squid"
when: ansible_distribution_major_version | version_compare('9', '>=')
- include: logrotate.yml
- include: logrotate_jessie.yml
when: ansible_distribution_release == "jessie"
- include: logrotate_stretch.yml
when: ansible_distribution_major_version | version_compare('9', '>=')
- include: minifirewall.yml

View File

@ -1,11 +0,0 @@
/var/log/{{ squid_daemon_name }}/*.log {
monthly
compress
rotate 12
missingok
create 640 proxy adm
sharedscripts
postrotate
test ! -e /var/run/{{ squid_daemon_name }}.pid || /usr/sbin/{{ squid_daemon_name }} -k rotate
endscript
}

View File

@ -0,0 +1,14 @@
#
# Logrotate fragment for squid3.
#
/var/log/squid3/*.log {
monthly
compress
rotate 12
missingok
create 640 proxy adm
sharedscripts
postrotate
test ! -e /var/run/squid3.pid || test ! -x /usr/sbin/squid3 || /usr/sbin/squid3 -k rotate
endscript
}

View File

@ -0,0 +1,18 @@
#
# Logrotate fragment for squid.
#
/var/log/squid/*.log {
monthly
compress
delaycompress
rotate 12
missingok
create 640 proxy adm
sharedscripts
prerotate
test ! -x /usr/sbin/sarg-reports || /usr/sbin/sarg-reports monthly
endscript
postrotate
test ! -e /var/run/squid.pid || test ! -x /usr/sbin/squid || /usr/sbin/squid -k rotate
endscript
}