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

Drop Python 2, implement Python 3, replace virtualenv with native python 3 implementation, drop EPEL parameter #292

Merged
merged 7 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
.travis.yml:
secure: "Hw0ScFZ+tANSuxXvkQlHOtbnV+9O6FyIxY4e8ZuNiE+4E045olgGjqus+ffo0MoHOHzCPPbThF107yQIXXHCwIy3wzOVIjQ7KQ/yVeamCl4K9A4AFP1Pcr/zMTRdK16zrgxBH+6wDkjSxHGonT8AyUKBrT7AeET+pqxwVHvHCfo="
docker_sets:
- set: ubuntu1604-64
- set: centos7-64
- set: ubuntu1604-64{image=ubuntu:xenial-20191212}
- set: ubuntu1804-64
- set: debian9-64
- set: debian10-64
20 changes: 16 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,31 @@ matrix:
env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{image=ubuntu:xenial-20191212} BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{image=ubuntu:xenial-20191212} BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
branches:
only:
Expand Down
142 changes: 28 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,11 @@ https://github.com/voxpupuli/puppetboard
puppet module install puppet-puppetboard

### Dependencies
Note Oracle linux 5 on puppet versions 4.6.0 to 4.7.1 has pip package problem
which will cause an error trying to install puppetboard.

Note that this module no longer explicitly requires the puppetlabs apache module. If you want to use the apache functionality of this module you will have to specify that the apache module is installed with:

puppet module install puppetlabs-apache

