puppet-aodh: Initial commit
This is the initial commit for puppet-aodh. It has been automatically generated using cookiecutter[1] and msync[2] [1] https://github.com/openstack/puppet-openstack-cookiecutter [2] https://github.com/openstack/puppet-modulesync-configs Change-Id: I17611e8608931cf69b8d9891620e901a8936e19echanges/15/225015/4
parent
67198dcec2
commit
ca85542cc2
|
@ -0,0 +1,13 @@
|
|||
fixtures:
|
||||
repositories:
|
||||
'concat':
|
||||
'repo': 'git://github.com/puppetlabs/puppetlabs-concat.git'
|
||||
'ref': '1.2.2'
|
||||
'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile'
|
||||
'keystone': 'git://github.com/openstack/puppet-keystone.git'
|
||||
'mysql': 'git://github.com/puppetlabs/puppetlabs-mysql.git'
|
||||
'openstacklib': 'git://github.com/openstack/puppet-openstacklib.git'
|
||||
'postgresql': 'git://github.com/puppetlabs/puppetlabs-postgresql.git'
|
||||
'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
|
||||
symlinks:
|
||||
aodh: "#{source_dir}"
|
|
@ -0,0 +1,10 @@
|
|||
pkg/
|
||||
Gemfile.lock
|
||||
vendor/
|
||||
spec/fixtures/
|
||||
.vagrant/
|
||||
.bundle/
|
||||
coverage/
|
||||
.idea/
|
||||
*.swp
|
||||
*.iml
|
|
@ -0,0 +1,36 @@
|
|||
source ENV['GEM_SOURCE'] || "https://rubygems.org"
|
||||
|
||||
group :development, :test do
|
||||
gem 'puppetlabs_spec_helper', :require => 'false'
|
||||
gem 'rspec-puppet', '~> 2.2.0', :require => 'false'
|
||||
gem 'metadata-json-lint', :require => 'false'
|
||||
gem 'puppet-lint-param-docs', :require => 'false'
|
||||
gem 'puppet-lint-absolute_classname-check', :require => 'false'
|
||||
gem 'puppet-lint-absolute_template_path', :require => 'false'
|
||||
gem 'puppet-lint-trailing_newline-check', :require => 'false'
|
||||
gem 'puppet-lint-unquoted_string-check', :require => 'false'
|
||||
gem 'puppet-lint-leading_zero-check', :require => 'false'
|
||||
gem 'puppet-lint-variable_contains_upcase', :require => 'false'
|
||||
gem 'puppet-lint-numericvariable', :require => 'false'
|
||||
gem 'json', :require => 'false'
|
||||
gem 'webmock', :require => 'false'
|
||||
end
|
||||
|
||||
group :system_tests do
|
||||
gem 'beaker-rspec', :require => 'false'
|
||||
gem 'beaker-puppet_install_helper', :require => 'false'
|
||||
end
|
||||
|
||||
if facterversion = ENV['FACTER_GEM_VERSION']
|
||||
gem 'facter', facterversion, :require => false
|
||||
else
|
||||
gem 'facter', :require => false
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
||||
|
||||
# vim:ft=ruby
|
|
@ -0,0 +1,13 @@
|
|||
Copyright 2015 OpenStack Foundation
|
||||
|
||||
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.
|
|
@ -0,0 +1,78 @@
|
|||
AODH
|
||||
====
|
||||
|
||||
#### Table of Contents
|
||||
|
||||
1. [Overview - What is the AODH module?](#overview)
|
||||
2. [Module Description - What does the module do?](#module-description)
|
||||
3. [Setup - The basics of getting started with AODH](#setup)
|
||||
4. [Implementation - An under-the-hood peek at what the module is doing](#implementation)
|
||||
5. [Limitations - OS compatibility, etc.](#limitations)
|
||||
6. [Development - Guide for contributing to the module](#development)
|
||||
7. [Contributors - Those with commits](#contributors)
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
The AODH module is a part of [OpenStack](https://github.com/openstack), an effort by the Openstack infrastructure team to provide continuous integration testing and code review for Openstack and Openstack community projects not part of the core software. The module its self is used to flexibly configure and manage the Alarming service for Openstack.
|
||||
|
||||
Module Description
|
||||
------------------
|
||||
|
||||
The AODH module is a thorough attempt to make Puppet capable of managing the entirety of AODH. This includes manifests to provision region specific endpoint and database connections. Types are shipped as part of the AODH module to assist in manipulation of configuration files.
|
||||
|
||||
Setup
|
||||
-----
|
||||
|
||||
**What the AODH module affects**
|
||||
|
||||
* [AODH](http://docs.openstack.org/developer/aodh/), the Alarming service for Openstack.
|
||||
|
||||
### Installing AODH
|
||||
|
||||
AODH is not currently in Puppet Forge, but is anticipated to be added soon. Once that happens, you'll be able to install AODH with:
|
||||
puppet module install openstack/aodh
|
||||
|
||||
### Beginning with AODH
|
||||
|
||||
To utilize the AODH module's functionality you will need to declare multiple resources. The following is a modified excerpt from the [openstack module](https://github.com/stackfoge/puppet-openstack). This is not an exhaustive list of all the components needed, we recommend you consult and understand the [openstack module](https://github.com/stackforge/puppet-openstack) and the [core openstack](http://docs.openstack.org) documentation.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
### AODH
|
||||
|
||||
AODH is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers.
|
||||
|
||||
Limitations
|
||||
------------
|
||||
|
||||
* All the AODH types use the CLI tools and so need to be ran on the AODH node.
|
||||
|
||||
Beaker-Rspec
|
||||
------------
|
||||
|
||||
This module has beaker-rspec tests
|
||||
|
||||
To run the tests on the default vagrant node:
|
||||
|
||||
```shell
|
||||
bundle install
|
||||
bundle exec rake acceptance
|
||||
```
|
||||
|
||||
For more information on writing and running beaker-rspec tests visit the documentation:
|
||||
|
||||
* https://github.com/puppetlabs/beaker/wiki/How-to-Write-a-Beaker-Test-for-a-Module
|
||||
|
||||
Development
|
||||
-----------
|
||||
|
||||
Developer documentation for the entire puppet-openstack project.
|
||||
|
||||
* https://wiki.openstack.org/wiki/Puppet-openstack#Developer_documentation
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* https://github.com/openstack/puppet-aodh/graphs/contributors
|
|
@ -0,0 +1,21 @@
|
|||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint/tasks/puppet-lint'
|
||||
require 'puppet-syntax/tasks/puppet-syntax'
|
||||
|
||||
PuppetSyntax.exclude_paths ||= []
|
||||
PuppetSyntax.exclude_paths << "spec/fixtures/**/*"
|
||||
PuppetSyntax.exclude_paths << "pkg/**/*"
|
||||
PuppetSyntax.exclude_paths << "vendor/**/*"
|
||||
|
||||
Rake::Task[:lint].clear
|
||||
PuppetLint::RakeTask.new :lint do |config|
|
||||
config.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"]
|
||||
config.fail_on_warnings = true
|
||||
config.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}'
|
||||
config.disable_checks = ["80chars", "class_inherits_from_params_class", "class_parameter_defaults", "only_variable_string"]
|
||||
end
|
||||
|
||||
desc "Run acceptance tests"
|
||||
RSpec::Core::RakeTask.new(:acceptance) do |t|
|
||||
t.pattern = 'spec/acceptance'
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
Puppet::Type.type(:aodh_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||
) do
|
||||
|
||||
def self.file_path
|
||||
'/etc/aodh/aodh.conf'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,51 @@
|
|||
Puppet::Type.newtype(:aodh_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from aodh.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
newvalues(/^[\S ]*$/)
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
newparam(:ensure_absent_val) do
|
||||
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
|
||||
defaultto('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'aodh'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,30 @@
|
|||
# == Class: aodh::config
|
||||
#
|
||||
# This class is used to manage arbitrary aodh configurations.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*aodh_config*]
|
||||
# (optional) Allow configuration of arbitrary aodh configurations.
|
||||
# The value is an hash of aodh_config resources. Example:
|
||||
# { 'DEFAULT/foo' => { value => 'fooValue'},
|
||||
# 'DEFAULT/bar' => { value => 'barValue'}
|
||||
# }
|
||||
# In yaml format, Example:
|
||||
# aodh_config:
|
||||
# DEFAULT/foo:
|
||||
# value: fooValue
|
||||
# DEFAULT/bar:
|
||||
# value: barValue
|
||||
#
|
||||
# NOTE: The configuration MUST NOT be already handled by this module
|
||||
# or Puppet catalog compilation will fail with duplicate resources.
|
||||
#
|
||||
class aodh::config (
|
||||
$aodh_config = {},
|
||||
) {
|
||||
|
||||
validate_hash($aodh_config)
|
||||
|
||||
create_resources('aodh_config', $aodh_config)
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
# == Class: aodh::db
|
||||
#
|
||||
# Configure the aodh database
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*database_connection*]
|
||||
# Url used to connect to database.
|
||||
# (Optional) Defaults to "sqlite:////var/lib/aodh/aodh.sqlite".
|
||||
#
|
||||
# [*database_idle_timeout*]
|
||||
# Timeout when db connections should be reaped.
|
||||
# (Optional) Defaults to 3600.
|
||||
#
|
||||
# [*database_max_retries*]
|
||||
# Maximum number of database connection retries during startup.
|
||||
# Setting -1 implies an infinite retry count.
|
||||
# (Optional) Defaults to 10.
|
||||
#
|
||||
# [*database_retry_interval*]
|
||||
# Interval between retries of opening a database connection.
|
||||
# (Optional) Defaults to 10.
|
||||
#
|
||||
# [*database_min_pool_size*]
|
||||
# Minimum number of SQL connections to keep open in a pool.
|
||||
# (Optional) Defaults to 1.
|
||||
#
|
||||
# [*database_max_pool_size*]
|
||||
# Maximum number of SQL connections to keep open in a pool.
|
||||
# (Optional) Defaults to 10.
|
||||
#
|
||||
# [*database_max_overflow*]
|
||||
# If set, use this value for max_overflow with sqlalchemy.
|
||||
# (Optional) Defaults to 20.
|
||||
#
|
||||
class aodh::db (
|
||||
$database_connection = 'sqlite:////var/lib/aodh/aodh.sqlite',
|
||||
$database_idle_timeout = 3600,
|
||||
$database_min_pool_size = 1,
|
||||
$database_max_pool_size = 10,
|
||||
$database_max_retries = 10,
|
||||
$database_retry_interval = 10,
|
||||
$database_max_overflow = 20,
|
||||
) {
|
||||
|
||||
$database_connection_real = pick($::aodh::database_connection, $database_connection)
|
||||
$database_idle_timeout_real = pick($::aodh::database_idle_timeout, $database_idle_timeout)
|
||||
$database_min_pool_size_real = pick($::aodh::database_min_pool_size, $database_min_pool_size)
|
||||
$database_max_pool_size_real = pick($::aodh::database_max_pool_size, $database_max_pool_size)
|
||||
$database_max_retries_real = pick($::aodh::database_max_retries, $database_max_retries)
|
||||
$database_retry_interval_real = pick($::aodh::database_retry_interval, $database_retry_interval)
|
||||
$database_max_overflow_real = pick($::aodh::database_max_overflow, $database_max_overflow)
|
||||
|
||||
validate_re($database_connection_real,
|
||||
'(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
if $database_connection_real {
|
||||
case $database_connection_real {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
}
|
||||
/^postgresql:\/\//: {
|
||||
$backend_package = $::aodh::params::psycopg_package_name
|
||||
}
|
||||
/^sqlite:\/\//: {
|
||||
$backend_package = $::aodh::params::sqlite_package_name
|
||||
}
|
||||
default: {
|
||||
fail('Unsupported backend configured')
|
||||
}
|
||||
}
|
||||
|
||||
if $backend_package and !defined(Package[$backend_package]) {
|
||||
package {'aodh-backend-package':
|
||||
ensure => present,
|
||||
name => $backend_package,
|
||||
tag => 'openstack',
|
||||
}
|
||||
}
|
||||
|
||||
aodh_config {
|
||||
'database/connection': value => $database_connection_real, secret => true;
|
||||
'database/idle_timeout': value => $database_idle_timeout_real;
|
||||
'database/min_pool_size': value => $database_min_pool_size_real;
|
||||
'database/max_retries': value => $database_max_retries_real;
|
||||
'database/retry_interval': value => $database_retry_interval_real;
|
||||
'database/max_pool_size': value => $database_max_pool_size_real;
|
||||
'database/max_overflow': value => $database_max_overflow_real;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
# The aodh::db::mysql class implements mysql backend for aodh
|
||||
#
|
||||
# This class can be used to create tables, users and grant
|
||||
# privelege for a mysql aodh database.
|
||||
#
|
||||
# == parameters
|
||||
#
|
||||
# [*password*]
|
||||
# (Mandatory) Password to connect to the database.
|
||||
# Defaults to 'false'.
|
||||
#
|
||||
# [*dbname*]
|
||||
# (Optional) Name of the database.
|
||||
# Defaults to 'aodh'.
|
||||
#
|
||||
# [*user*]
|
||||
# (Optional) User to connect to the database.
|
||||
# Defaults to 'aodh'.
|
||||
#
|
||||
# [*host*]
|
||||
# (Optional) The default source host user is allowed to connect from.
|
||||
# Defaults to '127.0.0.1'
|
||||
#
|
||||
# [*allowed_hosts*]
|
||||
# (Optional) Other hosts the user is allowed to connect from.
|
||||
# Defaults to 'undef'.
|
||||
#
|
||||
# [*charset*]
|
||||
# (Optional) The database charset.
|
||||
# Defaults to 'utf8'
|
||||
#
|
||||
# [*collate*]
|
||||
# (Optional) The database collate.
|
||||
# Only used with mysql modules >= 2.2.
|
||||
# Defaults to 'utf8_general_ci'
|
||||
#
|
||||
# == Dependencies
|
||||
# Class['mysql::server']
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# == Authors
|
||||
#
|
||||
# == Copyright
|
||||
#
|
||||
class aodh::db::mysql(
|
||||
$password,
|
||||
$dbname = 'aodh',
|
||||
$user = 'aodh',
|
||||
$host = '127.0.0.1',
|
||||
$charset = 'utf8',
|
||||
$collate = 'utf8_general_ci',
|
||||
$allowed_hosts = undef
|
||||
) {
|
||||
|
||||
validate_string($password)
|
||||
|
||||
::openstacklib::db::mysql { 'aodh':
|
||||
user => $user,
|
||||
password_hash => mysql_password($password),
|
||||
dbname => $dbname,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
collate => $collate,
|
||||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Mysql['aodh'] ~> Exec<| title == 'aodh-manage db_sync' |>
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
# == Class: aodh::db::postgresql
|
||||
#
|
||||
# Class that configures postgresql for aodh
|
||||
# Requires the Puppetlabs postgresql module.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*password*]
|
||||
# (Required) Password to connect to the database.
|
||||
#
|
||||
# [*dbname*]
|
||||
# (Optional) Name of the database.
|
||||
# Defaults to 'aodh'.
|
||||
#
|
||||
# [*user*]
|
||||
# (Optional) User to connect to the database.
|
||||
# Defaults to 'aodh'.
|
||||
#
|
||||
# [*encoding*]
|
||||
# (Optional) The charset to use for the database.
|
||||
# Default to undef.
|
||||
#
|
||||
# [*privileges*]
|
||||
# (Optional) Privileges given to the database user.
|
||||
# Default to 'ALL'
|
||||
#
|
||||
# == Dependencies
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# == Authors
|
||||
#
|
||||
# == Copyright
|
||||
#
|
||||
class aodh::db::postgresql(
|
||||
$password,
|
||||
$dbname = 'aodh',
|
||||
$user = 'aodh',
|
||||
$encoding = undef,
|
||||
$privileges = 'ALL',
|
||||
) {
|
||||
|
||||
Class['aodh::db::postgresql'] -> Service<| title == 'aodh' |>
|
||||
|
||||
::openstacklib::db::postgresql { 'aodh':
|
||||
password_hash => postgresql_password($user, $password),
|
||||
dbname => $dbname,
|
||||
user => $user,
|
||||
encoding => $encoding,
|
||||
privileges => $privileges,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['aodh'] ~> Exec<| title == 'aodh-manage db_sync' |>
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# Class to execute "aodh-manage db_sync
|
||||
#
|
||||
class aodh::db::sync {
|
||||
exec { 'aodh-manage db_sync':
|
||||
path => '/usr/bin',
|
||||
user => 'aodh',
|
||||
refreshonly => true,
|
||||
subscribe => [Package['aodh'], Aodh_config['database/connection']],
|
||||
require => User['aodh'],
|
||||
}
|
||||
|
||||
Exec['aodh-manage db_sync'] ~> Service<| title == 'aodh' |>
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
# == Class: aodh
|
||||
#
|
||||
# Full description of class aodh here.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*sample_parameter*]
|
||||
# Explanation of what this parameter affects and what it defaults to.
|
||||
#
|
||||
class aodh {
|
||||
|
||||
include ::aodh::params
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
# == Class: aodh::keystone::auth
|
||||
#
|
||||
# Configures aodh user, service and endpoint in Keystone.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*password*]
|
||||
# (required) Password for aodh user.
|
||||
#
|
||||
# [*auth_name*]
|
||||
# Username for aodh service. Defaults to 'aodh'.
|
||||
#
|
||||
# [*email*]
|
||||
# Email for aodh user. Defaults to 'aodh@localhost'.
|
||||
#
|
||||
# [*tenant*]
|
||||
# Tenant for aodh user. Defaults to 'services'.
|
||||
#
|
||||
# [*configure_endpoint*]
|
||||
# Should aodh endpoint be configured? Defaults to 'true'.
|
||||
#
|
||||
# [*configure_user*]
|
||||
# (Optional) Should the service user be configured?
|
||||
# Defaults to 'true'.
|
||||
#
|
||||
# [*configure_user_role*]
|
||||
# (Optional) Should the admin role be configured for the service user?
|
||||
# Defaults to 'true'.
|
||||
#
|
||||
# [*service_type*]
|
||||
# Type of service. Defaults to 'alarming'.
|
||||
#
|
||||
# [*public_protocol*]
|
||||
# Protocol for public endpoint. Defaults to 'http'.
|
||||
#
|
||||
# [*public_address*]
|
||||
# Public address for endpoint. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*admin_protocol*]
|
||||
# Protocol for admin endpoint. Defaults to 'http'.
|
||||
#
|
||||
# [*admin_address*]
|
||||
# Admin address for endpoint. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*internal_protocol*]
|
||||
# Protocol for internal endpoint. Defaults to 'http'.
|
||||
#
|
||||
# [*internal_address*]
|
||||
# Internal address for endpoint. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*port*]
|
||||
# Port for endpoint. Defaults to '8042'.
|
||||
#
|
||||
# [*public_port*]
|
||||
# Port for public endpoint. Defaults to $port.
|
||||
#
|
||||
# [*region*]
|
||||
# Region for endpoint. Defaults to 'RegionOne'.
|
||||
#
|
||||
# [*service_name*]
|
||||
# (optional) Name of the service.
|
||||
# Defaults to the value of auth_name.
|
||||
#
|
||||
#
|
||||
class aodh::keystone::auth (
|
||||
$password,
|
||||
$auth_name = 'aodh',
|
||||
$email = 'aodh@localhost',
|
||||
$tenant = 'services',
|
||||
$configure_endpoint = true,
|
||||
$configure_user = true,
|
||||
$configure_user_role = true,
|
||||
$service_name = undef,
|
||||
$service_type = 'alarming',
|
||||
$public_protocol = 'http',
|
||||
$public_address = '127.0.0.1',
|
||||
$admin_protocol = 'http',
|
||||
$admin_address = '127.0.0.1',
|
||||
$internal_protocol = 'http',
|
||||
$internal_address = '127.0.0.1',
|
||||
$port = '8042',
|
||||
$public_port = undef,
|
||||
$region = 'RegionOne'
|
||||
) {
|
||||
|
||||
$real_service_name = pick($service_name, $auth_name)
|
||||
|
||||
if $configure_user_role {
|
||||
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'aodh-server' |>
|
||||
}
|
||||
Keystone_endpoint["${region}/${real_service_name}"] ~> Service <| name == 'aodh-server' |>
|
||||
|
||||
if ! $public_port {
|
||||
$real_public_port = $port
|
||||
} else {
|
||||
$real_public_port = $public_port
|
||||
}
|
||||
|
||||
keystone::resource::service_identity { 'aodh':
|
||||
configure_user => $configure_user,
|
||||
configure_user_role => $configure_user_role,
|
||||
configure_endpoint => $configure_endpoint,
|
||||
service_name => $real_service_name,
|
||||
service_type => $service_type,
|
||||
service_description => 'AODH Alarming Service',
|
||||
region => $region,
|
||||
auth_name => $auth_name,
|
||||
password => $password,
|
||||
email => $email,
|
||||
tenant => $tenant,
|
||||
public_url => "${public_protocol}://${public_address}:${real_public_port}/",
|
||||
internal_url => "${internal_protocol}://${internal_address}:${port}/",
|
||||
admin_url => "${admin_protocol}://${admin_address}:${port}/",
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,211 @@
|
|||
# Class aodh::logging
|
||||
#
|
||||
# aodh extended logging configuration
|
||||
#
|
||||
# == parameters
|
||||
#
|
||||
# [*logging_context_format_string*]
|
||||
# (optional) Format string to use for log messages with context.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
|
||||
# [%(request_id)s %(user_identity)s] %(instance)s%(message)s'
|
||||
#
|
||||
# [*logging_default_format_string*]
|
||||
# (optional) Format string to use for log messages without context.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
|
||||
# [-] %(instance)s%(message)s'
|
||||
#
|
||||
# [*logging_debug_format_suffix*]
|
||||
# (optional) Formatted data to append to log format when level is DEBUG.
|
||||
# Defaults to undef.
|
||||
# Example: '%(funcName)s %(pathname)s:%(lineno)d'
|
||||
#
|
||||
# [*logging_exception_prefix*]
|
||||
# (optional) Prefix each line of exception output with this format.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s'
|
||||
#
|
||||
# [*log_config_append*]
|
||||
# The name of an additional logging configuration file.
|
||||
# Defaults to undef.
|
||||
# See https://docs.python.org/2/howto/logging.html
|
||||
#
|
||||
# [*default_log_levels*]
|
||||
# (optional) Hash of logger (keys) and level (values) pairs.
|
||||
# Defaults to undef.
|
||||
# Example:
|
||||
# { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
# 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
|
||||
# 'oslo.messaging' => 'INFO', 'iso8601' => 'WARN',
|
||||
# 'requests.packages.urllib3.connectionpool' => 'WARN',
|
||||
# 'urllib3.connectionpool' => 'WARN',
|
||||
# 'websocket' => 'WARN', 'aodhmiddleware' => 'WARN',
|
||||
# 'routes.middleware' => 'WARN', stevedore => 'WARN' }
|
||||
#
|
||||
# [*publish_errors*]
|
||||
# (optional) Publish error events (boolean value).
|
||||
# Defaults to undef (false if unconfigured).
|
||||
#
|
||||
# [*fatal_deprecations*]
|
||||
# (optional) Make deprecations fatal (boolean value)
|
||||
# Defaults to undef (false if unconfigured).
|
||||
#
|
||||
# [*instance_format*]
|
||||
# (optional) If an instance is passed with the log message, format it
|
||||
# like this (string value).
|
||||
# Defaults to undef.
|
||||
# Example: '[instance: %(uuid)s] '
|
||||
#
|
||||
# [*instance_uuid_format*]
|
||||
# (optional) If an instance UUID is passed with the log message, format
|
||||
# it like this (string value).
|
||||
# Defaults to undef.
|
||||
# Example: instance_uuid_format='[instance: %(uuid)s] '
|
||||
|
||||
# [*log_date_format*]
|
||||
# (optional) Format string for %%(asctime)s in log records.
|
||||
# Defaults to undef.
|
||||
# Example: 'Y-%m-%d %H:%M:%S'
|
||||
|
||||
class aodh::logging(
|
||||
$logging_context_format_string = undef,
|
||||
$logging_default_format_string = undef,
|
||||
$logging_debug_format_suffix = undef,
|
||||
$logging_exception_prefix = undef,
|
||||
$log_config_append = undef,
|
||||
$default_log_levels = undef,
|
||||
$publish_errors = undef,
|
||||
$fatal_deprecations = undef,
|
||||
$instance_format = undef,
|
||||
$instance_uuid_format = undef,
|
||||
$log_date_format = undef,
|
||||
) {
|
||||
|
||||
if $logging_context_format_string {
|
||||
aodh_config {
|
||||
'DEFAULT/logging_context_format_string' :
|
||||
value => $logging_context_format_string;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/logging_context_format_string' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_default_format_string {
|
||||
aodh_config {
|
||||
'DEFAULT/logging_default_format_string' :
|
||||
value => $logging_default_format_string;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/logging_default_format_string' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_debug_format_suffix {
|
||||
aodh_config {
|
||||
'DEFAULT/logging_debug_format_suffix' :
|
||||
value => $logging_debug_format_suffix;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/logging_debug_format_suffix' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_exception_prefix {
|
||||
aodh_config {
|
||||
'DEFAULT/logging_exception_prefix' : value => $logging_exception_prefix;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/logging_exception_prefix' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_config_append {
|
||||
aodh_config {
|
||||
'DEFAULT/log_config_append' : value => $log_config_append;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/log_config_append' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $default_log_levels {
|
||||
aodh_config {
|
||||
'DEFAULT/default_log_levels' :
|
||||
value => join(sort(join_keys_to_values($default_log_levels, '=')), ',');
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/default_log_levels' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $publish_errors {
|
||||
aodh_config {
|
||||
'DEFAULT/publish_errors' : value => $publish_errors;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/publish_errors' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $fatal_deprecations {
|
||||
aodh_config {
|
||||
'DEFAULT/fatal_deprecations' : value => $fatal_deprecations;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/fatal_deprecations' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $instance_format {
|
||||
aodh_config {
|
||||
'DEFAULT/instance_format' : value => $instance_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/instance_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $instance_uuid_format {
|
||||
aodh_config {
|
||||
'DEFAULT/instance_uuid_format' : value => $instance_uuid_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/instance_uuid_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_date_format {
|
||||
aodh_config {
|
||||
'DEFAULT/log_date_format' : value => $log_date_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aodh_config {
|
||||
'DEFAULT/log_date_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
# Parameters for puppet-aodh
|
||||
#
|
||||
class aodh::params {
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$psycopg_package_name = 'python-psycopg2'
|
||||
$sqlite_package_name = undef
|
||||
}
|
||||
'Debian': {
|
||||
$psycopg_package_name = 'python-psycopg2'
|
||||
$sqlite_package_name = 'python-pysqlite2'
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem")
|
||||
}
|
||||
|
||||
} # Case $::osfamily
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
# == Class: aodh::policy
|
||||
#
|
||||
# Configure the aodh policies
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*policies*]
|
||||
# (optional) Set of policies to configure for aodh
|
||||
# Example :
|
||||
# {
|
||||
# 'aodh-context_is_admin' => {
|
||||
# 'key' => 'context_is_admin',
|
||||
# 'value' => 'true'
|
||||
# },
|
||||
# 'aodh-default' => {
|
||||
# 'key' => 'default',
|
||||
# 'value' => 'rule:admin_or_owner'
|
||||
# }
|
||||
# }
|
||||
# Defaults to empty hash.
|
||||
#
|
||||
# [*policy_path*]
|
||||
# (optional) Path to the nova policy.json file
|
||||
# Defaults to /etc/aodh/policy.json
|
||||
#
|
||||
class aodh::policy (
|
||||
$policies = {},
|
||||
$policy_path = '/etc/aodh/policy.json',
|
||||
) {
|
||||
|
||||
validate_hash($policies)
|
||||
|
||||
Openstacklib::Policy::Base {
|
||||
file_path => $policy_path,
|
||||
}
|
||||
|
||||
create_resources('openstacklib::policy::base', $policies)
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "puppet-aodh",
|
||||
"version": "0.0.1",
|
||||
"author": "OpenStack Contributors",
|
||||
"summary": "Puppet module for OpenStack Aodh",
|
||||
"license": "Apache-2.0",
|
||||
"source": "git://github.com/openstack/puppet-aodh.git",
|
||||
"project_page": "https://launchpad.net/puppet-aodh",
|
||||
"issues_url": "https://bugs.launchpad.net/puppet-aodh",
|
||||
"description": "Installs and configures OpenStack Aodh.",
|
||||
"operatingsystem_support": [
|
||||
{
|
||||
"operatingsystem": "Debian",
|
||||
"operatingsystemrelease": ["8"]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "Fedora",
|
||||
"operatingsystemrelease": ["21","22"]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "RedHat",
|
||||
"operatingsystemrelease": ["7"]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "Ubuntu",
|
||||
"operatingsystemrelease": ["14.04"]
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{ "name": "puppetlabs/inifile", "version_requirement": ">=1.0.0 <2.0.0" },
|
||||
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.2.0 <5.0.0" },
|
||||
{ "name": "stackforge/openstacklib", "version_requirement": ">=5.0.0 <6.0.0" }
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
HOSTS:
|
||||
centos-server-70-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: el-7-x86_64
|
||||
box: puppetlabs/centos-7.0-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/centos-7.0-64-nocm
|
||||
hypervisor: vagrant
|
||||
CONFIG:
|
||||
log_level: debug
|
||||
type: foss
|
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
ubuntu-server-14.04-amd64:
|
||||
roles:
|
||||
- master
|
||||
platform: ubuntu-14.04-amd64
|
||||
box: puppetlabs/ubuntu-14.04-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
|
||||
hypervisor: vagrant
|
||||
CONFIG:
|
||||
type: foss
|
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
centos-70-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: el-7-x86_64
|
||||
hypervisor: none
|
||||
ip: 127.0.0.1
|
||||
CONFIG:
|
||||
type: foss
|
||||
set_env: false
|
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
ubuntu-14.04-amd64:
|
||||
roles:
|
||||
- master
|
||||
platform: ubuntu-14.04-amd64
|
||||
hypervisor: none
|
||||
ip: 127.0.0.1
|
||||
CONFIG:
|
||||
type: foss
|
||||
set_env: false
|
|
@ -0,0 +1,11 @@
|
|||
HOSTS:
|
||||
ubuntu-server-14.04-amd64:
|
||||
roles:
|
||||
- master
|
||||
platform: ubuntu-14.04-amd64
|
||||
box: puppetlabs/ubuntu-14.04-64-nocm
|
||||
box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
|
||||
hypervisor: vagrant
|
||||
CONFIG:
|
||||
log_level: debug
|
||||
type: foss
|
|
@ -0,0 +1,62 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'aodh::db::mysql' do
|
||||
|
||||
let :pre_condition do
|
||||
[
|
||||
'include mysql::server',
|
||||
'include aodh::db::sync'
|
||||
]
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
'password' => 'fooboozoo_default_password',
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with only required params' do
|
||||
it { is_expected.to contain_openstacklib__db__mysql('aodh').with(
|
||||
'user' => 'aodh',
|
||||
'password_hash' => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
'dbname' => 'aodh',
|
||||
'host' => '127.0.0.1',
|
||||
'charset' => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
)}
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param to array" do
|
||||
let :params do
|
||||
{
|
||||
:password => 'aodhpass',
|
||||
:allowed_hosts => ['127.0.0.1','%']
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
describe "overriding allowed_hosts param to string" do
|
||||
let :params do
|
||||
{
|
||||
:password => 'aodhpass2',
|
||||
:allowed_hosts => '192.168.1.1'
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param equals to host param " do
|
||||
let :params do
|
||||
{
|
||||
:password => 'aodhpass2',
|
||||
:allowed_hosts => '127.0.0.1'
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,58 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'aodh::db::postgresql' do
|
||||
|
||||
let :req_params do
|
||||
{ :password => 'pw' }
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
'include postgresql::server'
|
||||
end
|
||||
|
||||
context 'on a RedHat osfamily' do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7.0',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}
|
||||
end
|
||||
|
||||
context 'with only required parameters' do
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_postgresql__server__db('aodh').with(
|
||||
:user => 'aodh',
|
||||
:password => 'md534e5dd092d680f3d8c11c62951fb5c19'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on a Debian osfamily' do
|
||||
let :facts do
|
||||
{
|
||||
:operatingsystemrelease => '7.8',
|
||||
:operatingsystem => 'Debian',
|
||||
:osfamily => 'Debian',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}
|
||||
end
|
||||
|
||||
context 'with only required parameters' do
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_postgresql__server__db('aodh').with(
|
||||
:user => 'aodh',
|
||||
:password => 'md534e5dd092d680f3d8c11c62951fb5c19'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,127 @@
|
|||
#
|
||||
# Unit tests for aodh::keystone::auth
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'aodh::keystone::auth' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
describe 'with default class parameters' do
|
||||
let :params do
|
||||
{ :password => 'aodh_password',
|
||||
:tenant => 'foobar' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('aodh').with(
|
||||
:ensure => 'present',
|
||||
:password => 'aodh_password',
|
||||
:tenant => 'foobar'
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_keystone_user_role('aodh@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin']
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_keystone_service('aodh').with(
|
||||
:ensure => 'present',
|
||||
:type => 'alarming',
|
||||
:description => 'AODH Alarming Service'
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "http://127.0.0.1:8042/",
|
||||
:admin_url => "http://127.0.0.1:8042/",
|
||||
:internal_url => "http://127.0.0.1:8042/"
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding public_protocol, public_port and public address' do
|
||||
let :params do
|
||||
{ :password => 'aodh_password',
|
||||
:public_protocol => 'https',
|
||||
:public_port => '80',
|
||||
:public_address => '10.10.10.10',
|
||||
:port => '81',
|
||||
:internal_address => '10.10.10.11',
|
||||
:admin_address => '10.10.10.12' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "https://10.10.10.10:80/",
|
||||
:internal_url => "http://10.10.10.11:81/",
|
||||
:admin_url => "http://10.10.10.12:81/"
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding auth name' do
|
||||
let :params do
|
||||
{ :password => 'foo',
|
||||
:auth_name => 'aodhy' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('aodhy') }
|
||||
it { is_expected.to contain_keystone_user_role('aodhy@services') }
|
||||
it { is_expected.to contain_keystone_service('aodhy') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/aodhy') }
|
||||
end
|
||||
|
||||
describe 'when overriding service name' do
|
||||
let :params do
|
||||
{ :service_name => 'aodh_service',
|
||||
:auth_name => 'aodh',
|
||||
:password => 'aodh_password' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('aodh') }
|
||||
it { is_expected.to contain_keystone_user_role('aodh@services') }
|
||||
it { is_expected.to contain_keystone_service('aodh_service') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh_service') }
|
||||
end
|
||||
|
||||
describe 'when disabling user configuration' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'aodh_password',
|
||||
:configure_user => false
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('aodh') }
|
||||
it { is_expected.to contain_keystone_user_role('aodh@services') }
|
||||
it { is_expected.to contain_keystone_service('aodh').with(
|
||||
:ensure => 'present',
|
||||
:type => 'alarming',
|
||||
:description => 'AODH Alarming Service'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
describe 'when disabling user and user role configuration' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'aodh_password',
|
||||
:configure_user => false,
|
||||
:configure_user_role => false
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('aodh') }
|
||||
it { is_expected.not_to contain_keystone_user_role('aodh@services') }
|
||||
it { is_expected.to contain_keystone_service('aodh').with(
|
||||
:ensure => 'present',
|
||||
:type => 'alarming',
|
||||
:description => 'AODH Alarming Service'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,107 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'aodh::logging' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
}
|
||||
end
|
||||
|
||||
let :log_params do
|
||||
{
|
||||
:logging_context_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
|
||||
:logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
|
||||
:logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d',
|
||||
:logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
|
||||
:log_config_append => '/etc/aodh/logging.conf',
|
||||
:publish_errors => true,
|
||||
:default_log_levels => {
|
||||
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
|
||||
'iso8601' => 'WARN',
|
||||
'requests.packages.urllib3.connectionpool' => 'WARN' },
|
||||
:fatal_deprecations => true,
|
||||
:instance_format => '[instance: %(uuid)s] ',
|
||||
:instance_uuid_format => '[instance: %(uuid)s] ',
|
||||
:log_date_format => '%Y-%m-%d %H:%M:%S',
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'aodh-logging' do
|
||||
|
||||
context 'with extended logging options' do
|
||||
before { params.merge!( log_params ) }
|
||||
it_configures 'logging params set'
|
||||
end
|
||||
|
||||
context 'without extended logging options' do
|
||||
it_configures 'logging params unset'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for 'logging params set' do
|
||||
it 'enables logging params' do
|
||||
is_expected.to contain_aodh_config('DEFAULT/logging_context_format_string').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s')
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/logging_default_format_string').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s')
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/logging_debug_format_suffix').with_value(
|
||||
'%(funcName)s %(pathname)s:%(lineno)d')
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/logging_exception_prefix').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/log_config_append').with_value(
|
||||
'/etc/aodh/logging.conf')
|
||||
is_expected.to contain_aodh_config('DEFAULT/publish_errors').with_value(
|
||||
true)
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/default_log_levels').with_value(
|
||||
'amqp=WARN,amqplib=WARN,boto=WARN,iso8601=WARN,qpid=WARN,requests.packages.urllib3.connectionpool=WARN,sqlalchemy=WARN,suds=INFO')
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/fatal_deprecations').with_value(
|
||||
true)
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/instance_format').with_value(
|
||||
'[instance: %(uuid)s] ')
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/instance_uuid_format').with_value(
|
||||
'[instance: %(uuid)s] ')
|
||||
|
||||
is_expected.to contain_aodh_config('DEFAULT/log_date_format').with_value(
|
||||
'%Y-%m-%d %H:%M:%S')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shared_examples_for 'logging params unset' do
|
||||
[ :logging_context_format_string, :logging_default_format_string,
|
||||
:logging_debug_format_suffix, :logging_exception_prefix,
|
||||
:log_config_append, :publish_errors,
|
||||
:default_log_levels, :fatal_deprecations,
|
||||
:instance_format, :instance_uuid_format,
|
||||
:log_date_format, ].each { |param|
|
||||
it { is_expected.to contain_aodh_config("DEFAULT/#{param}").with_ensure('absent') }
|
||||
}
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'aodh-logging'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'aodh-logging'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,41 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'aodh::policy' do
|
||||
|
||||
shared_examples_for 'aodh policies' do
|
||||
let :params do
|
||||
{
|
||||
:policy_path => '/etc/aodh/policy.json',
|
||||
:policies => {
|
||||
'context_is_admin' => {
|
||||
'key' => 'context_is_admin',
|
||||
'value' => 'foo:bar'
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it 'set up the policies' do
|
||||
is_expected.to contain_openstacklib__policy__base('context_is_admin').with({
|
||||
:key => 'context_is_admin',
|
||||
:value => 'foo:bar'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'aodh policies'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'aodh policies'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
shared_examples_for "a Puppet::Error" do |description|
|
||||
it "with message matching #{description.inspect}" do
|
||||
expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
require 'shared_examples'
|
||||
require 'webmock/rspec'
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
end
|
||||
|
||||
at_exit { RSpec::Puppet::Coverage.report! }
|
|
@ -0,0 +1,56 @@
|
|||
require 'beaker-rspec'
|
||||
require 'beaker/puppet_install_helper'
|
||||
|
||||
run_puppet_install_helper
|
||||
|
||||
RSpec.configure do |c|
|
||||
# Project root
|
||||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||
modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
|
||||
|
||||
# Readable test descriptions
|
||||
c.formatter = :documentation
|
||||
|
||||
# Configure all nodes in nodeset
|
||||
c.before :suite do
|
||||
# Install module and dependencies
|
||||
hosts.each do |host|
|
||||
|
||||
# install git
|
||||
install_package host, 'git'
|
||||
|
||||
zuul_ref = ENV['ZUUL_REF']
|
||||
zuul_branch = ENV['ZUUL_BRANCH']
|
||||
zuul_url = ENV['ZUUL_URL']
|
||||
|
||||
repo = 'openstack/puppet-openstack-integration'
|
||||
|
||||
# Start out with clean moduledir, don't trust r10k to purge it
|
||||
on host, "rm -rf /etc/puppet/modules/*"
|
||||
# Install dependent modules via git or zuul
|
||||
r = on host, "test -e /usr/zuul-env/bin/zuul-cloner", { :acceptable_exit_codes => [0,1] }
|
||||
if r.exit_code == 0
|
||||
zuul_clone_cmd = '/usr/zuul-env/bin/zuul-cloner '
|
||||
zuul_clone_cmd += '--cache-dir /opt/git '
|
||||
zuul_clone_cmd += "--zuul-ref #{zuul_ref} "
|
||||
zuul_clone_cmd += "--zuul-branch #{zuul_branch} "
|
||||
zuul_clone_cmd += "--zuul-url #{zuul_url} "
|
||||
zuul_clone_cmd += "git://git.openstack.org #{repo}"
|
||||
on host, zuul_clone_cmd
|
||||
else
|
||||
on host, "git clone https://git.openstack.org/#{repo} #{repo}"
|
||||
end
|
||||
|
||||
on host, "ZUUL_REF=#{zuul_ref} ZUUL_BRANCH=#{zuul_branch} ZUUL_URL=#{zuul_url} bash #{repo}/install_modules.sh"
|
||||
|
||||
# Install the module being tested
|
||||
on host, "rm -fr /etc/puppet/modules/#{modname}"
|
||||
puppet_module_install(:source => proj_root, :module_name => modname)
|
||||
|
||||
on host, "rm -fr #{repo}"
|
||||
|
||||
# List modules installed to help with debugging
|
||||
on host, puppet('module','list'), { :acceptable_exit_codes => 0 }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,68 @@
|
|||
#
|
||||
# these tests are a little concerning b/c they are hacking around the
|
||||
# modulepath, so these tests will not catch issues that may eventually arise
|
||||
# related to loading these plugins.
|
||||
# I could not, for the life of me, figure out how to programatcally set the modulepath
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'openstacklib',
|
||||
'lib')
|
||||
)
|
||||
require 'spec_helper'
|
||||
provider_class = Puppet::Type.type(:aodh_config).provider(:ini_setting)
|
||||
describe provider_class do
|
||||
|
||||
it 'should default to the default setting when no other one is specified' do
|
||||
resource = Puppet::Type::Aodh_config.new(
|
||||
{:name => 'DEFAULT/foo', :value => 'bar'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
expect(provider.section).to eq('DEFAULT')
|
||||
expect(provider.setting).to eq('foo')
|
||||
end
|
||||
|
||||
it 'should allow setting to be set explicitly' do
|
||||
resource = Puppet::Type::Aodh_config.new(
|
||||
{:name => 'dude/foo', :value => 'bar'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
expect(provider.section).to eq('dude')
|
||||
expect(provider.setting).to eq('foo')
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||
resource = Puppet::Type::Aodh_config.new(
|
||||
{:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
|
||||
it 'should ensure absent when value matches ensure_absent_val' do
|
||||
resource = Puppet::Type::Aodh_config.new(
|
||||
{:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' }
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,63 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/aodh_config'
|
||||
describe |