Added WebClient installer.

This commit is contained in:
Michael Krotscheck 2015-04-22 15:22:18 -07:00
parent 7cd53e46c6
commit 0e50af1532
8 changed files with 174 additions and 34 deletions

View File

@ -20,22 +20,49 @@
class refstack::apache::http () {
require ::refstack::params
require ::refstack::api
# require ::refstack::app
require ::refstack::app
# Pull various variables into this module, for slightly saner templates.
# Pull various variables into this module, for slightly saner templates.
$install_api_root = $::refstack::params::install_api_root
$install_www_root = $::refstack::params::install_www_root
$src_www_root = $::refstack::params::src_www_root
$hostname = $::refstack::params::hostname
$user = $::refstack::params::user
$group = $::refstack::params::group
$server_admin = $::refstack::params::server_admin
$python_version = $::refstack::params::python_version
# Install apache
# Install apache
include apache
include apache::params
include apache::mod::wsgi
# Set up refstack as HTTP
# Create a copy of the wsgi file with apache user permissions.
file { '/etc/refstack/app.wsgi':
ensure => present,
owner => $::apache::params::user,
group => $::apache::params::group,
mode => '0644',
source => "${src_www_root}/refstack/api/app.wsgi",
require => [
Class['refstack::api']
],
notify => Service['httpd'],
}
# Synchronize the app directory and the apache directory.
file { $install_www_root:
ensure => directory,
owner => $::apache::params::user,
group => $::apache::params::group,
source => "${src_www_root}/refstack-ui/app",
recurse => true,
purge => true,
force => true,
notify => Service['httpd'],
}
# Set up refstack as HTTP
apache::vhost { $hostname:
port => 80,
docroot => $install_www_root,
@ -43,5 +70,6 @@ class refstack::apache::http () {
template => 'refstack/refstack_http.vhost.erb',
ssl => false,
notify => Service['httpd'],
require => File['/etc/refstack/app.wsgi'],
}
}

View File

@ -18,14 +18,14 @@
# protocol.
#
class refstack::apache::https () {
require ::refstack::params
require ::refstack::api
# require ::refstack::app
require ::refstack::app
# Pull various variables into this module, for slightly saner templates.
$install_api_root = $::refstack::params::install_api_root
$install_www_root = $::refstack::params::install_www_root
$src_www_root = $::refstack::params::src_www_root
$hostname = $::refstack::params::hostname
$user = $::refstack::params::user
$group = $::refstack::params::group
@ -41,8 +41,22 @@ class refstack::apache::https () {
# Install apache
include apache
include apache::params
include apache::mod::wsgi
# Create a copy of the wsgi file with apache user permissions.
file { '/etc/refstack/app.wsgi':
ensure => present,
owner => $::apache::params::user,
group => $::apache::params::group,
mode => '0644',
source => "${src_www_root}/refstack/api/app.wsgi",
require => [
Class['refstack::api']
],
notify => Service['httpd'],
}
if $ssl_cert_content != undef {
file { $ssl_cert:
owner => 'root',
@ -73,6 +87,18 @@ class refstack::apache::https () {
}
}
# Synchronize the app directory and the apache directory.
file { $install_www_root:
ensure => directory,
owner => $::apache::params::user,
group => $::apache::params::group,
source => "${src_www_root}/refstack-ui/app",
recurse => true,
purge => true,
force => true,
notify => Service['httpd'],
}
# Set up ::refstack as HTTPS
apache::vhost { $hostname:
port => 443,
@ -81,5 +107,6 @@ class refstack::apache::https () {
template => 'refstack/refstack_https.vhost.erb',
ssl => true,
notify => Service['httpd'],
require => File['/etc/refstack/app.wsgi'],
}
}

View File

@ -49,19 +49,12 @@ class refstack::api () {
}
}
# Ensure PyMysqldb is present
if !defined(Package['python-mysqldb']) {
package { 'python-mysqldb':
ensure => present
}
}
# Create the refstack configuration directory.
file { '/etc/refstack':
ensure => directory,
owner => $user,
group => $group,
mode => '0700',
mode => '0755',
}
# Configure the refstack API
@ -69,7 +62,7 @@ class refstack::api () {
ensure => present,
owner => $user,
group => $group,
mode => '0400',
mode => '0644',
content => template('refstack/refstack.conf.erb'),
require => [
File['/etc/refstack']
@ -104,14 +97,13 @@ class refstack::api () {
}
# Run pip from the venv, install refstack.
python::pip { 'refstack':
pkgname => 'refstack',
ensure => present,
virtualenv => $install_api_root,
url => "file://${src_api_root}",
owner => $user,
require => Vcsrepo[$src_api_root],
subscribe => Vcsrepo[$src_api_root],
exec { 'pip install':
command => "${install_api_root}/bin/pip install ${src_api_root}",
user => $user,
group => $group,
refreshonly => true,
require => Vcsrepo[$src_api_root],
subscribe => Vcsrepo[$src_api_root],
}
# Migrate the database
@ -120,12 +112,11 @@ class refstack::api () {
path => "${install_api_root}/bin/:/usr/local/bin:/usr/bin:/bin/",
refreshonly => true,
subscribe => [
Python::Pip['refstack'],
Exec['pip install'],
File['/etc/refstack/refstack.conf'],
],
require => [
Package['python-mysqldb'],
Python::Pip['refstack'],
Exec['pip install'],
File['/etc/refstack/refstack.conf'],
],
}

88
manifests/app.pp Normal file
View File

@ -0,0 +1,88 @@
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# == Class: refstack::app
#
# This class installs the refstack JavaScript Webclient (or app).
#
# Much of this module is duplicated in ::refstack::api, however it's separated
# here so that any future project splits (api vs. client) can be treated
# similarly in the puppet module.
#
class refstack::app () {
require ::refstack::params
require ::refstack::user
# Import parameters into local scope.
$src_www_root = $::refstack::params::src_www_root
$install_www_root = $::refstack::params::install_www_root
$user = $::refstack::params::user
$group = $::refstack::params::group
# Ensure Git is present
if !defined(Package['git']) {
package { 'git':
ensure => present
}
}
# Ensure NPM is present
if !defined(Package['npm']) {
package { 'npm':
ensure => present
}
}
if !defined(Package['nodejs']) {
package { 'nodejs':
ensure => present
}
}
if !defined(Package['nodejs-legacy']) {
package { 'nodejs-legacy':
ensure => present
}
}
# Download the latest Refstack Source
vcsrepo { $src_www_root:
ensure => latest,
owner => $user,
group => $group,
provider => git,
revision => 'master',
source => 'https://git.openstack.org/stackforge/refstack/',
require => Package['git']
}
# Run NPM Install
exec { 'npm install':
command => 'npm install',
path => "/usr/local/bin:/usr/bin:/bin/",
cwd => "${src_www_root}/refstack-ui",
user => $user,
group => $group,
refreshonly => true,
subscribe => [
Vcsrepo[$src_www_root],
],
require => [
Package['npm'],
Vcsrepo[$src_www_root],
],
environment => [
# This is not automatically set by exec.
'HOME=/home/refstack'
]
}
}

View File

@ -34,7 +34,7 @@ class refstack (
}
include ::refstack::mysql
include ::refstack::app
include ::refstack::api
include ::refstack::apache::http
}

View File

@ -55,7 +55,7 @@ class refstack::params (
$install_api_root = "/var/lib/refstack-py${python_version}"
# Build the connection string from individual parameters
$mysql_connection_string = "mysql://${mysql_user}:${mysql_user_password}@${mysql_host}:${mysql_port}/${mysql_database}"
$mysql_connection_string = "mysql+pymysql://${mysql_user}:${mysql_user_password}@${mysql_host}:${mysql_port}/${mysql_database}"
# CA file needs special treatment, since we want the path variable
# to be undef in some cases.

View File

@ -8,9 +8,9 @@ WSGIPythonHome <%= @install_api_root %>
DocumentRoot <%= @install_www_root %>
# WSGIDaemonProcess refstack user=<%= @user %> group=<%= @group %> threads=5
# WSGIScriptAlias /api <%= @install_api_root %>/lib/python<%= @python_version %>/site-packages/refstack/api/app.wsgi
# WSGIPassAuthorization On
WSGIDaemonProcess refstack user=<%= @user %> group=<%= @group %> threads=5
WSGIScriptAlias /api /etc/refstack/app.wsgi
WSGIPassAuthorization On
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/refstack-error.log
CustomLog ${APACHE_LOG_DIR}/refstack-access.log combined
@ -18,4 +18,7 @@ WSGIPythonHome <%= @install_api_root %>
<Directory "<%= @install_api_root %>">
Require all granted
</Directory>
<Directory "/etc/refstack">
Require all granted
</Directory>
</VirtualHost>

View File

@ -49,12 +49,15 @@ WSGIPythonHome <%= @install_api_root %>
DocumentRoot <%= @install_www_root %>
# WSGIDaemonProcess storyboard user=<%= @user %> group=<%= @group %> threads=5
# WSGIScriptAlias /api <%= @install_api_root %>/lib/python<%= @python_version %>/site-packages/storyboard/api/app.wsgi
# WSGIPassAuthorization On
WSGIDaemonProcess refstack user=<%= @user %> group=<%= @group %> threads=5
WSGIScriptAlias /api /etc/refstack/app.wsgi
WSGIPassAuthorization On
<Directory "<%= @install_api_root %>">
Require all granted
</Directory>
<Directory "/etc/refstack">
Require all granted
</Directory>
</VirtualHost>
</IfModule>