Skip to content

Commit

Permalink
create ssl cert per vhost, not one monster
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Oct 29, 2024
1 parent c18d4b0 commit 9682658
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 54 deletions.
4 changes: 0 additions & 4 deletions puppet/modules/profiles/manifests/jenkins/controller.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
require => Package[$packages],
}

class { 'web::base':
letsencrypt => $https,
}

class { 'web::jenkins':
hostname => $hostname,
https => $https,
Expand Down
2 changes: 2 additions & 0 deletions puppet/modules/redmine/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@
}

if $https {
include web::letsencrypt

letsencrypt::certonly { $servername:
plugin => 'webroot',
domains => [$servername],
Expand Down
11 changes: 1 addition & 10 deletions puppet/modules/web/manifests/base.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# Basic webserver config
#
# @param letsencrypt
# Whether to include letsencrypt
class web::base(
Boolean $letsencrypt = true,
) {
if $letsencrypt {
include web::letsencrypt
}

class web::base {
include apache

file { '/var/www/vhosts':
Expand Down
35 changes: 1 addition & 34 deletions puppet/modules/web/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,7 @@
class web(
Boolean $https = false,
) {
class { 'web::base':
letsencrypt => $https,
}

if $https {
$letsencypt_domain = 'theforeman.org'

letsencrypt::certonly { $letsencypt_domain:
plugin => 'webroot',
# domain / webroot_paths must match exactly
domains => [
'theforeman.org',
'archivedeb.theforeman.org',
'deb.theforeman.org',
'debugs.theforeman.org',
'downloads.theforeman.org',
'stagingdeb.theforeman.org',
'www.theforeman.org',
'yum.theforeman.org',
'stagingyum.theforeman.org',
],
webroot_paths => [
'/var/www/vhosts/web/htdocs',
'/var/www/vhosts/archivedeb/htdocs',
'/var/www/vhosts/deb/htdocs',
'/var/www/vhosts/debugs/htdocs',
'/var/www/vhosts/downloads/htdocs',
'/var/www/vhosts/stagingdeb/htdocs',
'/var/www/vhosts/web/htdocs',
'/var/www/vhosts/yum/htdocs',
'/var/www/vhosts/stagingyum/htdocs',
],
}
}
include web::base

if $facts['os']['selinux']['enabled'] {
include selinux
Expand Down
6 changes: 4 additions & 2 deletions puppet/modules/web/manifests/jenkins.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
'no_proxy_uris' => ['/.well-known'],
}

if $web::base::letsencrypt {
if $https {
include web::letsencrypt

letsencrypt::certonly { $hostname:
plugin => 'webroot',
domains => [$hostname],
Expand All @@ -34,7 +36,7 @@
mode => '0755',
}

if $web::base::letsencrypt and $https {
if $https {
$url = "https://${hostname}"

apache::vhost { 'jenkins':
Expand Down
16 changes: 12 additions & 4 deletions puppet/modules/web/manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
}

if $web::https {
include web::letsencrypt

letsencrypt::certonly { $servername:
plugin => 'webroot',
domains => [$servername] + $serveraliases,
webroot_paths => [$docroot],
}

apache::vhost { "${title}-https":
servername => $servername,
serveraliases => $serveraliases,
Expand All @@ -62,10 +70,10 @@
docroot_mode => $docroot_mode,
port => 443,
ssl => true,
ssl_cert => "${letsencrypt::config_dir}/live/${web::letsencypt_domain}/cert.pem",
ssl_chain => "${letsencrypt::config_dir}/live/${web::letsencypt_domain}/chain.pem",
ssl_key => "${letsencrypt::config_dir}/live/${web::letsencypt_domain}/privkey.pem",
require => Letsencrypt::Certonly[$web::letsencypt_domain],
ssl_cert => "${letsencrypt::config_dir}/live/${servername}/cert.pem",
ssl_chain => "${letsencrypt::config_dir}/live/${servername}/chain.pem",
ssl_key => "${letsencrypt::config_dir}/live/${servername}/privkey.pem",
require => Letsencrypt::Certonly[$servername],
* => $attrs,
}
}
Expand Down

0 comments on commit 9682658

Please sign in to comment.