From 265bd8fe1d2e8f21c63610dfe4211cf6a1cf87ec Mon Sep 17 00:00:00 2001 From: Ruslan Kamaldinov Date: Mon, 6 Jan 2014 06:33:45 +0400 Subject: [PATCH] Add Storyboard puppet module There are two major parts being installed with this module: 1. storyboard-api - REST API service served with apache mod_wsgi module 2. storyboard-webclient - static html/css/js files. This project is built and published to tarballs.o.o, from where it'll be installed with this puppet module This module requires three configs from Hiera: * storyboard_db_host * storyboard_db_password * storyboard_db_user Installed projects: * http://git.openstack.org/cgit/openstack-infra/storyboard/ * http://git.openstack.org/cgit/openstack-infra/storyboard-webclient/ Things to be added in later commits: * Documentation for ci.openstack.org * Configure logging (once supported by storyboard) * SSL Change-Id: If3da06f8d20a6282036f1f9f063c25a6d0db60c6 --- manifests/site.pp | 10 + .../openstack_project/manifests/storyboard.pp | 22 +++ modules/storyboard/manifests/init.pp | 180 ++++++++++++++++++ .../storyboard/templates/storyboard.conf.erb | 2 + .../storyboard/templates/storyboard.vhost.erb | 17 ++ 5 files changed, 231 insertions(+) create mode 100644 modules/openstack_project/manifests/storyboard.pp create mode 100644 modules/storyboard/manifests/init.pp create mode 100644 modules/storyboard/templates/storyboard.conf.erb create mode 100644 modules/storyboard/templates/storyboard.vhost.erb diff --git a/manifests/site.pp b/manifests/site.pp index 941234ce19..ea6abc056b 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -438,6 +438,16 @@ node 'summit.openstack.org' { } } +# A machine to run Storyboard +node 'storyboard.openstack.org' { + class { 'openstack_project::storyboard': + sysadmins => hiera('sysadmins'), + mysql_host => hiera('storyboard_db_host'), + mysql_user => hiera('storyboard_db_user'), + mysql_password => hiera('storyboard_db_password'), + } +} + # A machine to serve static content. node 'static.openstack.org' { class { 'openstack_project::static': diff --git a/modules/openstack_project/manifests/storyboard.pp b/modules/openstack_project/manifests/storyboard.pp new file mode 100644 index 0000000000..ace22f69e7 --- /dev/null +++ b/modules/openstack_project/manifests/storyboard.pp @@ -0,0 +1,22 @@ +# == Class: openstack_project::storyboard +# +class openstack_project::storyboard( + $mysql_host = '', + $mysql_password = '', + $mysql_user = '', + $sysadmins = [], +) { + class { 'openstack_project::server': + sysadmins => $sysadmins, + iptables_public_tcp_ports => [80], + } + + class { '::storyboard': + mysql_host => $mysql_host, + mysql_password => $mysql_password, + mysql_user => $mysql_user, + projects_file => + 'puppet:///modules/openstack_project/review.projects.yaml', + } + +} diff --git a/modules/storyboard/manifests/init.pp b/modules/storyboard/manifests/init.pp new file mode 100644 index 0000000000..504e580faf --- /dev/null +++ b/modules/storyboard/manifests/init.pp @@ -0,0 +1,180 @@ +# Copyright (c) 2014 Mirantis Inc. +# +# 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: storyboard +# +class storyboard ( + $vhost_name = $::fqdn, + $mysql_host, + $mysql_password, + $mysql_user, + $projects_file, + $storyboard_git_source_repo = 'https://git.openstack.org/openstack-infra/storyboard/', + $storyboard_revision = 'master', + $storyboard_webclient_url = 'http://tarballs.openstack.org/storyboard-webclient/storyboard-webclient-latest.tar.gz' + +) { + include apache + include mysql::python + include pip + + package { 'libapache2-mod-wsgi': + ensure => present, + } + + package { 'curl': + ensure => present, + } + + group { 'storyboard': + ensure => present, + } + + user { 'storyboard': + ensure => present, + home => '/home/storyboard', + shell => '/bin/bash', + gid => 'storyboard', + managehome => true, + require => Group['storyboard'], + } + + vcsrepo { '/opt/storyboard': + ensure => latest, + provider => git, + revision => $storyboard_revision, + source => $storyboard_git_source_repo, + } + + exec { 'install-storyboard' : + command => 'pip install /opt/storyboard', + path => '/usr/local/bin:/usr/bin:/bin/', + refreshonly => true, + subscribe => Vcsrepo['/opt/storyboard'], + notify => Exec['storyboard-reload'], + require => Class['pip'], + } + + file { '/etc/storyboard': + ensure => directory, + } + + file { '/etc/storyboard/storyboard.conf': + ensure => present, + owner => 'storyboard', + mode => '0400', + content => template('storyboard/storyboard.conf.erb'), + notify => Exec['storyboard-reload'], + require => [ + File['/etc/storyboard'], + User['storyboard'], + ], + } + + file { '/etc/storyboard/projects.yaml': + ensure => present, + owner => 'storyboard', + mode => '0400', + source => $projects_file, + replace => true, + require => [ + File['/etc/storyboard'], + User['storyboard'], + ], + } + + exec { 'migrate-storyboard-db': + command => 'storyboard-db-manage --config-file /etc/storyboard/storyboard.conf upgrade head', + path => '/usr/local/bin:/usr/bin:/bin/', + refreshonly => true, + subscribe => Exec['install-storyboard'], + require => [ + File['/etc/storyboard/storyboard.conf'], + ], + } + + file { '/var/log/storyboard': + ensure => directory, + owner => 'storyboard', + require => User['storyboard'], + } + + exec { 'storyboard-reload': + command => 'touch /usr/local/lib/python2.7/dist-packages/storyboard/api/app.wsgi', + path => '/usr/local/bin:/usr/bin:/bin/', + refreshonly => true, + } + + # START storyboard-webclient + $tarball = 'storyboard-webclient.tar.gz' + + file { '/var/lib/storyboard': + ensure => directory, + owner => 'storyboard', + group => 'storyboard', + } + + # Using -z here to only download when the tarball has changed. + exec { 'get-webclient': + command => "curl ${storyboard_webclient_url} -z ./${tarball} -o ${tarball}", + path => '/bin:/usr/bin', + cwd => '/var/lib/storyboard', + require => [ + File['/var/lib/storyboard'], + Package['curl'], + ] + } + + exec { 'unpack-webclient': + command => "tar -xzf ${tarball}", + path => '/bin:/usr/bin', + cwd => '/var/lib/storyboard', + require => Exec['get-webclient'], + } + + file { '/var/lib/storyboard/www': + ensure => directory, + owner => 'storyboard', + group => 'storyboard', + require => Exec['unpack-webclient'], + source => '/var/lib/storyboard/dist', + recurse => true, + purge => true, + force => true + } + + # END storyboard-webclient + + apache::vhost { $vhost_name: + port => 80, + docroot => 'MEANINGLESS ARGUMENT', + priority => '50', + template => 'storyboard/storyboard.vhost.erb', + require => Package['libapache2-mod-wsgi'], + } + + a2mod { 'proxy': + ensure => present, + } + + a2mod { 'proxy_http': + ensure => present, + } + + a2mod {'wsgi': + ensure => present, + require => Package['libapache2-mod-wsgi'], + } + +} diff --git a/modules/storyboard/templates/storyboard.conf.erb b/modules/storyboard/templates/storyboard.conf.erb new file mode 100644 index 0000000000..a3278ae2b2 --- /dev/null +++ b/modules/storyboard/templates/storyboard.conf.erb @@ -0,0 +1,2 @@ +[database] +connection=mysql://<%= mysql_user %>:<%= mysql_password %>@<%= mysql_host %>:3306/storyboard diff --git a/modules/storyboard/templates/storyboard.vhost.erb b/modules/storyboard/templates/storyboard.vhost.erb new file mode 100644 index 0000000000..fd656253c8 --- /dev/null +++ b/modules/storyboard/templates/storyboard.vhost.erb @@ -0,0 +1,17 @@ + + DocumentRoot /var/lib/storyboard/www + ErrorLog /var/log/apache2/storyboard-error.log + CustomLog /var/log/apache2/storyboard-access.log common + + WSGIDaemonProcess storyboard user=storyboard group=storyboard threads=5 python-path=/usr/local/lib/python2.7/dist-packages + WSGIScriptAlias /api /usr/local/lib/python2.7/dist-packages/storyboard/api/app.wsgi + + # The app.wsgi file has to be accessible by apache. It won't + # be visible to clients because of the DocumentRoot though. + + WSGIProcessGroup storyboard + WSGIApplicationGroup %{GLOBAL} + Order deny,allow + Allow from all + +