Make astute log level configurable

This change updates the astute configuration to honor the fuel debug
setting for determining when to enable debug logging for astute.

Change-Id: I0bd6940bf7e730a529b23975a11fed208dab14d4
Closes-Bug: #1588412
This commit is contained in:
Alex Schultz 2016-06-21 15:01:17 -06:00
parent a517f0121b
commit 32ab5a89b6
5 changed files with 98 additions and 18 deletions

View File

@ -1,10 +1,12 @@
notice('MODULAR: astute.pp')
$fuel_settings = parseyaml($astute_settings_yaml)
$debug = pick($::fuel_settings['DEBUG'],false)
$bootstrap_settings = pick($::fuel_settings['BOOTSTRAP'], {})
class { 'fuel::astute':
debug => $debug,
rabbitmq_host => $::fuel_settings['ADMIN_NETWORK']['ipaddress'],
rabbitmq_astute_user => $::fuel_settings['astute']['user'],
rabbitmq_astute_password => $::fuel_settings['astute']['password'],

View File

@ -1,22 +1,41 @@
# == Class: fuel::astute
#
# === Parameters
#
# [*debug*]
# (Optional) Boolean used to enable debug logging
# Defaults to $::fuel::params::debug
#
# [*rabbitmq_host*]
# [*rabbitmq_astute_user*]
# [*rabbitmq_astute_password*]
# [*bootstrap_profile*]
#
class fuel::astute(
$debug = $::fuel::params::debug,
$rabbitmq_host = $::fuel::params::rabbitmq_host,
$rabbitmq_astute_user = $::fuel::params::rabbitmq_astute_user,
$rabbitmq_astute_password = $::fuel::params::rabbitmq_astute_password,
$bootstrap_profile = $::fuel::params::bootstrap_profile,
) inherits fuel::params {
) inherits fuel::params {
$log_level = $debug ? {
true => 'debug',
default => 'info',
}
$packages = [
"psmisc",
"python-editor",
"nailgun-mcagents",
"sysstat",
"rubygem-amqp",
"rubygem-amq-protocol",
"rubygem-i18n",
"rubygem-tzinfo",
"rubygem-minitest",
"rubygem-symboltable",
"rubygem-thread_safe",
'psmisc',
'python-editor',
'nailgun-mcagents',
'sysstat',
'rubygem-amqp',
'rubygem-amq-protocol',
'rubygem-i18n',
'rubygem-tzinfo',
'rubygem-minitest',
'rubygem-symboltable',
'rubygem-thread_safe',
]
ensure_packages($packages)
@ -46,26 +65,26 @@ class fuel::astute(
mode => '0755',
} ~> Service <| title == 'astute' |>
file {"/etc/astute":
file {'/etc/astute':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
file {"/etc/astute/astuted.conf":
file {'/etc/astute/astuted.conf':
content => template('fuel/astute/astuted.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
require => File["/etc/astute"],
require => File['/etc/astute'],
} ~> Service <| title == 'astute' |>
file {"/var/log/astute":
file {'/var/log/astute':
ensure => directory,
owner => 'root',
group => 'root',
mode => 0755,
mode => '0755',
}
# FIXME(dteselkin): use correct versions of rubygem packages

View File

@ -4,6 +4,8 @@ class fuel::params {
$db_host = '127.0.0.1'
$db_port = '5432'
$debug = false
$nailgun_db_name = 'nailgun'
$nailgun_db_user = 'nailgun'
$nailgun_db_password = 'nailgun'

View File

@ -0,0 +1,57 @@
require 'spec_helper'
describe 'fuel::astute' do
shared_examples_for 'fuel::astute configuration' do
context 'with defaults' do
it 'install required packages' do
[ 'psmisc',
'python-editor',
'nailgun-mcagents',
'sysstat',
'rubygem-amqp',
'rubygem-amq-protocol',
'rubygem-i18n',
'rubygem-tzinfo',
'rubygem-minitest',
'rubygem-symboltable',
'rubygem-thread_safe',
'rubygem-astute' ].each do |pkg|
should contain_package(pkg)
end
end
it 'should configure astute.conf' do
should contain_file('/etc/astute/astuted.conf')
end
it 'should configure log level as info' do
should contain_file('/etc/sysconfig/astute').with_content(
/loglevel info/
)
end
end
context 'with debugging enabled' do
let (:params) do
{ :debug => true }
end
it 'should configure log level as debug' do
should contain_file('/etc/sysconfig/astute').with_content(
/loglevel debug/
)
end
end
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat',
:operatingsystem => 'CentOS',
:operatingsystemrelease => '7.2',
:hostname => 'hostname.example.com' }
end
it_configures 'fuel::astute configuration'
end
end

View File

@ -1 +1 @@
ASTUTE_OPTIONS="--config /etc/astute/astuted.conf --logfile /var/log/astute/astute.log --loglevel debug --workers 7"
ASTUTE_OPTIONS="--config /etc/astute/astuted.conf --logfile /var/log/astute/astute.log --loglevel <%=@log_level%> --workers 7"