summaryrefslogtreecommitdiff
path: root/manifests/init.pp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-05 05:07:25 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-05 05:07:25 +0100
commitf91c06d1c6c8b58b388c771603010e9494308d24 (patch)
treea56429a6a5b1dd93426a254811fc1325fbcf87ea /manifests/init.pp
parentHopefully fix blog. (diff)
downloadwebsite_blog_2-f91c06d1c6c8b58b388c771603010e9494308d24.tar.gz
website_blog_2-f91c06d1c6c8b58b388c771603010e9494308d24.tar.xz
Move remaining out of site.pp.
Diffstat (limited to 'manifests/init.pp')
-rw-r--r--manifests/init.pp38
1 files changed, 37 insertions, 1 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 9b5f050..1ecce39 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,6 +1,42 @@
class blog (
String $blog_root,
- Hash[String,Hash] $blogs = {}
+ Hash[String,Hash] $blogs = {},
+ Optional[String] $domain = undef,
+ Optional[Array[String]] $domain_aliases = undef,
) {
create_resources(blog::instance, $blogs)
+
+ if $domain {
+ $default = {
+ access_log => 'absent',
+ error_log => 'absent',
+ ssl => true,
+ ssl_cert => "/etc/letsencrypt/live/${certname}/fullchain.pem",
+ ssl_key => "/etc/letsencrypt/live/${certname}/privkey.pem",
+ use_default_location => false,
+ }
+ $domain_conf = {
+ server_name => [ $domain, ],
+ index_files => [ 'index.php', 'index.html', 'index.htm', ],
+ www_root => $blog::blog_root,
+ }
+
+ $main_conf = {
+ "${safe_title} - server" => $default + $domain_conf,
+ }
+
+ create_resources(nginx::resource::server, $main_conf)
+
+ if $domain_aliases {
+ $alias_conf = {
+ "${safe_title} - aliases" => $default + {
+ server_name => $domain_aliases,
+ server_cfg_append => {
+ 'return' => '301 $scheme://blog.hornquist.se$request_uri',
+ },
+ },
+ }
+ create_resources(nginx::resource::server, $alias_conf)
+ }
+ }
}