Puppet Class: squid
- Defined in:
- modules/squid/manifests/init.pp
Summary
This class installs Squid and configures itOverview
SPDX-License-Identifier: Apache-2.0
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'modules/squid/manifests/init.pp', line 11
class squid (
Wmflib::Ensure $ensure = present,
Logrotate::Frequency $logrotate_frequency = 'daily',
Integer[1] $logrotate_days = 2,
Optional[String[1]] $config_content = undef,
Optional[Stdlib::Filesource] $config_source = undef,
) {
if $ensure == 'present' and $config_content =~ Undef and $config_source =~ Undef {
fail('if $ensure is present you most also set $config_content or $config_source')
}
package { 'squid':
ensure => $ensure,
}
file {
default:
mode => '0444',
owner => 'root',
group => 'root';
'/etc/squid':
ensure => stdlib::ensure($ensure, 'directory');
'/etc/squid/squid.conf':
ensure => stdlib::ensure($ensure, 'file'),
source => $config_source,
content => $config_content,
notify => Service['squid'];
}
$rotate = $logrotate_frequency ? {
'hourly' => $logrotate_days * 24,
default => $logrotate_days,
}
logrotate::rule { 'squid':
ensure => $ensure,
file_glob => '/var/log/squid/*.log',
compress => true,
frequency => $logrotate_frequency,
rotate => $rotate,
missing_ok => true,
size => '300M',
no_create => true,
post_rotate => [
'test ! -e /var/run/squid.pid || /usr/sbin/squid -k rotate',
'/usr/lib/rsyslog/rsyslog-rotate',
],
}
systemd::unit { 'squid':
content => "[Service]\nLimitNOFILE=32768\n",
override => true,
restart => true,
}
service { 'squid':
ensure => stdlib::ensure($ensure, 'service'),
require => Systemd::Unit['squid'],
}
}
|