Add initial support for handling a DB server

Used to store varnish config etc
This commit is contained in:
Patrik Lundin 2024-11-13 13:27:58 +01:00
parent 78894e7500
commit 85afb706ed
Signed by: patlu
GPG key ID: A0A812BA2249F294
4 changed files with 47 additions and 0 deletions

View file

@ -37,3 +37,6 @@
'^internal-.+-test-cs-[0-9]+\.cdn\.sunet\.se$':
sunet::certbot::acmed:
sunet::certbot::sync::server:
'^internal-.+-test-db-[0-9]+\.cdn\.sunet\.se$':
cdn::db:

View file

@ -0,0 +1,36 @@
# Configure a SUNET CDN DB server
class cdn::db(
String $postgres_version = '17.0-bookworm',
)
{
$db_secrets = lookup({ 'name' => 'cdn::db-secrets', 'default_value' => undef })
file { '/opt/sunet-cdn':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
file { '/opt/sunet-cdn/compose':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0750',
}
sunet::nftables::docker_expose { 'expose postgres-db' :
allow_clients => '127.0.0.1',
port => 5432,
iif => $facts['networking']['primary'],
}
sunet::docker_compose { 'sunet-cdn-ca':
content => template('cdn/db/docker-compose.yml.erb'),
service_name => 'cdn-ca',
compose_dir => '/opt/sunet-cdn/compose',
compose_filename => 'docker-compose.yml',
description => 'SUNET CDN DB',
}
}

View file

@ -0,0 +1,5 @@
services:
db:
image: "postgres:<%= @postgres_version %>"
environment:
- POSTGRES_PASSWORD=<%= @postgres_password %>

View file

@ -0,0 +1,3 @@
---
cdn::db-secrets:
postgres_password: ENC[PKCS7,MIIDCAYJKoZIhvcNAQcDoIIC+TCCAvUCAQAxggKQMIICjAIBADB0MFwxCzAJBgNVBAYTAlNFMQ4wDAYDVQQKDAVTVU5FVDEOMAwGA1UECwwFRVlBTUwxLTArBgNVBAMMJGludGVybmFsLXN0bzMtdGVzdC1kYi0xLmNkbi5zdW5ldC5zZQIUbbUXduFvDLw3OUVWiGrIvFBkkJMwDQYJKoZIhvcNAQEBBQAEggIAGKLk12OT5zsVKd04qsLkFtawdauLYUERXUC3d9FtZNV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