Create dedicated "apache" base profile

This profile has multiple purposes:
- group common httpd configurations/instructions
- correct a small issue with the "status" mod

Until now, only Horizon was specifically including this mode, and as
httpd wasn't listening on localhost, it wasn't in use at all.

With this commit, all API using apache will be able to provide the httpd
server status on 127.0.0.1/server-status.

Change-Id: If6d64f807c244d7e56852a67ac7dbad26c4c002f
Closes-Bug: 1724751
(cherry picked from commit ca7239a5dc)
This commit is contained in:
Cédric Jeanneret 2017-10-19 08:32:09 +02:00 committed by Emilien Macchi
parent 5cac802425
commit e807e860fd
7 changed files with 122 additions and 5 deletions

View File

@ -36,8 +36,8 @@ class tripleo::profile::base::aodh::api (
include ::tripleo::profile::base::aodh
if $step >= 3 {
include ::tripleo::profile::base::apache
include ::aodh::api
include ::apache::mod::ssl
include ::aodh::wsgi::apache
#NOTE: Combination alarms are deprecated in newton and disabled by default.

View File

@ -0,0 +1,43 @@
# Copyright 2017 Camptocamp SA.
#
# 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 tripleo::profile::base::apache
#
# Common apache modules and configurationfor API listeners
#
# === Parameters
#
# [*enable_status_listener*]
# Enable or not the localhost listener in httpd.
# Accepted values: Boolean.
# Default to false.
#
# [*status_listener*]
# Where should apache listen for status page
# Default to 127.0.0.1:80
class tripleo::profile::base::apache(
$enable_status_listener = false,
$status_listener = '127.0.0.1:80',
) {
include ::apache::mod::status
include ::apache::mod::ssl
if $enable_status_listener {
if !defined(Apache::Listen[$status_listener]) {
::apache::listen {$status_listener: }
}
}
}

View File

@ -30,7 +30,7 @@ class tripleo::profile::base::ceilometer::api (
if $step >= 4 {
include ::ceilometer::api
include ::apache::mod::ssl
include ::ceilometer::wsgi::apache
include ::tripleo::profile::base::apache
}
}

View File

@ -50,8 +50,8 @@ class tripleo::profile::base::gnocchi::api (
if $step >= 4 {
include ::gnocchi::api
include ::apache::mod::ssl
include ::gnocchi::wsgi::apache
include ::tripleo::profile::base::apache
class { '::gnocchi::storage':
coordination_url => join(['redis://:', hiera('gnocchi_redis_password'), '@', normalize_ip_for_uri(hiera('redis_vip')), ':6379/']),

View File

@ -29,7 +29,8 @@ class tripleo::profile::base::horizon (
if $step >= 3 {
# Horizon
include ::apache::mod::remoteip
include ::apache::mod::status
include ::tripleo::profile::base::apache
if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers', undef) {
$_profile_support = 'cisco'
} else {

View File

@ -87,8 +87,8 @@ class tripleo::profile::base::keystone (
}
include ::keystone::config
include ::apache::mod::ssl
include ::keystone::wsgi::apache
include ::tripleo::profile::base::apache
include ::keystone::cors
if $manage_roles {

View File

@ -0,0 +1,73 @@
#
# Copyright (C) 2017 Camptocamp SA.
#
# 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.
#
require 'spec_helper'
describe 'tripleo::profile::base::apache' do
shared_examples_for 'tripleo::profile::base::apache' do
context 'with default params' do
it 'should trigger complete configuration' do
is_expected.to contain_class('apache::mod::status')
is_expected.to contain_class('apache::mod::ssl')
is_expected.to_not contain_apache__listen('127.0.0.1:80')
end
end
context 'Activate listener' do
let(:params) { {
:enable_status_listener => true,
} }
it 'should trigger complete configuration' do
is_expected.to contain_class('apache::mod::status')
is_expected.to contain_class('apache::mod::ssl')
is_expected.to contain_apache__listen('127.0.0.1:80')
end
end
context 'Change listener' do
let(:params) {{
:enable_status_listener => true,
:status_listener => '10.10.0.10:80',
}}
it 'should trigger complete configuration' do
is_expected.to contain_class('apache::mod::status')
is_expected.to contain_class('apache::mod::ssl')
is_expected.to contain_apache__listen('10.10.0.10:80')
end
end
context 'Provide wrong value for ensure_status_listener' do
let(:params) {{
:enable_status_listener => 'fooo',
}}
it { is_expected.to compile.and_raise_error(/expects a Boolean value/) }
end
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({ :hostname => 'node.example.com' })
end
it_behaves_like 'tripleo::profile::base::apache'
end
end
end