]> gitweb.fluxo.info Git - puppet-apache.git/commitdiff
Initial certbot support
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 18 Jun 2016 16:53:07 +0000 (13:53 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 18 Jun 2016 16:53:07 +0000 (13:53 -0300)
manifests/site.pp
manifests/site/config.pp
templates/site.erb

index 6af019eb3cfcf2878e482e4c280fbd55bfa57e5c..586d5c14a45462fae5647e4d8268fe6d93f4b98b 100644 (file)
@@ -32,8 +32,8 @@ define apache::site(
   $hidden_service       = false,
   $custom_directives    = false,
   $allow_override       = false,
-  $hosting_domain       = hiera('apache::site::domain', $::domain)
-
+  $hosting_domain       = hiera('apache::site::domain', $::domain),
+  $certbot              = false,
 ) {
   $vhost = $filename ? {
     ''      => "${name}",
@@ -118,6 +118,7 @@ define apache::site(
     custom_directives    => $custom_directives,
     allow_override       => $allow_override,
     hosting_domain       => $hosting_domain,
+    certbot              => $certbot,
   }
 
   # Enable or disable accordingly
@@ -128,5 +129,13 @@ define apache::site(
     owner          => $owner,
     group          => $group,
     vhost          => $vhost,
+    require        => Apache::Site::Config[$name],
+  }
+
+  if $certbot == true {
+    certbot::manage { $name:
+      pre_hook => '/usr/sbin/service apache2 reload',
+      require  => Apache::Site::Manage[$name],
+    }
   }
 }
index a723eabb890cecdaa766fc02c34e91d1edb03f27..063c08f04db7f5470479d8e0439bd2b29eba3002 100644 (file)
@@ -21,6 +21,7 @@ define apache::site::config(
   $custom_directives    = false,
   $allow_override       = false,
   $hosting_domain       = hiera('apache::site::domain', $::domain)
+  $certbot              = false,
 ) {
   case $source {
     true: {
index 2ed510797b720ab235f12804cc9ce774434aa750..17ff13ebdf60898c4621dc400505eaed6d0b2ad1 100644 (file)
      AllowOverride <%= @allow_override %>
    </Directory>
 <% end -%>
+<% if @certbot != false -%>
+   # Add Alias For Lets Encrypt WebRoot Authentication Using ACME
+   # See https://ubuntu101.co.za/ssl/postfix-and-dovecot-on-ubuntu-with-a-lets-encrypt-ssl-certificate/
+   AliasMatch ^/.well-known/acme-challenge/(.*)$ /var/spool/certbot/<%= @name %>/.well-known/acme-challenge/$1
+   Alias /.well-known/acme-challenge/ /var/spool/certbot/<%= @name %>/.well-known/acme-challenge/
+   <Directory "/var/spool/certbot/<%= @name %>/.well-known/acme-challenge/">
+     Options None
+     AllowOverride None
+     ForceType text/plain
+     RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)"
+   </Directory>
+<% end -%>
 </VirtualHost>
 # end vhost for <%= @title %>
 <% if @ssl == true %>