2012-05-17 15:11:25 +00:00
|
|
|
class squid($version, $user, $config_template, $error_template) {
|
|
|
|
$bin = bin_path($name)
|
|
|
|
$sbin = sbin_path($name)
|
2012-05-17 00:33:40 +00:00
|
|
|
|
2012-05-17 15:11:25 +00:00
|
|
|
$build_dir = build_path($name, $version)
|
2012-05-17 00:33:40 +00:00
|
|
|
$log_dir = log_path($name)
|
|
|
|
$pid = pid_path($name)
|
|
|
|
$data_dir = data_path($name)
|
|
|
|
$config_dir = config_path($name)
|
|
|
|
$config = "${config_dir}/squid.conf"
|
|
|
|
|
2012-05-23 13:10:47 +00:00
|
|
|
mkdir_p { [ $log_dir, $data_dir, $config_dir ]:
|
|
|
|
path => $base::path
|
2012-05-17 00:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_and_install { $name:
|
|
|
|
version => $version,
|
|
|
|
source => "http://www.squid-cache.org/Versions/v3/3.1/squid-${version}.tar.bz2",
|
|
|
|
configure => template('squid/configure'),
|
|
|
|
preconfigure => template('squid/preconfigure')
|
|
|
|
}
|
|
|
|
|
|
|
|
file { $config:
|
|
|
|
content => template($config_template),
|
2012-05-17 15:11:25 +00:00
|
|
|
require => Build_and_install[$name]
|
2012-05-17 00:33:40 +00:00
|
|
|
}
|
|
|
|
|
2012-05-17 15:11:25 +00:00
|
|
|
$squid_start = 'service squid start'
|
|
|
|
$squid_stop = 'service squid stop'
|
|
|
|
|
|
|
|
god_init { $name:
|
|
|
|
start => $squid_start,
|
|
|
|
stop => $squid_stop,
|
|
|
|
restart => "${squid_stop} && ${squid_start}",
|
|
|
|
pid_file => $pid,
|
|
|
|
ensure => present,
|
|
|
|
require => File[$config],
|
|
|
|
interval => 10
|
2012-05-17 00:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file { [
|
2012-05-17 15:11:25 +00:00
|
|
|
"${data_dir}/errors/en/ERR_CANNOT_FORWARD",
|
|
|
|
"${data_dir}/errors/templates/ERR_CANNOT_FORWARD"
|
2012-05-17 00:33:40 +00:00
|
|
|
]:
|
2012-05-17 15:11:25 +00:00
|
|
|
content => template($error_template),
|
2012-05-17 00:33:40 +00:00
|
|
|
require => Build_and_install['squid']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|