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
80 changes: 24 additions & 56 deletions puppet/modules/web/manifests/jenkins.pp
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

web::vhost requires web which includes web::base

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it in because we use $apache::user and $apache::group as docroot owners. I'm not sure we actually need that though.

$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'],
},
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not parse for environment *root*: Syntax error at ','

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still miss something in my vim config from when I moved to my new laptop.


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

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

if $https {
$url = "https://${hostname}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use web::https instead, and drop the https param?
Otherwise you set web::jenkins::https to false, but web::vhost still uses web::https and tries to build a cert

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be more consistent with web::vhost::web. Further looking at that, we can probably also align those 2 on redirecting HTTP to HTTPS. I'll look a bit further.


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],
$http_attrs = {
'redirect_dest' => "${url}/",
}
$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,
docroot_owner => $apache::user,
docroot_group => $apache::user,
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