Puppet module for configuring the squid caching service.
The set up a simple squid server with a cache to forward http port 80 requests.
class{'::squid':}
squid::acl{'Safe_ports':
type => port,
entries => ['80'],
}
squid::http_access{'Safe_ports':
action => allow,
}
squid::http_access{'!Safe_ports':
action => deny,
}Parameters to the squid class almost map 1 to 1 to squid.conf parameters themselves.
ensure_serviceThe ensure value of the squid service, defaults torunning.enable_serviceThe enable value of the squid service, defaults totrue.configLocation of squid.conf file, defaults to/etc/squid/squid.conf.config_useruser which owns the config file, default depends on$operatingsystemconfig_groupgroup which owns the config file, default depends on$operatingsystemdaemon_useruser which runs the squid daemon, this is used for ownership of the cache directory, default depends on$operatingsystemdaemon_groupgroup which runs the squid daemon, this is used for ownership of the cache directory, default depends on$operatingsystemcache_memdefaults to256 MB. cache_mem docs.memory_cache_shareddefaults to undef. memory_cache_shared docs.maximum_object_size_in_memorydefaults to512 KB. maximum_object_size_in_memory docsaccess_logdefaults todaemon:/var/logs/squid/access.log squid. access_log docscoredump_dirdefaults to undef. coredump_dir docs.package_namename of the squid package to manage, default depends on$operatingsystemservice_namename of the squid service to manage, default depends on$operatingsystemmax_filedescriptorsdefaults to undef. max_filedescriptors docs.workersdefaults to undef. workers docs.aclsdefaults to undef. If you pass in a hash of acl entries, they will be defined automatically. acl entries.http_accessdefaults to undef. If you pass in a hash of http_access entries, they will be defined automatically. http_access entries.http_portsdefaults to undef. If you pass in a hash of http_port entries, they will be defined automatically. http_port entries.https_portsdefaults to undef. If you pass in a hash of https_port entries, they will be defined automatically. https_port entries.snmp_portsdefaults to undef. If you pass in a hash of snmp_port entries, they will be defined automatically. snmp_port entries.cache_dirsdefaults to undef. If you pass in a hash of cache_dir entries, they will be defined automatically. cache_dir entries.extra_config_sectionsdefaults to empty hash. If you pass in a hash ofextra_config_sectionresources, they will be defined automatically.
class{'::squid':
cache_mem => '512 MB',
workers => 3,
coredump_dir => '/var/spool/squid',
}class{'::squid':
cache_mem => '512 MB',
workers => 3,
coredump_dir => '/var/spool/squid',
acls => { 'remote_urls' => {
type => 'url_regex',
entries => ['http://example.org/path',
'http://example.com/anotherpath'],
},
},
http_access => { 'our_networks hosts' => { action => 'allow', },
http_ports => { '10000' => { options => 'accel vhost'} },
snmp_ports => { '1000' => { process_number => 3 },
cache_dirs => { '/data/' => { type => 'ufs', options => '15000 32 256 min-size=32769', process_number => 2 }},
}The acls, http_access, http_ports, snmp_port, cache_dirs lines above are equivalent to their examples below.
Defines acl entries for a squid server.
squid::acl{'remote_urls':
type => 'url_regex',
entries => ['http://example.org/path',
'http://example.com/anotherpath'],
}would result in a multi entry squid acl
acl remote_urls url_regex http://example.org/path
acl remote_urls url_regex http://example.com/anotherpath
These may be defined as a hash passed to ::squid
typeThe acltype of the acl, must be defined, e.g url_regex, urlpath_regex, port, ..aclnameThe name of acl, defaults to thetitle.entriesAn array of acl entries, multiple members results in multiple lines in squid.conf.orderEach ACL has an order05by default this can be specified if order of ACL definition matters.
Defines cache_dir entries for a squid server.
squid::cache_dir{'/data':
type => 'ufs',
options => '15000 32 256 min-size=32769',
process_number => 2,
}Results in the squid configuration of
if ${processor} = 2
cache_dir ufs 15000 32 256 min-size=32769
endif
typethe type of cache, e.g ufs. defaults toufs.pathdefaults to the namevar, file path to cache.optionsString of options for the cache. Defaults to empty string.process_numberif specfied as an integer the cache will be wrapped in aif $proceess_numberstatement so the cache will be used by only one process. Default is undef.
Defines http_access entries for a squid server.
squid::http_access{'our_networks hosts':
action => 'allow',
}Adds a squid.conf line
http_access allow our_networks hosts
These may be defined as a hash passed to ::squid
valuedefaults to thenamevarthe rule to allow or deny.actionmust bedenyorallow. By default it is allow. The squid.conf file is ordered so by default all allows appear before all denys. This can be overidden with theorderparameter.orderby default is05
Defines http_port entries for a squid server.
By setting optional ssl parameter to true will create https_port entries instead.
squid::http_port{'10000':
options => 'accel vhost'
}
squid::http_port{'10001':
ssl => true,
options => 'cert=/etc/squid/ssl_cert/server.cert key=/etc/squid/ssl_cert/server.key'
}Results in a squid configuration of
http_port 10000 accel vhost
https_port 10001 cert=/etc/squid/ssl_cert/server.cert key=/etc/squid/ssl_cert/server.key
portdefaults to the namevar and is the port number.optionsA string to specify any options for the default. By default and empty string.sslA boolean. When set totruecreates https_port entries. Defaults tofalse.
Defines https_port entries for a squid server.
As an alternative to using the Squid::Http_port defined type with ssl set to true, you can use this type instead. The result is the same. Internally this type uses Squid::Http_port to create the configuration entries.
portdefaults to the namevar and is the port number.optionsA string to specify any options to add to the https_port line. Defaults to an empty string.
Defines snmp_port entries for a squid server.
squid::snmp_port{'1000':
process_number => 3
}Results in a squid configuration of
if ${process_number} = 3
snmp_port 1000
endif
portdefaults to the namevar and is the port number.optionsA string to specify any options for the default. By default and empty string.process_numberIf set to and integer the snmp_port is enabled only for a particular squid thread. Defaults to undef.
Defines auth_param entries for a squid server.
squid::auth_param{ 'basic auth_param':
scheme => 'basic',
entries => ['program /usr/lib64/squid/basic_ncsa_auth /etc/squid/.htpasswd',
'children 5',
'realm Squid Basic Authentication',
'credentialsttl 5 hours'],
}would result in multi entry squid auth_param
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/.htpasswd
auth_param basic children 5
auth_param basic realm Squid Basic Authentication
auth_param basic credentialsttl 5 hours
These may be defined as a hash passed to ::squid
schemethe scheme used for authentication must be definedentriesAn array of entries, multiple members results in multiple lines in squid.conforderby default is '40'
Squid has a large number of configuration directives. Not all of these have been exposed individually in this module. For those that haven't, the extra_config_section defined type can be used.
squid::extra_config_section {'mail settings':
order => '60',
config_entries => {
'mail_from' => 'squid@example.com',
'mail_program' => 'mail',
},
}Results in a squid configuration of
# mail settings
mail_from squid@example.com
mail_program mail
commentdefaults to the namevar and is used as a section comment insquid.conf.config_entriesA hash of configuration entries to create in this section. The hash key is the name of the configuration directive. The value is either a string, or an array of strings to use as the configuration directive options.orderby default is '60'. It can be used to configure where insquid.confthis configuration section should occur.