Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use web::vhost in web::jenkins #2144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 24 additions & 61 deletions puppet/modules/web/manifests/jenkins.pp
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
class web::jenkins(
class web::jenkins (
Stdlib::Fqdn $hostname = 'ci.theforeman.org',
Stdlib::Absolutepath $webroot = '/var/www/vhosts/jenkins/htdocs',
Boolean $https = false,
) {
include web::base

$proxy_pass = {
'path' => '/',
'url' => 'http://localhost:8080/',
'keywords' => ['nocanon'],
'no_proxy_uris' => ['/.well-known'],
}

if $https {
include web::letsencrypt

letsencrypt::certonly { $hostname:
plugin => 'webroot',
domains => [$hostname],
webroot_paths => [$webroot],
}
$proxy_attrs = {
'allow_encoded_slashes' => 'nodecode',
'proxy_pass' => {
'path' => '/',
'url' => 'http://localhost:8080/',
'keywords' => ['nocanon'],
'no_proxy_uris' => ['/.well-known'],
},
}
ekohl marked this conversation as resolved.
Show resolved Hide resolved

if $facts['os']['selinux']['enabled'] {
Expand All @@ -29,50 +18,24 @@
}
}

file { dirname($webroot):
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}

if $https {
$url = "https://${hostname}"
include web

apache::vhost { 'jenkins':
port => 80,
servername => $hostname,
docroot => $webroot,
docroot_owner => $apache::user,
docroot_group => $apache::group,
redirect_dest => "https://${hostname}/",
}
apache::vhost { 'jenkins-https':
port => 443,
servername => $hostname,
docroot => $webroot,
docroot_owner => $apache::user,
docroot_group => $apache::group,
proxy_pass => $proxy_pass,
allow_encoded_slashes => 'nodecode',
request_headers => ['set X-Forwarded-Proto "https"'],
ssl => true,
ssl_cert => "/etc/letsencrypt/live/${hostname}/fullchain.pem",
ssl_chain => "/etc/letsencrypt/live/${hostname}/chain.pem",
ssl_key => "/etc/letsencrypt/live/${hostname}/privkey.pem",
require => Letsencrypt::Certonly[$hostname],
if $web::https {
$http_attrs = {
'redirect_dest' => "https://${hostname}/",
}
$https_attrs = $proxy_attrs
} else {
$url = "http://${hostname}"
$http_attrs = $proxy_attrs
$https_attrs = {}
}

apache::vhost { 'jenkins':
port => 80,
servername => $hostname,
docroot => $webroot,
docroot_owner => $apache::user,
docroot_group => $apache::group,
proxy_pass => $proxy_pass,
allow_encoded_slashes => 'nodecode',
}
web::vhost { 'jenkins':
servername => $hostname,
http_attrs => $http_attrs,
https_attrs => $https_attrs,
attrs => {
'request_headers' => ['set X-Forwarded-Proto expr=%{REQUEST_SCHEME}'],
},
}
}
6 changes: 4 additions & 2 deletions puppet/modules/web/manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
Optional[String] $docroot_group = undef,
Optional[Stdlib::Filemode] $docroot_mode = undef,
Hash[String, Any] $attrs = {},
Hash[String, Any] $http_attrs = {},
Hash[String, Any] $https_attrs = {},
) {
require web

Expand All @@ -48,7 +50,7 @@
docroot_owner => $docroot_owner,
docroot_group => $docroot_group,
docroot_mode => $docroot_mode,
* => $attrs,
* => $http_attrs + $attrs,
}

if $web::https {
Expand All @@ -74,7 +76,7 @@
ssl_chain => "${letsencrypt::config_dir}/live/${servername}/chain.pem",
ssl_key => "${letsencrypt::config_dir}/live/${servername}/privkey.pem",
require => Letsencrypt::Certonly[$servername],
* => $attrs,
* => $https_attrs + $attrs,
}
}
}
Loading