On RedHat type systems, EPEL may also need to be configured; you can use the
[puppet/epel](https://forge.puppet.com/puppet/epel) module if you don't
already have it configured.

This module also requires the ``git`` and ``virtualenv`` packages. These can be enabled in the module by:


Expand All @@ -63,7 +57,6 @@ class { 'puppetboard':
manage_git => true,
manage_virtualenv => true,
}

```

or by:
Expand All @@ -73,9 +66,10 @@ class { 'puppetboard':
manage_git => 'latest',
manage_virtualenv => 'latest',
}

```

If the virtualenv is managed by this module, the [voxpupuli/python](https://forge.puppet.com/puppet/python#puppet-python) will be used. That module uses [voxpupuli/epel](https://forge.puppet.com/puppet/epel#configure-epel-extra-repository-for-enterprise-linux) on RHEL based platforms.

## Usage

Declare the base puppetboard manifest:
Expand Down Expand Up @@ -153,18 +147,32 @@ The first, `puppetboard::apache::vhost`, will use the `apache::vhost`
defined-type to create a full virtual host. This is useful if you want
puppetboard to be available from http://pboard.example.com:

```puppet
(The following is generic code used in our tests, it works on Debian 9 and 10, also on Ubuntu 16.04 and 18.04. It will talk to PuppetDB on localhost via http)

```puppet
# Configure Apache on this server
class { 'apache': }
class { 'apache::mod::wsgi': }
class { 'apache':
default_vhost => false,
purge_configs => true,
}
$wsgi = $facts['os']['family'] ? {
'Debian' => {package_name => "libapache2-mod-wsgi-py3", mod_path => "/usr/lib/apache2/modules/mod_wsgi.so"},
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved
default => {},
}
class { 'apache::mod::wsgi':
* => $wsgi,
}

# Configure Puppetboard
class { 'puppetboard': }
class { 'puppetboard':
manage_virtualenv => true,
manage_git => true,
require => Class['puppetdb'],
}

# Access Puppetboard through pboard.example.com
class { 'puppetboard::apache::vhost':
vhost_name => 'pboard.example.com',
vhost_name => 'localhost',
port => 80,
}
```
Expand Down Expand Up @@ -232,107 +240,13 @@ apache::vhost { 'example.acme':
}
```

### Redhat/CentOS

RedHat/CentOS has restrictions on the /etc/apache directory that require wsgi to be configured to use /var/run.

```puppet

class { 'apache::mod::wsgi':
wsgi_socket_prefix => "/var/run/wsgi",
}

```

### Apache, RedHat/CentOS and a non-standard port


```puppet

# Configure Apache on this server
class { 'apache': }
class { 'apache::mod::version': }
class { 'apache::mod::wsgi':
wsgi_socket_prefix => "/var/run/wsgi",
}

# Configure Puppetboard
class { 'puppetboard': }

# Access Puppetboard through pboard.example.com, port 8888
class { 'puppetboard::apache::vhost':
vhost_name => 'puppetboard.example.com',
port => '8888',
}
```

### RedHat/CentOS 7 with Python 3

If you want to use the latest version of Puppet Board you'll need to run Python 3.6+.

By default RHEL 7 has Python 2.7 installed, so you'll need to install a Python 3 and
the compatible version of `mod_wsgi` (the `mod_wsgi` module must be compiled to support
the specific version of Python you're running).


``` puppet
$mod_wsgi_package_name = 'rh-python36-mod_wsgi'

package { ['python3', 'python3-pip', 'python3-devel', 'python36-virtualenv']:
ensure => present,
}

# configure apache
class { 'apache':
purge_configs => false,
mpm_module => 'prefork',
default_vhost => false,
default_mods => false,
}

# configure mod_wsgi for python3
class { 'apache::mod::wsgi':
mod_path => 'modules/mod_rh-python36-wsgi.so',
package_name => $mod_wsgi_package_name,
wsgi_socket_prefix => '/var/run/wsgi',
}

# create symlinks from the isolated Red Hat directory into the
# standard Apache paths so that it can pick up the module and config
file { '/etc/httpd/conf.modules.d/10-rh-python36-wsgi.conf':
ensure => 'link',
target => '/opt/rh/httpd24/root/etc/httpd/conf.modules.d/10-rh-python36-wsgi.conf',
require => Package[$mod_wsgi_package_name],
}
file { '/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so':
ensure => 'link',
target => '/opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so',
require => Package[$mod_wsgi_package_name],
}

class { 'puppetboard':
# use python3 when setting up the virtualenv for puppetboard
virtualenv_version => '3',
# specify other parameters here
}
```

**NOTE** Below are the Yum repos needed for the various packages above.
On CentOS you'll need to package `centos-release-scl-rh` or manage
the SCL repos with the [bodgit/scl](https://github.com/bodgit/puppet-scl) module.

| OS | package | repo |
|----------|------------------------|-------------------------------|
| RHEL 7 | `python3` | `rhel-7-server-rpms` |
| RHEL 7 | `python3-pip` | `rhel-7-server-rpms` |
| RHEL 7 | `python3-devel` | `rhel-7-server-optional-rpms` |
| RHEL 7 | `python36-virtualenv` | `EPEL` |
| RHEL 7 | `rh-python36-mod_wsgi` | `rhel-server-rhscl-7-rpms` |
| CentOS 7 | `python3` | `base/7` |
| CentOS 7 | `python3-pip` | `base/7` |
| CentOS 7 | `python3-devel` | `base/7` |
| CentOS 7 | `python36-virtualenv` | `EPEL` |
| CentOS 7 | `rh-python36-mod_wsgi` | `centos-sclo-rh` |
CentOS/RedHat 7 is pretty old. Python 3 got added after the initial release and
a lot of packages are missing. For example python3.6 is available as a package,
but no matching wsgi module for apache is available. Because of that, we don't
test on CentOS 7 anymore. However, it's still possible to setup Puppetboard on
CentOS with gunicorn as a webserver and nginx/apache forwarding to it.

### Using SSL to the PuppetDB host

Expand Down Expand Up @@ -455,7 +369,7 @@ puppet resource service puppetserver ensure=running

## Development

This module is maintained by [Vox Pupuli](https://voxpupuli.org/). Voxpupuli
This module is maintained by [Vox Pupuli](https://voxpupuli.org/). Vox Pupuli
welcomes new contributions to this module, especially those that include
documentation and rspec tests. We are happy to provide guidance if necessary.

Expand All @@ -465,5 +379,5 @@ Please log tickets and issues on github.

### Authors
* Spencer Krum <krum.spencer@gmail.com>
* Voxpupuli Team
* Vox Pupuli Team
* The core of this module was based on Hunter Haugen's puppetboard-vagrant repo.
7 changes: 3 additions & 4 deletions templates/wsgi.py.erb → files/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# THIS FILE IS MANAGED BY PUPPET
from __future__ import absolute_import

import os
import sys

os.environ['PUPPETBOARD_SETTINGS'] = '<%= @basedir %>/puppetboard/settings.py'
activate_this = '<%= @basedir %>/virtenv-puppetboard/bin/activate_this.py'
exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this))

me = os.path.dirname(os.path.abspath(__file__))
os.environ['PUPPETBOARD_SETTINGS'] = os.path.join(me, 'settings.py')

# Add us to the PYTHONPATH/sys.path if we're not on it
if not me in sys.path:
sys.path.insert(0, me)
Expand Down
2 changes: 1 addition & 1 deletion manifests/apache/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

file { "${docroot}/wsgi.py":
ensure => present,
content => template('puppetboard/wsgi.py.erb'),
content => file("${module_name}/wsgi.py"),
owner => $user,
group => $group,
require => [
Expand Down
26 changes: 15 additions & 11 deletions manifests/apache/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@
# No default
class puppetboard::apache::vhost (
String $vhost_name,
String $wsgi_alias = '/',
Integer $port = 5000,
Stdlib::Unixpath $wsgi_alias = '/',
Stdlib::Port $port = 5000,
Boolean $ssl = false,
Optional[Stdlib::AbsolutePath] $ssl_cert = undef,
Optional[Stdlib::AbsolutePath] $ssl_key = undef,
Integer $threads = 5,
String $user = $puppetboard::params::user,
String $group = $puppetboard::params::group,
Integer[1] $threads = 5,
String[1] $user = $puppetboard::params::user,
String[1] $group = $puppetboard::params::group,
Stdlib::AbsolutePath $basedir = $puppetboard::params::basedir,
String $override = $puppetboard::params::apache_override,
Boolean $enable_ldap_auth = $puppetboard::params::enable_ldap_auth,
Expand All @@ -98,24 +98,28 @@
Optional[String] $ldap_bind_authoritative = undef,
Boolean $ldap_require_group = $puppetboard::params::ldap_require_group,
Optional[String] $ldap_require_group_dn = undef,
Stdlib::Absolutepath $virtualenv_dir = $puppetboard::params::virtualenv_dir,
Hash $custom_apache_parameters = {},
) inherits ::puppetboard::params {
Hash $wsgi_daemon_process_options_extra = {},
) inherits puppetboard::params {

$docroot = "${basedir}/puppetboard"

$wsgi_script_aliases = {
"${wsgi_alias}" => "${docroot}/wsgi.py",
}

$wsgi_daemon_process_options = {
threads => $threads,
group => $group,
user => $user,
$wsgi_daemon_process_options_default = {
threads => $threads,
group => $group,
user => $user,
python-home => $virtualenv_dir,
}
$wsgi_daemon_process_options = merge($wsgi_daemon_process_options_default, $wsgi_daemon_process_options_extra)

file { "${docroot}/wsgi.py":
ensure => present,
content => template('puppetboard/wsgi.py.erb'),
content => file("${module_name}/wsgi.py"),
owner => $user,
group => $group,
require => [
Expand Down
Loading