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

Manage libnginx-mod-http-passenger on modern Debian / Ubuntu #1376

Merged
merged 12 commits into from
Mar 22, 2020
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
$ssl_prefer_server_ciphers = $nginx::ssl_prefer_server_ciphers
$ssl_protocols = $nginx::ssl_protocols
$ssl_ciphers = $nginx::ssl_ciphers
$include_modules_enabled = $nginx::include_modules_enabled

# Non-configurable settings
$conf_template = 'nginx/conf.d/nginx.conf.erb'
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
Boolean $super_user = $nginx::params::super_user,
$temp_dir = $nginx::params::temp_dir,
Boolean $server_purge = false,
Boolean $include_modules_enabled = $nginx::params::include_modules_enabled,
smortex marked this conversation as resolved.
Show resolved Hide resolved

# Primary Templates
$conf_template = 'nginx/conf.d/nginx.conf.erb',
Expand Down Expand Up @@ -166,6 +167,7 @@
Boolean $mime_types_preserve_defaults = false,
Optional[String] $repo_release = undef,
$passenger_package_ensure = 'present',
String $passenger_package_name = $nginx::params::passenger_package_name,
smortex marked this conversation as resolved.
Show resolved Hide resolved
Optional[Stdlib::HTTPUrl] $repo_source = undef,
### END Package Configuration ###

Expand Down
3 changes: 2 additions & 1 deletion manifests/package/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$package_ensure = $nginx::package_ensure
$package_flavor = $nginx::package_flavor
$passenger_package_ensure = $nginx::passenger_package_ensure
$passenger_package_name = $nginx::passenger_package_name
$manage_repo = $nginx::manage_repo
$release = $nginx::repo_release
$repo_source = $nginx::repo_source
Expand Down Expand Up @@ -71,7 +72,7 @@
key => {'id' => '16378A33A6EF16762922526E561F9B9CAC40B2F7'},
}

package { 'passenger':
package { $passenger_package_name:
ensure => $passenger_package_ensure,
require => Exec['apt_update'],
}
Expand Down
3 changes: 2 additions & 1 deletion manifests/package/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$package_ensure = $nginx::package_ensure
$package_flavor = $nginx::package_flavor
$passenger_package_ensure = $nginx::passenger_package_ensure
$passenger_package_name = $nginx::passenger_package_name
$manage_repo = $nginx::manage_repo
$purge_passenger_repo = $nginx::purge_passenger_repo

Expand Down Expand Up @@ -88,7 +89,7 @@
before => Package['nginx'],
}

