From c974b922e948793d69d3f8c23e8921ada0b8516d Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 16 Oct 2015 16:36:09 -0400 Subject: [PATCH] Add site module to deploy frontend to a dir This commit adds a site.pp file which is used to deploy the frontend to a directory instead of setting up a vhost. When deploying this on status.o.o we need to put the dashboard in a dir on an existing vhost instead of deploying a seperate one. This commit adds the class to do this. Change-Id: Ic47fbd817a293a257f7a9b164682fc96cce5321e --- manifests/frontend.pp | 31 ++++++++++-------------------- manifests/site.pp | 40 +++++++++++++++++++++++++++++++++++++++ manifests/vhost.pp | 32 +++++++++++++++++++++++++++++++ templates/config.json.erb | 3 +++ 4 files changed, 85 insertions(+), 21 deletions(-) create mode 100644 manifests/site.pp create mode 100644 manifests/vhost.pp create mode 100644 templates/config.json.erb diff --git a/manifests/frontend.pp b/manifests/frontend.pp index 0af6c05..564389a 100644 --- a/manifests/frontend.pp +++ b/manifests/frontend.pp @@ -2,24 +2,12 @@ # params: # source_dir: # The directory where the application will be running -# serveradmin: -# Used in the Apache virtual host, eg., openstack-health@openstack.org -# vhost_name: -# Used in the Apache virtual host, eg., health.openstack.org -# vhost_port: -# Used in the Apache virtual host, eg., 5000 -# api_endpoint: -# The URL where openstack-health API is running + class openstack_health::frontend( $source_dir = '/opt/openstack-health', - $serveradmin = "webmaster@${::fqdn}", - $vhost_name = 'localhost', - $vhost_port = 80, - $api_endpoint = 'http://localhost:5000', + $api_endpoint, ) { - $frontend_dir = "${source_dir}/build" - class { '::nodejs': legacy_debian_symlinks => true, repo_url_suffix => 'node_0.12', @@ -57,12 +45,13 @@ class openstack_health::frontend( subscribe => Vcsrepo[$source_dir], } - ::httpd::vhost { "${vhost_name}-frontend": - docroot => 'MEANINGLESS ARGUMENT', - port => $vhost_port, - priority => '100', - ssl => false, - template => 'openstack_health/openstack-health-frontend.vhost.erb', - require => Exec['build-static-files'], + file { "${source_dir}/build/config.json": + ensure => present, + owner => 'openstack_health', + group => 'openstack_health', + mode => '0755', + content => template('openstack_health/config.json.erb'), + require => Exec['build-static-files'] } + } diff --git a/manifests/site.pp b/manifests/site.pp new file mode 100644 index 0000000..e9433f7 --- /dev/null +++ b/manifests/site.pp @@ -0,0 +1,40 @@ +# Copyright (c) 2014 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. +# +# == Define: openstack_health::site +# + +define openstack_health::site( + $httproot, + $api_endpoint = 'http://localhost:5000' +) { + + class { '::openstack_health::frontend': + api_endpoint => $api_endpoint + } + + exec {'move-static-files': + command => "mv ${openstack_health::source_dir}/build ${httproot}", + path => ['/usr/local/bin/', '/usr/bin/', '/bin/'], + subscribe => Exec['build-static-files'] + } + + file {$httproot: + ensure => directory, + owner => 'openstack_health', + group => 'openstack_health', + mode => '0755', + require => Exec['move-static-files'] + } +} diff --git a/manifests/vhost.pp b/manifests/vhost.pp new file mode 100644 index 0000000..1e131cc --- /dev/null +++ b/manifests/vhost.pp @@ -0,0 +1,32 @@ +# Install and maintain OpenStack Health. +# params: +# serveradmin: +# Used in the Apache virtual host, eg., openstack-health@openstack.org +# vhost_name: +# Used in the Apache virtual host, eg., health.openstack.org +# vhost_port: +# Used in the Apache virtual host, eg., 5000 +# api_endpoint: +# The URL where openstack-health API is running +class openstack_health::vhost( + $serveradmin = "webmaster@${::fqdn}", + $vhost_name = 'localhost', + $vhost_port = 80, + $api_endpoint = 'http://localhost:5000', +) { + + class { '::openstack_health::frontend': + api_endpoint => $api_endpoint + } + + $frontend_dir = "${openstack_health::source_dir}/build" + + httpd::vhost { "${vhost_name}-frontend": + docroot => 'MEANINGLESS ARGUMENT', + port => $vhost_port, + priority => '100', + ssl => false, + template => 'openstack_health/openstack-health-frontend.vhost.erb', + require => Exec['build-static-files'], + } +} diff --git a/templates/config.json.erb b/templates/config.json.erb new file mode 100644 index 0000000..c49a9ee --- /dev/null +++ b/templates/config.json.erb @@ -0,0 +1,3 @@ +{ + "apiRoot": <%= @api_endpoint %> +}