-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The goal of this is that the module can either manage the vhost itself or attach fragments to another vhost to embed the application. This allows composition.
- Loading branch information
Showing
16 changed files
with
715 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,155 @@ | ||
# Configure an Apache vhost | ||
# @api private | ||
class pulpcore::apache { | ||
class pulpcore::apache ( | ||
Boolean $manage_selinux_boolean = true, | ||
Stdlib::Port $http_port = 80, | ||
Stdlib::Port $https_port = 443, | ||
Hash[String, Any] $http_vhost_options = {}, | ||
Hash[String, Any] $https_vhost_options = {}, | ||
Enum['none', 'optional', 'require', 'optional_no_ca'] $ssl_verify_client = 'optional', | ||
) { | ||
$vhost_priority = $pulpcore::apache_vhost_priority | ||
$api_path = '/pulp/api/v3' | ||
$api_url = "http://${pulpcore::api_host}:${pulpcore::api_port}${api_path}" | ||
$api_base_url = "http://${pulpcore::api_host}:${pulpcore::api_port}" | ||
$api_url = "${api_base_url}${api_path}" | ||
$content_path = '/pulp/content' | ||
$content_url = "http://${pulpcore::content_host}:${pulpcore::content_port}${content_path}" | ||
|
||
if $pulpcore::manage_apache { | ||
include apache | ||
apache::vhost { 'pulpcore': | ||
servername => $pulpcore::servername, | ||
port => 80, | ||
priority => '10', | ||
docroot => $pulpcore::apache_docroot, | ||
docroot_owner => $pulpcore::user, | ||
docroot_group => $pulpcore::group, | ||
docroot_mode => '0755', | ||
manage_docroot => true, | ||
proxy_pass => [ | ||
{ | ||
'path' => $api_path, | ||
'url' => $api_url, | ||
'reverse_urls' => [$api_url], | ||
}, | ||
{ | ||
'path' => $content_path, | ||
'url' => $content_url, | ||
'reverse_urls' => [$content_url], | ||
}, | ||
], | ||
$content_base_url = "http://${pulpcore::content_host}:${pulpcore::content_port}" | ||
$content_url = "${content_base_url}${content_path}" | ||
|
||
$docroot_directory = { | ||
'provider' => 'Directory', | ||
'path' => $pulpcore::apache_docroot, | ||
'options' => ['-Indexes', '-FollowSymLinks'], | ||
'allow_override' => ['None'], | ||
} | ||
$content_directory = { | ||
'path' => $content_path, | ||
'provider' => 'location', | ||
'proxy_pass' => [ | ||
{ | ||
'url' => $content_url, | ||
}, | ||
], | ||
'request_headers' => [ | ||
'unset X-CLIENT-CERT', | ||
'set X-CLIENT-CERT "%{SSL_CLIENT_CERT}s" env=SSL_CLIENT_CERT', | ||
], | ||
} | ||
|
||
# Pulp has a default for remote header. Here it's ensured that the end user | ||
# can't send that header to spoof users. | ||
$remote_user_environ_header = $pulpcore::remote_user_environ_name.regsubst(/^HTTP_/, '') | ||
$api_directory = { | ||
'path' => $api_path, | ||
'provider' => 'location', | ||
'proxy_pass' => [ | ||
{ | ||
'url' => $api_url, | ||
}, | ||
], | ||
'request_headers' => [ | ||
"unset ${remote_user_environ_header}", | ||
"set ${remote_user_environ_header} \"%{SSL_CLIENT_S_DN_CN}s\" env=SSL_CLIENT_S_DN_CN", | ||
], | ||
} | ||
|
||
# Static content is served by the whitenoise application. SELinux prevents | ||
# Apache from serving it directly | ||
$proxy_pass_static = { | ||
'path' => $pulpcore::static_url, | ||
'url' => "${api_base_url}${pulpcore::static_url}", | ||
} | ||
|
||
case $pulpcore::apache_http_vhost { | ||
true: { | ||
$http_vhost_name = 'pulpcore' | ||
$http_fragment = undef | ||
|
||
include apache | ||
include apache::mod::headers | ||
apache::vhost { $http_vhost_name: | ||
servername => $pulpcore::servername, | ||
port => $http_port, | ||
priority => $vhost_priority, | ||
docroot => $pulpcore::apache_docroot, | ||
manage_docroot => false, | ||
directories => [$docroot_directory, $content_directory], | ||
* => $http_vhost_options, | ||
} | ||
} | ||
false: { | ||
$http_vhost_name = undef | ||
$http_fragment = undef | ||
} | ||
default: { | ||
$http_vhost_name = $pulpcore::apache_http_vhost | ||
$http_fragment = epp('pulpcore/apache-fragment.epp', { | ||
'directories' => [$content_directory], | ||
}) | ||
} | ||
} | ||
|
||
case $pulpcore::apache_https_vhost { | ||
true: { | ||
$https_vhost_name = 'pulpcore-https' | ||
$https_fragment = undef | ||
|
||
include apache | ||
include apache::mod::headers | ||
apache::vhost { $https_vhost_name: | ||
servername => $pulpcore::servername, | ||
port => $https_port, | ||
ssl => true, | ||
priority => $vhost_priority, | ||
docroot => $pulpcore::apache_docroot, | ||
manage_docroot => false, | ||
directories => [$docroot_directory, $content_directory, $api_directory], | ||
proxy_pass => [$proxy_pass_static], | ||
ssl_cert => $pulpcore::apache_https_cert, | ||
ssl_key => $pulpcore::apache_https_key, | ||
ssl_chain => $pulpcore::apache_https_chain, | ||
ssl_ca => $pulpcore::apache_https_ca, | ||
ssl_verify_client => $ssl_verify_client, | ||
* => $https_vhost_options, | ||
} | ||
} | ||
false: { | ||
$https_vhost_name = undef | ||
$https_fragment = undef | ||
} | ||
default: { | ||
$https_vhost_name = $pulpcore::apache_https_vhost | ||
$https_fragment = epp('pulpcore/apache-fragment.epp', { | ||
'directories' => [$content_directory, $api_directory], | ||
'proxy_pass' => [$proxy_pass_static], | ||
}) | ||
} | ||
} | ||
|
||
if $pulpcore::apache_http_vhost == true or $pulpcore::apache_https_vhost == true { | ||
file { $pulpcore::apache_docroot: | ||
ensure => directory, | ||
owner => $pulpcore::user, | ||
group => $pulpcore::group, | ||
mode => '0755', | ||
} | ||
} | ||
|
||
if $http_fragment or $https_fragment { | ||
pulpcore::apache::fragment { 'pulpcore': | ||
http_content => $http_fragment, | ||
https_content => $https_fragment, | ||
} | ||
} | ||
|
||
if $manage_selinux_boolean and ($pulpcore::apache_http_vhost or $pulpcore::apache_https_vhost) { | ||
# Doesn't use selinux::boolean since that doesn't use ensure_resource which | ||
# then conflict with the foreman module which doesn't use the selinux module. | ||
if $facts['os']['selinux']['enabled'] { | ||
selinux::boolean { 'httpd_can_network_connect': } | ||
ensure_resource('selboolean', 'httpd_can_network_connect', { | ||
value => 'on', | ||
persistent => true, | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# @summary Deploy an Apache fragment. Only intended to be used within the module | ||
# @param order | ||
# This determines the order. See apache::vhost for more details. | ||
# 165 is chosen because it's just before the Proxy setup. In Foreman a | ||
# ProxyPass /pulp ! is generated and by placing all content before that, a | ||
# broken setup is avoided. | ||
# @api private | ||
define pulpcore::apache::fragment ( | ||
Optional[String] $http_content = undef, | ||
Optional[String] $https_content = undef, | ||
Integer[0] $order = 165, | ||
) { | ||
include pulpcore::apache | ||
|
||
if $pulpcore::apache::http_vhost_name and $http_content { | ||
apache::vhost::fragment { "pulpcore-http-${title}": | ||
vhost => $pulpcore::apache::http_vhost_name, | ||
priority => $pulpcore::apache::vhost_priority, | ||
content => $http_content, | ||
order => $order, | ||
} | ||
} | ||
|
||
if $pulpcore::apache::https_vhost_name and $https_content { | ||
apache::vhost::fragment { "pulpcore-https-${title}": | ||
vhost => $pulpcore::apache::https_vhost_name, | ||
priority => $pulpcore::apache::vhost_priority, | ||
content => $https_content, | ||
order => $order, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,40 @@ | ||
# @summary Pulp Container plugin | ||
class pulpcore::plugin::container { | ||
# @param location_prefix | ||
# In the Apache configuration a location with this prefix is exposed. The | ||
# version (currently v2) will be appended. | ||
# @param registry_version_path | ||
# The path beneath the location prefix to forward. This is also appended to | ||
# the content base url. | ||
class pulpcore::plugin::container ( | ||
String $location_prefix = '/pulpcore_registry', | ||
String $registry_version_path = '/v2/', | ||
) { | ||
$context = { | ||
'directories' => [ | ||
{ | ||
'provider' => 'location', | ||
'path' => "${location_prefix}${registry_version_path}", | ||
'proxy_pass' => [ | ||
{ | ||
'url' => "${pulpcore::apache::api_base_url}${registry_version_path}", | ||
}, | ||
], | ||
'request_headers' => [ | ||
"unset ${pulpcore::apache::remote_user_environ_header}", | ||
"set ${pulpcore::apache::remote_user_environ_header} \"%{SSL_CLIENT_S_DN_CN}s\" env=SSL_CLIENT_S_DN_CN", | ||
], | ||
}, | ||
], | ||
'proxy_pass' => [ | ||
{ | ||
'path' => '/pulp/container/', | ||
'url' => "${pulpcore::apache::content_base_url}/pulp/container/", | ||
}, | ||
], | ||
} | ||
|
||
pulpcore::plugin { 'container': | ||
config => 'TOKEN_AUTH_DISABLED=True', | ||
config => 'TOKEN_AUTH_DISABLED=True', | ||
https_content => epp('pulpcore/apache-fragment.epp', $context), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,34 @@ | ||
# @summary Pulp File plugin | ||
class pulpcore::plugin::file { | ||
# @param use_pulp2_content_route | ||
# Whether to redirect the legacy (Pulp 2) URLs to the content server | ||
class pulpcore::plugin::file ( | ||
Boolean $use_pulp2_content_route = false, | ||
) { | ||
if $use_pulp2_content_route { | ||
$context = { | ||
'directories' => [ | ||
{ | ||
'provider' => 'location', | ||
'path' => '/pulp/isos', | ||
'proxy_pass' => [ | ||
{ | ||
'url' => $pulpcore::apache::content_url, | ||
}, | ||
], | ||
'request_headers' => [ | ||
'unset X-CLIENT-CERT', | ||
'set X-CLIENT-CERT "%{SSL_CLIENT_CERT}s" env=SSL_CLIENT_CERT', | ||
], | ||
}, | ||
], | ||
} | ||
$content = epp('pulpcore/apache-fragment.epp', $context) | ||
} else { | ||
$content = undef | ||
} | ||
|
||
pulpcore::plugin { 'file': | ||
http_content => $content, | ||
https_content => $content, | ||
} | ||
} |
Oops, something went wrong.