package { 'passenger':
package { $passenger_package_name:
ensure => $passenger_package_ensure,
require => Yumrepo['passenger'],
}
Expand Down
95 changes: 55 additions & 40 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
### Operating System Configuration
## This is my hacky... no hiera system. Oh well. :)
$_module_defaults = {
'conf_dir' => '/etc/nginx',
'daemon_user' => 'nginx',
'pid' => '/var/run/nginx.pid',
'root_group' => 'root',
'log_dir' => '/var/log/nginx',
'log_user' => 'nginx',
'log_group' => 'root',
'log_mode' => '0750',
'run_dir' => '/var/nginx',
'package_name' => 'nginx',
'manage_repo' => false,
'mime_types' => {
'conf_dir' => '/etc/nginx',
'daemon_user' => 'nginx',
'pid' => '/var/run/nginx.pid',
'root_group' => 'root',
'log_dir' => '/var/log/nginx',
'log_user' => 'nginx',
'log_group' => 'root',
'log_mode' => '0750',
'run_dir' => '/var/nginx',
'package_name' => 'nginx',
'passenger_package_name' => 'passenger',
'manage_repo' => false,
'include_modules_enabled' => false,
'mime_types' => {
'text/html' => 'html htm shtml',
'text/css' => 'css',
'text/xml' => 'xml',
Expand Down Expand Up @@ -107,9 +109,20 @@
}
}
'Debian': {
# $facts['os']['distro']['codename'] is not yet well established, so we stick with the legact lsb facts for now
if ($facts['os']['name'] == 'ubuntu' and $facts['lsbdistcodename'] in ['lucid', 'precise', 'trusty', 'xenial', 'bionic']) # lint:ignore:legacy_facts
or ($facts['os']['name'] == 'debian' and $facts['os']['release']['major'] in ['6', '7', '8', '9', '10']) {
if ($facts['os']['name'] == 'ubuntu' and $facts['os']['distro']['codename'] in ['bionic'])
or ($facts['os']['name'] == 'debian' and $facts['os']['release']['major'] in ['9', '10']) {
$_module_os_overrides = {
'manage_repo' => true,
'daemon_user' => 'www-data',
'log_user' => 'root',
'log_group' => 'adm',
'log_mode' => '0755',
'run_dir' => '/run/nginx',
'passenger_package_name' => 'libnginx-mod-http-passenger',
'include_modules_enabled' => true,
}
} elsif ($facts['os']['name'] == 'ubuntu' and $facts['os']['distro']['codename'] in ['lucid', 'precise', 'trusty', 'xenial'])
or ($facts['os']['name'] == 'debian' and $facts['os']['release']['major'] in ['6', '7', '8']) {
$_module_os_overrides = {
'manage_repo' => true,
'daemon_user' => 'www-data',
Expand Down Expand Up @@ -204,31 +217,33 @@
### END Operating System Configuration

### Referenced Variables
$conf_dir = $_module_parameters['conf_dir']
$snippets_dir = "${conf_dir}/snippets"
$log_dir = $_module_parameters['log_dir']
$log_user = $_module_parameters['log_user']
$log_group = $_module_parameters['log_group']
$log_mode = $_module_parameters['log_mode']
$run_dir = $_module_parameters['run_dir']
$temp_dir = '/tmp'
$pid = $_module_parameters['pid']
$conf_dir = $_module_parameters['conf_dir']
$snippets_dir = "${conf_dir}/snippets"
$log_dir = $_module_parameters['log_dir']
$log_user = $_module_parameters['log_user']
$log_group = $_module_parameters['log_group']
$log_mode = $_module_parameters['log_mode']
$run_dir = $_module_parameters['run_dir']
$temp_dir = '/tmp'
$pid = $_module_parameters['pid']
$include_modules_enabled = $_module_parameters['include_modules_enabled']

$client_body_temp_path = "${run_dir}/client_body_temp"
$daemon_user = $_module_parameters['daemon_user']
$global_owner = 'root'
$global_group = $_module_parameters['root_group']
$global_mode = '0644'
$http_access_log_file = 'access.log'
$manage_repo = $_module_parameters['manage_repo']
$mime_types = $_module_parameters['mime_types']
$nginx_error_log_file = 'error.log'
$root_group = $_module_parameters['root_group']
$package_name = $_module_parameters['package_name']
$proxy_temp_path = "${run_dir}/proxy_temp"
$sites_available_owner = 'root'
$sites_available_group = $_module_parameters['root_group']
$sites_available_mode = '0644'
$super_user = true
$client_body_temp_path = "${run_dir}/client_body_temp"
$daemon_user = $_module_parameters['daemon_user']
$global_owner = 'root'
$global_group = $_module_parameters['root_group']
$global_mode = '0644'
$http_access_log_file = 'access.log'
$manage_repo = $_module_parameters['manage_repo']
$mime_types = $_module_parameters['mime_types']
$nginx_error_log_file = 'error.log'
$root_group = $_module_parameters['root_group']
$package_name = $_module_parameters['package_name']
$passenger_package_name = $_module_parameters['passenger_package_name']
$proxy_temp_path = "${run_dir}/proxy_temp"
$sites_available_owner = 'root'
$sites_available_group = $_module_parameters['root_group']
$sites_available_mode = '0644'
$super_user = true
### END Referenced Variables
}
2 changes: 1 addition & 1 deletion spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pkg_match = %r{passenger}
when 'Debian'
pkg_cmd = 'dpkg -s nginx | grep ^Maintainer'
pkg_remove_cmd = 'apt-get -y remove nginx nginx-common'
pkg_remove_cmd = 'apt-get -y purge nginx nginx-common'
pkg_match = case fact('operatingsystemmajrelease')
when '9', '10'
%r{Debian Nginx Maintainers}
Expand Down
7 changes: 6 additions & 1 deletion spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@
let(:params) { { package_source: 'passenger' } }

it { is_expected.to contain_package('nginx') }
it { is_expected.to contain_package('passenger') }
if facts[:lsbdistid] == 'Debian' && %w[9 10].include?(facts.dig(:os, 'release', 'major')) ||
facts[:lsbdistid] == 'Ubuntu' && %w[bionic].include?(facts[:lsbdistcodename])
it { is_expected.to contain_package('libnginx-mod-http-passenger') }
else
it { is_expected.to contain_package('passenger') }
end
it do
is_expected.to contain_apt__source('nginx').with(
'location' => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
Expand Down
3 changes: 3 additions & 0 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ worker_rlimit_nofile <%= @worker_rlimit_nofile %>;
<% if @pid -%>
pid <%= @pid %>;
<% end -%>
<% if @include_modules_enabled -%>
include /etc/nginx/modules-enabled/*.conf;
<% end -%>
<% if @nginx_cfg_prepend -%>

<%- field_width = @nginx_cfg_prepend.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
Expand Down