Skip to content

Commit

Permalink
Merge pull request #310 from waipeng/apache_conf
Browse files Browse the repository at this point in the history
Fix running puppetboard without vhost
  • Loading branch information
bastelfreak authored Oct 17, 2020
2 parents 1e4cfca + 1b74d19 commit 8532820
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
12 changes: 10 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Data type: `Integer[0]`

number of hours after which a node is considered "unresponsive"

Default value: `0`
Default value: `3`

##### `enable_catalog`

Expand Down Expand Up @@ -476,6 +476,14 @@ LDAP group DN for LDAP group

Default value: ``undef``

##### `virtualenv_dir`

Data type: `Stdlib::Absolutepath`

Set location where virtualenv will be installed

Default value: `$puppetboard::virtualenv_dir`

### `puppetboard::apache::vhost`

Sets up an apache::vhost to run PuppetBoard, and writes an appropriate wsgi.py from template
Expand Down Expand Up @@ -576,7 +584,7 @@ Data type: `String[1]`

Sets the Apache AllowOverride value

Default value: `$puppetboard::apache_override`
Default value: `$puppetboard::override`

##### `enable_ldap_auth`

Expand Down
2 changes: 2 additions & 0 deletions manifests/apache/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# @param ldap_bind_authoritative Determines if other authentication providers are used when a user can be mapped to a DN but the server cannot bind with the credentials
# @param ldap_require_group LDAP group to require on login
# @param ldap_require_group_dn LDAP group DN for LDAP group
# @param virtualenv_dir Set location where virtualenv will be installed
#
# @note Make sure you have purge_configs set to false in your apache class!
# @note This runs the WSGI application with a WSGIProcessGroup of $user and a WSGIApplicationGroup of %{GLOBAL}.
Expand All @@ -31,6 +32,7 @@
Optional[String[1]] $ldap_bind_authoritative = undef,
Boolean $ldap_require_group = $puppetboard::ldap_require_group,
Optional[String[1]] $ldap_require_group_dn = undef,
Stdlib::Absolutepath $virtualenv_dir = $puppetboard::virtualenv_dir,
) inherits puppetboard {
$docroot = "${basedir}/puppetboard"

Expand Down
47 changes: 46 additions & 1 deletion spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,52 @@
apache_conf_file = '/etc/apache2/conf-enabled/puppetboard.conf'
end

context 'configuring Apache / mod_wsgi' do
context 'configuring Apache without vhost / mod_wsgi' do
it 'works with no errors' do
pp = <<-EOS
# Configure Apache on this server
class { 'apache': }
$wsgi = $facts['os']['family'] ? {
'Debian' => {package_name => "libapache2-mod-wsgi-py3", mod_path => "/usr/lib/apache2/modules/mod_wsgi.so"},
default => {},
}
class { 'apache::mod::wsgi':
* => $wsgi,
}
# Configure PuppetDB
class { 'puppetdb':
disable_ssl => true,
manage_firewall => false,
}
# Configure Puppetboard
class { 'puppetboard':
manage_virtualenv => true,
manage_git => true,
require => Class['puppetdb'],
}
# Access Puppetboard through pboard.example.com
class { 'puppetboard::apache::conf': }
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_failures: true)
end
it 'answers to localhost' do
shell('/usr/bin/curl localhost/puppetboard/') do |r|
# The default puppetboard page returns 404 on empty puppetdb
# https://github.com/voxpupuli/puppetboard/issues/515
expect(r.stdout).to match(%r{404 Not Found})
expect(r.exit_code).to be_zero
end
end
# rubocop:enable RSpec/MultipleExpectations
end

context 'configuring Apache with vhost / mod_wsgi' do
it 'works with no errors' do
pp = <<-EOS
# Configure Apache on this server
Expand Down
2 changes: 1 addition & 1 deletion templates/apache/conf.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WSGIDaemonProcess puppetboard user=<%= @user -%> group=<%= @user -%> threads=<%= @threads %> maximum-requests=<%= @max_reqs %>
WSGIDaemonProcess puppetboard python-home=<%= @virtualenv_dir %> user=<%= @user -%> group=<%= @user -%> threads=<%= @threads %> maximum-requests=<%= @max_reqs %>
WSGIScriptAlias <%= @wsgi_alias -%> <%= @docroot -%>/wsgi.py

<Directory <%= @docroot -%>>
Expand Down

0 comments on commit 8532820

Please sign in to comment.