From 1b74d192d0d57277e0216342ebba8d4563a2eb4e Mon Sep 17 00:00:00 2001 From: Jake Yip Date: Wed, 14 Oct 2020 13:17:23 +1100 Subject: [PATCH] Fix running puppetboard without vhost Running puppetboard without a vhost was not tested, so the changes that we made in #302 were just for puppetboard::apache::vhost, and did not extend to puppetboard::apache::conf Fix up puppetboard::apache::conf the same way, and add a test --- REFERENCE.md | 12 +++++++-- manifests/apache/conf.pp | 2 ++ spec/acceptance/class_spec.rb | 47 ++++++++++++++++++++++++++++++++++- templates/apache/conf.erb | 2 +- 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 31474f7c..d5152350 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -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` @@ -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 @@ -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` diff --git a/manifests/apache/conf.pp b/manifests/apache/conf.pp index 145285b3..6a47ff89 100644 --- a/manifests/apache/conf.pp +++ b/manifests/apache/conf.pp @@ -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}. @@ -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" diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 84e8ce57..0191c915 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -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 diff --git a/templates/apache/conf.erb b/templates/apache/conf.erb index 4cd1a085..c19ca15b 100644 --- a/templates/apache/conf.erb +++ b/templates/apache/conf.erb @@ -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 >