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

various small changes to the redmine module #1882

Merged
merged 10 commits into from
Sep 4, 2023
75 changes: 49 additions & 26 deletions puppet/modules/redmine/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Stdlib::Absolutepath $data_dir = '/var/lib/redmine',
String $servername = 'projects.theforeman.org',
Stdlib::Httpsurl $repo_url = 'https://github.com/theforeman/redmine',
Optional[String] $repo_branch = undef,
String $username = 'redmine',
String $db_name = 'redmine',
String $db_password = extlib::cache_data('foreman_cache_data', 'db_password', extlib::random_password(32)),
Expand All @@ -38,14 +39,24 @@
# PostgreSQL tuning
$postgresql_settings = {
'checkpoint_completion_target' => '0.9',
'checkpoint_segments' => '20',
'effective_cache_size' => '2GB',
'shared_buffers' => '512MB',
'work_mem' => '4MB',
}

# Needed for bundle install
if $facts['os']['release']['major'] == '8' {
package { 'ruby dnf module':
evgeni marked this conversation as resolved.
Show resolved Hide resolved
ensure => '2.7',
name => 'ruby',
enable_only => true,
provider => 'dnfmodule',
before => Package['rubygem-bundler.noarch', 'ruby-devel'],
}
}

$packages = [
'git',
'rubygem-bundler.noarch',
'ruby-devel',
'gcc',
Expand All @@ -54,6 +65,8 @@
'ImageMagick-devel',
'postgresql-devel',
'sqlite-devel',
'redhat-rpm-config',
'make',
]

ensure_packages($packages)
Expand All @@ -73,7 +86,7 @@

postgresql::server::db { $db_name:
user => $username,
password => postgresql_password($username, $db_password),
password => postgresql::postgresql_password($username, $db_password),
owner => $username,
encoding => 'utf8',
locale => 'en_US.utf8',
Expand All @@ -99,16 +112,24 @@
content => template('redmine/secure_config.yaml.erb'),
}

file { $app_root:
ensure => directory,
owner => $username,
}

vcsrepo { $app_root:
ensure => present,
provider => 'git',
source => $repo_url,
revision => $repo_branch,
owner => $username,
user => $username,
notify => Exec['install redmine'],
}

# TODO: this should lay down a .bundle/config instead of using --path
exec { 'install redmine':
command => 'bundle install',
command => 'bundle install --path ./vendor',
evgeni marked this conversation as resolved.
Show resolved Hide resolved
user => $username,
cwd => $app_root,
path => $::path,
Expand Down Expand Up @@ -138,15 +159,12 @@
include web::base

$docroot = "${app_root}/public"
$min_instances = 1
$start_timeout = 600
$priority = '05'

letsencrypt::certonly { $servername:
plugin => 'webroot',
domains => [$servername],
webroot_paths => [$docroot],
require => Vcsrepo[$app_root],
$apache_backend_config = {
passenger_app_root => $app_root,
passenger_min_instances => 1,
passenger_start_timeout => 600,
}

apache::vhost { $servername:
Expand All @@ -159,25 +177,30 @@
}

if $https {
letsencrypt::certonly { $servername:
plugin => 'webroot',
domains => [$servername],
webroot_paths => [$docroot],
require => Vcsrepo[$app_root],
}

apache::vhost { "${servername}-https":
add_default_charset => 'UTF-8',
docroot => $docroot,
manage_docroot => false,
port => 443,
options => ['SymLinksIfOwnerMatch'],
passenger_app_root => $app_root,
passenger_min_instances => $min_instances,
passenger_start_timeout => $start_timeout,
priority => $priority,
servername => $servername,
ssl => true,
ssl_cert => "/etc/letsencrypt/live/${servername}/fullchain.pem",
ssl_chain => "/etc/letsencrypt/live/${servername}/chain.pem",
ssl_key => "/etc/letsencrypt/live/${servername}/privkey.pem",
headers => [
add_default_charset => 'UTF-8',
docroot => $docroot,
manage_docroot => false,
port => 443,
options => ['SymLinksIfOwnerMatch'],
priority => $priority,
servername => $servername,
ssl => true,
ssl_cert => "/etc/letsencrypt/live/${servername}/fullchain.pem",
ssl_chain => "/etc/letsencrypt/live/${servername}/chain.pem",
ssl_key => "/etc/letsencrypt/live/${servername}/privkey.pem",
headers => [
'set Strict-Transport-Security: max-age=15778800;',
],
require => [Letsencrypt::Certonly[$servername], Exec['install redmine']],
require => [Letsencrypt::Certonly[$servername], Exec['install redmine']],
* => $apache_backend_config,
}
}

Expand Down