Support LodgeIt installation on EL7 derivatives

This commit aims to make this module work on EL7 derivatives.

It :

  * Creates a /etc/sysconfig/lodgeit-MYINSTANCE configuration file
  * Creates a systemd unit file to manage lodgeit instances
  * Install the proper packages for the platform

Change-Id: Ifdc874e5f4c66c336d8e3dc1c731ca28d6415a46
Depends-On: I82241038d687316f91f18209fe8323c12422e2f8
Depends-On: If58c09095a530fcb54e2a42948183aabf6805e41
This commit is contained in:
Yanis Guenane 2015-10-13 10:26:00 +02:00
parent 7a03ae7eb1
commit d1b3bacc6d
4 changed files with 94 additions and 26 deletions

11
files/lodgeit.service Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=The %i LodgeIt Application
After=network.target basic.target
[Service]
EnvironmentFile=-/etc/sysconfig/lodgeit-%i
ExecStart=/bin/python /srv/lodgeit/%i/manage.py runserver -h ${LISTEN} -p ${PORT}
ExecStop=/bin/kill -WINCH ${MAINPID}
[Install]
WantedBy=multi-user.target

View File

@ -1,29 +1,27 @@
# == Class: lodgeit
#
class lodgeit {
$packages = [ 'python-imaging',
'python-jinja2',
'python-pybabel',
'python-werkzeug',
'python-simplejson',
'python-pygments']
include ::lodgeit::params
include ::httpd
include ::pip
httpd_mod { 'proxy':
ensure => present,
# The httpd module supports only Debian/Ubuntu (requires a2enmod)
# On EL7 derivative both of those modules are part of the httpd package
# Hence there is no need for extra action
if $::osfamily == 'Debian' {
httpd_mod { ['proxy', 'proxy_http'] :
ensure => present,
}
}
httpd_mod { 'proxy_http':
package { $::lodgeit::params::system_packages:
ensure => present,
}
package { $packages:
ensure => present,
}
if ! defined(Package['python-mysqldb']) {
package { 'python-mysqldb':
if ! defined(Package[$::lodgeit::params::mysql_python_package]) {
package { $::lodgeit::params::mysql_python_package:
ensure => present,
}
}
@ -44,4 +42,18 @@ class lodgeit {
source => 'https://git.openstack.org/openstack-infra/lodgeit',
}
if $::osfamily == 'RedHat' {
file { '/etc/systemd/system/lodgeit@.service':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
source => 'puppet:///modules/lodgeit/lodgeit.service',
} ~>
exec { '/bin/systemctl daemon-reload' : }
}
}

27
manifests/params.pp Normal file
View File

@ -0,0 +1,27 @@
# === Class : lodgeit::params
class lodgeit::params {
$common_packages = ['python-jinja2',
'python-babel',
'python-werkzeug',
'python-simplejson',
'python-pygments']
case $::osfamily {
'RedHat' : {
$system_packages = concat($common_packages, 'python-pillow')
$mysql_python_package = 'MySQL-python'
$lodgeit_service_provider = undef
}
'Debian' : {
$system_packages = concat($common_packages, 'python-imaging')
$mysql_python_package = 'python-mysqldb'
$lodgeit_service_provider = 'upstart'
}
default : {
fail("LodgeIt: The Operating System ${::osfamily} is not supported")
}
}
}

View File

@ -12,21 +12,38 @@ define lodgeit::site(
) {
include ::httpd
include ::lodgeit::params
::httpd::vhost::proxy { $vhost_name:
port => 80,
dest => "http://localhost:${port}",
dest => "http://127.0.0.1:${port}",
require => [File["/srv/lodgeit/${name}"], File["/srv/www/${name}"]],
proxyexclusions => ['/robots.txt'],
docroot => "/srv/www/${name}/"
}
file { "/etc/init/${name}-paste.conf":
ensure => present,
content => template('lodgeit/upstart.erb'),
replace => true,
require => Class['httpd'],
notify => Service["${name}-paste"],
if $::osfamily == 'RedHat' {
Exec['/bin/systemctl daemon-reload'] -> Service["lodgeit@${name}"]
$service_name = "lodgeit@${name}"
file { "/etc/sysconfig/lodgeit-${name}":
ensure => present,
content => "PORT=${port}\nLISTEN=127.0.0.1",
notify => Service[$service_name],
}
} else {
$service_name = "${name}-paste"
file { "/etc/init/${name}-paste.conf":
ensure => present,
content => template('lodgeit/upstart.erb'),
replace => true,
notify => Service[$service_name],
}
}
file { "/srv/lodgeit/${name}":
@ -47,7 +64,7 @@ define lodgeit::site(
mode => '0755',
replace => true,
content => template('lodgeit/manage.py.erb'),
notify => Service["${name}-paste"],
notify => Service[$service_name],
}
file { "/srv/lodgeit/${name}/lodgeit/views/layout.html":
@ -81,9 +98,10 @@ define lodgeit::site(
database_password => $db_password,
}
service { "${name}-paste":
service { $service_name:
ensure => running,
provider => upstart,
provider => $::lodgeit::params::service_provider,
require => Class['httpd'],
}
}