Ian Wienand a8682baa18 Enable build logs on builder, web app on launchers
There is currently a confusing array of exporting options for
exporting build and upload logs.  The upload logs have never really
worked, and the info is better given from image-list end-points.  The
build logs since Ia7415d2fbbb320f8eddc4e46c3a055414df5f997 are logged
into separate files into /var/log/nodepool/builds.  With a separate
builder, it can not access the webapp ports provided by the launcher,
so the redirects there are wrong -- and we don't deploy apache on the
launcher to expose them.  If you're using single node anyway, it's
more than likely you have zuul which installs the main website so
can't enable this.

For these reasons deprecate and remove these old settings.

Instead, add a separate flag to each of the builder and launcher.

builder::enable_build_log_via_http will deploy apache and a config
file that exposes /var/log/nodepool/builds

launcher::enable_webapp will deploy apache and redirects to the
internal webapp

Note this does not handle a launcher and builder on the same host;
since the webapp, and indeed refactoring this module in general for
multiple daemons, is under some development, we leave this as a future
task.

Depends-On: https://review.openstack.org/543667
Change-Id: I447886dd32f7f3bc6758ffd7a1b725689d04ee68
2018-02-13 14:15:03 +11:00

116 lines
3.3 KiB
Puppet

# Copyright 2015 2015 IBM
#
# 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: nodepool::launcher
#
class nodepool::launcher(
$statsd_host = undef,
$statsd_prefix = undef,
$nodepool_ssh_public_key = undef,
$launcher_logging_conf_template = 'nodepool/nodepool-launcher.logging.conf.erb',
# If true, an apache will be setup to redirect webapp end-points to
# the local webapp instance (on port 8005)
$enable_webapp = false,
$vhost_name = $::fqdn,
) {
if ! defined(File['/home/nodepool/.ssh']) {
file { '/home/nodepool/.ssh':
ensure => directory,
mode => '0500',
owner => 'nodepool',
group => 'nodepool',
require => User['nodepool'],
}
}
if ($nodepool_ssh_public_key != undef) {
file { '/home/nodepool/.ssh/id_rsa.pub':
ensure => present,
content => $nodepool_ssh_public_key,
mode => '0644',
owner => 'nodepool',
group => 'nodepool',
require => File['/home/nodepool/.ssh'],
}
}
file { '/etc/init.d/nodepool-launcher':
ensure => present,
mode => '0555',
owner => 'root',
group => 'root',
source => 'puppet:///modules/nodepool/nodepool-launcherv3.init',
}
file { '/etc/default/nodepool-launcher':
ensure => present,
content => template('nodepool/nodepool-launcherv3.default.erb'),
mode => '0444',
owner => 'root',
group => 'root',
}
file { '/etc/nodepool/launcher-logging.conf':
ensure => present,
mode => '0444',
owner => 'root',
group => 'root',
content => template($launcher_logging_conf_template),
}
if ($::operatingsystem == 'Ubuntu') and ($::operatingsystemrelease >= '16.04') {
# This is a hack to make sure that systemd is aware of the new service
# before we attempt to start it.
exec { 'nodepool-launcher-systemd-daemon-reload':
command => '/bin/systemctl daemon-reload',
before => Service['nodepool-launcher'],
subscribe => File['/etc/init.d/nodepool-launcher'],
refreshonly => true,
}
}
service { 'nodepool-launcher':
name => 'nodepool-launcher',
enable => true,
hasrestart => true,
require => [
File['/etc/init.d/nodepool-launcher'],
File['/etc/default/nodepool-launcher'],
File['/etc/nodepool/launcher-logging.conf'],
],
}
if $enable_webapp == true {
include ::httpd
::httpd::vhost { $vhost_name:
port => 80,
priority => '50',
docroot => 'MEANINGLESS_ARGUMENT',
template => 'nodepool/nodepool-launcher.vhost.erb',
}
if ! defined(Httpd::Mod['rewrite']) {
httpd::mod { 'rewrite': ensure => present }
}
if ! defined(Httpd::Mod['proxy']) {
httpd::mod { 'proxy': ensure => present }
}
if ! defined(Httpd::Mod['proxy_http']) {
httpd::mod { 'proxy_http': ensure => present }
}
}
}