2024-10-10 13:22:11 +00:00
|
|
|
# Configure a SUNET CDN CA server
|
2024-10-10 13:28:23 +00:00
|
|
|
class cdn::cache(
|
2024-10-10 13:27:06 +00:00
|
|
|
Hash[String, Integer] $customers = {
|
2024-10-10 13:22:11 +00:00
|
|
|
customer1 => 1000000000,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
{
|
|
|
|
include sunet::packages::certbot
|
|
|
|
include cdn::ca_trust
|
|
|
|
|
|
|
|
$cache_secrets = lookup({ 'name' => 'cdn::cache-secrets', 'default_value' => undef })
|
|
|
|
|
|
|
|
file { '/opt/sunet-cdn':
|
|
|
|
ensure => directory,
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0755',
|
|
|
|
}
|
|
|
|
|
|
|
|
file { '/opt/sunet-cdn/customers':
|
|
|
|
ensure => directory,
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0755',
|
|
|
|
}
|
|
|
|
|
|
|
|
file { '/opt/sunet-cdn/conf':
|
|
|
|
ensure => directory,
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0755',
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "/opt/sunet-cdn/conf/varnish-slash-seccomp.json":
|
|
|
|
ensure => file,
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
|
|
|
content => template('cdn/cache/varnish-slash-seccomp.json.erb'),
|
|
|
|
}
|
|
|
|
|
|
|
|
if $cache_secrets {
|
2024-10-10 13:29:50 +00:00
|
|
|
$customers.each |String $customer, Integer $customer_uid| {
|
2024-10-10 13:22:11 +00:00
|
|
|
if $cache_secrets['customers'][$customer] {
|
|
|
|
file { "/opt/sunet-cdn/customers/$customer":
|
|
|
|
ensure => directory,
|
|
|
|
owner => $customer_uid,
|
|
|
|
group => $customer_uid,
|
|
|
|
mode => '0750',
|
|
|
|
}
|
|
|
|
|
2024-10-10 13:31:54 +00:00
|
|
|
file { "/opt/sunet-cdn/customers/$customer/conf":
|
|
|
|
ensure => directory,
|
|
|
|
owner => $customer_uid,
|
|
|
|
group => $customer_uid,
|
|
|
|
mode => '0750',
|
|
|
|
}
|
|
|
|
|
2024-10-10 13:22:11 +00:00
|
|
|
file { "/opt/sunet-cdn/customers/$customer/shared":
|
|
|
|
ensure => directory,
|
|
|
|
owner => $customer_uid,
|
|
|
|
group => $customer_uid,
|
|
|
|
mode => '0750',
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "/opt/sunet-cdn/customers/$customer/cache":
|
|
|
|
ensure => directory,
|
|
|
|
owner => $customer_uid,
|
|
|
|
group => $customer_uid,
|
|
|
|
mode => '0750',
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "/opt/sunet-cdn/customers/$customer/conf/haproxy.cfg":
|
|
|
|
ensure => file,
|
|
|
|
owner => $customer_uid,
|
|
|
|
group => $customer_uid,
|
|
|
|
mode => '0440',
|
|
|
|
content => template('cdn/cache/haproxy.cfg.erb'),
|
|
|
|
}
|
|
|
|
|
2024-10-10 18:39:35 +00:00
|
|
|
file { "/opt/sunet-cdn/customers/$customer/conf/varnish.vcl":
|
|
|
|
ensure => file,
|
|
|
|
owner => $customer_uid,
|
|
|
|
group => $customer_uid,
|
|
|
|
mode => '0440',
|
|
|
|
content => template('cdn/cache/varnish.vcl.erb'),
|
|
|
|
}
|
|
|
|
|
2024-10-10 13:22:11 +00:00
|
|
|
sunet::docker_compose { "sunet-cdn-cache-$customer":
|
|
|
|
content => template('cdn/cache/docker-compose.yml.erb'),
|
|
|
|
service_name => "cdn-cache-$customer",
|
|
|
|
compose_dir => "/opt/sunet-cdn/compose/$customer",
|
|
|
|
compose_filename => 'docker-compose.yml',
|
|
|
|
description => "SUNET CDN CA $customer",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|