puppet-glare: Initial commit

This is the initial commit for puppet-glare.
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: I614a3d93947705a7a74820017bc568c6de197bea
This commit is contained in:
Denis Egorenko 2016-09-14 17:00:51 +03:00
parent 3b63e1221b
commit 564c1f7930
38 changed files with 1916 additions and 0 deletions

11
.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
pkg/
Gemfile.lock
vendor/
spec/fixtures/
.vagrant/
.bundle/
coverage/
.idea/
*.swp
*.iml
openstack/

19
Gemfile Normal file
View File

@ -0,0 +1,19 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
group :development, :test, :system_tests do
gem 'puppet-openstack_spec_helper', :require => 'false', :git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper'
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

13
LICENSE Normal file
View File

@ -0,0 +1,13 @@
Copyright 2016 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.

78
README.md Normal file
View File

@ -0,0 +1,78 @@
glare
=======
#### Table of Contents
1. [Overview - What is the glare module?](#overview)
2. [Module Description - What does the module do?](#module-description)
3. [Setup - The basics of getting started with glare](#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 glare module is a part of [OpenStack](https://www.openstack.org), 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 FIXME service for OpenStack.
Module Description
------------------
The glare module is a thorough attempt to make Puppet capable of managing the entirety of glare. This includes manifests to provision region specific endpoint and database connections. Types are shipped as part of the glare module to assist in manipulation of configuration files.
Setup
-----
**What the glare module affects**
* [Glare](https://wiki.openstack.org/wiki/Glare), the FIXME service for OpenStack.
### Installing glare
glare is not currently in Puppet Forge, but is anticipated to be added soon. Once that happens, you'll be able to install glare with:
puppet module install openstack/glare
### Beginning with glare
To utilize the glare module's functionality you will need to declare multiple resources.
Implementation
--------------
### glare
glare is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers.
Limitations
------------
* All the glare types use the CLI tools and so need to be ran on the glare 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-rspec/blob/master/README.md
Development
-----------
Developer documentation for the entire puppet-openstack project.
* http://docs.openstack.org/developer/puppet-openstack-guide/
Contributors
------------
* https://github.com/openstack/puppet-glare/graphs/contributors

1
Rakefile Normal file
View File

@ -0,0 +1 @@
require 'puppet-openstack_spec_helper/rake_tasks'

View File

@ -0,0 +1,10 @@
Puppet::Type.type(:glare_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def self.file_path
'/etc/glare/glare.conf'
end
end

View File

@ -0,0 +1,53 @@
Puppet::Type.newtype(:glare_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from glare.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
'glare'
end
end

30
manifests/config.pp Normal file
View File

@ -0,0 +1,30 @@
# == Class: glare::config
#
# This class is used to manage arbitrary glare configurations.
#
# === Parameters
#
# [*glare_config*]
# (optional) Allow configuration of arbitrary glare configurations.
# The value is an hash of glare_config resources. Example:
# { 'DEFAULT/foo' => { value => 'fooValue'},
# 'DEFAULT/bar' => { value => 'barValue'}
# }
# In yaml format, Example:
# glare_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 glare::config (
$glare_config = {},
) {
validate_hash($glare_config)
create_resources('glare_config', $glare_config)
}

58
manifests/db.pp Normal file
View File

@ -0,0 +1,58 @@
# == Class: glare::db
#
# Configure the glare database
#
# === Parameters
#
# [*database_connection*]
# (Optional) Url used to connect to database.
# Defaults to 'sqlite:////var/lib/glare/glare.sqlite'.
#
# [*database_idle_timeout*]
# (Optional) Timeout when db connections should be reaped.
# Defaults to $::os_service_default
#
# [*database_max_retries*]
# (Optional) Maximum number of database connection retries during startup.
# Setting -1 implies an infinite retry count.
# Defaults to $::os_service_default
#
# [*database_retry_interval*]
# (Optional) Interval between retries of opening a database connection.
# Defaults to $::os_service_default
#
# [*database_min_pool_size*]
# (Optional) Minimum number of SQL connections to keep open in a pool.
# Defaults to $::os_service_default
#
# [*database_max_pool_size*]
# (Optional)Maximum number of SQL connections to keep open in a pool.
# Defaults to $::os_service_default
#
# [*database_max_overflow*]
# (Optional) If set, use this value for max_overflow with sqlalchemy.
# Defaults to $::os_service_default
#
class glare::db (
$database_connection = 'sqlite:////var/lib/glare/glare.sqlite',
$database_idle_timeout = $::os_service_default,
$database_min_pool_size = $::os_service_default,
$database_max_pool_size = $::os_service_default,
$database_max_retries = $::os_service_default,
$database_retry_interval = $::os_service_default,
$database_max_overflow = $::os_service_default,
) {
validate_re($database_connection,
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
oslo::db { 'glare_config':
connection => $database_connection,
idle_timeout => $database_idle_timeout,
min_pool_size => $database_min_pool_size,
max_retries => $database_max_retries,
retry_interval => $database_retry_interval,
max_pool_size => $database_max_pool_size,
max_overflow => $database_max_overflow,
}
}

69
manifests/db/mysql.pp Normal file
View File

@ -0,0 +1,69 @@
# The glare::db::mysql class implements mysql backend for glare
#
# This class can be used to create tables, users and grant
# privilege for a mysql glare database.
#
# == parameters
#
# [*password*]
# (Mandatory) Password to connect to the database.
# Defaults to 'false'.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'glare'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'glare'.
#
# [*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 glare::db::mysql(
$password,
$dbname = 'glare',
$user = 'glare',
$host = '127.0.0.1',
$charset = 'utf8',
$collate = 'utf8_general_ci',
$allowed_hosts = undef
) {
validate_string($password)
::openstacklib::db::mysql { 'glare':
user => $user,
password_hash => mysql_password($password),
dbname => $dbname,
host => $host,
charset => $charset,
collate => $collate,
allowed_hosts => $allowed_hosts,
}
::Openstacklib::Db::Mysql['glare'] ~> Exec<| title == 'glare-manage db_sync' |>
}

View File

@ -0,0 +1,55 @@
# == Class: glare::db::postgresql
#
# Class that configures postgresql for glare
# Requires the Puppetlabs postgresql module.
#
# === Parameters
#
# [*password*]
# (Required) Password to connect to the database.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'glare'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'glare'.
#
# [*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 glare::db::postgresql(
$password,
$dbname = 'glare',
$user = 'glare',
$encoding = undef,
$privileges = 'ALL',
) {
Class['glare::db::postgresql'] -> Service<| title == 'glare' |>
::openstacklib::db::postgresql { 'glare':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}
::Openstacklib::Db::Postgresql['glare'] ~> Exec<| title == 'glare-manage db_sync' |>
}

23
manifests/db/sync.pp Normal file
View File

@ -0,0 +1,23 @@
#
# Class to execute glare-manage db_sync
#
# == Parameters
#
# [*extra_params*]
# (optional) String of extra command line parameters to append
# to the glare-dbsync command.
# Defaults to undef
#
class glare::db::sync(
$extra_params = undef,
) {
exec { 'glare-db-sync':
command => "glare-manage db_sync ${extra_params}",
path => '/usr/bin',
user => 'glare',
refreshonly => true,
subscribe => [Package['glare'], Glare_config['database/connection']],
}
Exec['glare-manage db_sync'] ~> Service<| title == 'glare' |>
}

14
manifests/init.pp Normal file
View File

@ -0,0 +1,14 @@
# == Class: glare
#
# Full description of class glare here.
#
# === Parameters
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
#
class glare {
include ::glare::params
}

View File

@ -0,0 +1,94 @@
# == Class: glare::keystone::auth
#
# Configures glare user, service and endpoint in Keystone.
#
# === Parameters
#
# [*password*]
# (required) Password for glare user.
#
# [*auth_name*]
# Username for glare service. Defaults to 'glare'.
#
# [*email*]
# Email for glare user. Defaults to 'glare@localhost'.
#
# [*tenant*]
# Tenant for glare user. Defaults to 'services'.
#
# [*configure_endpoint*]
# Should glare 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 'key-manager'.
#
# [*region*]
# Region for endpoint. Defaults to 'RegionOne'.
#
# [*service_name*]
# (optional) Name of the service.
# Defaults to the value of 'glare'.
#
# [*service_description*]
# (optional) Description of the service.
# Default to 'glare FIXME Service'
#
# [*public_url*]
# (optional) The endpoint's public url. (Defaults to 'http://127.0.0.1:FIXME')
# This url should *not* contain any trailing '/'.
#
# [*admin_url*]
# (optional) The endpoint's admin url. (Defaults to 'http://127.0.0.1:FIXME')
# This url should *not* contain any trailing '/'.
#
# [*internal_url*]
# (optional) The endpoint's internal url. (Defaults to 'http://127.0.0.1:FIXME')
#
class glare::keystone::auth (
$password,
$auth_name = 'glare',
$email = 'glare@localhost',
$tenant = 'services',
$configure_endpoint = true,
$configure_user = true,
$configure_user_role = true,
$service_name = 'glare',
$service_description = 'glare FIXME Service',
$service_type = 'FIXME',
$region = 'RegionOne',
$public_url = 'http://127.0.0.1:FIXME',
$admin_url = 'http://127.0.0.1:FIXME',
$internal_url = 'http://127.0.0.1:FIXME',
) {
if $configure_user_role {
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'glare-server' |>
}
Keystone_endpoint["${region}/${service_name}::${service_type}"] ~> Service <| name == 'glare-server' |>
keystone::resource::service_identity { 'glare':
configure_user => $configure_user,
configure_user_role => $configure_user_role,
configure_endpoint => $configure_endpoint,
service_name => $service_name,
service_type => $service_type,
service_description => $service_description,
region => $region,
auth_name => $auth_name,
password => $password,
email => $email,
tenant => $tenant,
public_url => $public_url,
internal_url => $internal_url,
admin_url => $admin_url,
}
}

View File

@ -0,0 +1,263 @@
# class: glare::keystone::auth
#
# Configure the keystone_authtoken section in the configuration file
#
# === Parameters
#
# [*username*]
# (Optional) The name of the service user
# Defaults to 'glare'
#
# [*password*]
# (Required) Password to create for the service user
#
# [*auth_url*]
# (Optional) The URL to use for authentication.
# Defaults to 'http://localhost:35357'.
#
# [*project_name*]
# (Optional) Service project name
# Defaults to 'services'
#
# [*user_domain_name*]
# (Optional) Name of domain for $username
# Defaults to $::os_service_default
#
# [*project_domain_name*]
# (Optional) Name of domain for $project_name
# Defaults to $::os_service_default
#
# [*insecure*]
# (Optional) If true, explicitly allow TLS without checking server cert
# against any certificate authorities. WARNING: not recommended. Use with
# caution.
# Defaults to $:os_service_default
#
# [*auth_section*]
# (Optional) Config Section from which to load plugin specific options
# Defaults to $::os_service_default.
#
# [*auth_type*]
# (Optional) Authentication type to load
# Defaults to 'password'.
#
# [*auth_uri*]
# (Optional) Complete public Identity API endpoint.
# Defaults to 'http://localhost:5000'.
#
# [*auth_version*]
# (Optional) API version of the admin Identity API endpoint.
# Defaults to $::os_service_default.
#
# [*cache*]
# (Optional) Env key for the swift cache.
# Defaults to $::os_service_default.
#
# [*cafile*]
# (Optional) A PEM encoded Certificate Authority to use when verifying HTTPs
# connections.
# Defaults to $::os_service_default.
#
# [*certfile*]
# (Optional) Required if identity server requires client certificate
# Defaults to $::os_service_default.
#
# [*check_revocations_for_cached*]
# (Optional) If true, the revocation list will be checked for cached tokens.
# This requires that PKI tokens are configured on the identity server.
# boolean value.
# Defaults to $::os_service_default.
#
# [*delay_auth_decision*]
# (Optional) Do not handle authorization requests within the middleware, but
# delegate the authorization decision to downstream WSGI components. Boolean
# value
# Defaults to $::os_service_default.
#
# [*enforce_token_bind*]
# (Optional) Used to control the use and type of token binding. Can be set
# to: "disabled" to not check token binding. "permissive" (default) to
# validate binding information if the bind type is of a form known to the
# server and ignore it if not. "strict" like "permissive" but if the bind
# type is unknown the token will be rejected. "required" any form of token
# binding is needed to be allowed. Finally the name of a binding method that
# must be present in tokens. String value.
# Defaults to $::os_service_default.
#
# [*hash_algorithms*]
# (Optional) Hash algorithms to use for hashing PKI tokens. This may be a
# single algorithm or multiple. The algorithms are those supported by Python
# standard hashlib.new(). The hashes will be tried in the order given, so put
# the preferred one first for performance. The result of the first hash will
# be stored in the cache. This will typically be set to multiple values only
# while migrating from a less secure algorithm to a more secure one. Once all
# the old tokens are expired this option should be set to a single value for
# better performance. List value.
# Defaults to $::os_service_default.
#
# [*http_connect_timeout*]
# (Optional) Request timeout value for communicating with Identity API
# server.
# Defaults to $::os_service_default.
#
# [*http_request_max_retries*]
# (Optional) How many times are we trying to reconnect when communicating
# with Identity API Server. Integer value
# Defaults to $::os_service_default.
#
# [*include_service_catalog*]
# (Optional) Indicate whether to set the X-Service-Catalog header. If False,
# middleware will not ask for service catalog on token validation and will
# not set the X-Service-Catalog header. Boolean value.
# Defaults to $::os_service_default.
#
# [*keyfile*]
# (Optional) Required if identity server requires client certificate
# Defaults to $::os_service_default.
#
# [*memcache_pool_conn_get_timeout*]
# (Optional) Number of seconds that an operation will wait to get a memcached
# client connection from the pool. Integer value
# Defaults to $::os_service_default.
#
# [*memcache_pool_dead_retry*]
# (Optional) Number of seconds memcached server is considered dead before it
# is tried again. Integer value
# Defaults to $::os_service_default.
#
# [*memcache_pool_maxsize*]
# (Optional) Maximum total number of open connections to every memcached
# server. Integer value
# Defaults to $::os_service_default.
#
# [*memcache_pool_socket_timeout*]
# (Optional) Number of seconds a connection to memcached is held unused in
# the pool before it is closed. Integer value
# Defaults to $::os_service_default.
#
# [*memcache_pool_unused_timeout*]
# (Optional) Number of seconds a connection to memcached is held unused in
# the pool before it is closed. Integer value
# Defaults to $::os_service_default.
#
# [*memcache_secret_key*]
# (Optional, mandatory if memcache_security_strategy is defined) This string
# is used for key derivation.
# Defaults to $::os_service_default.
#
# [*memcache_security_strategy*]
# (Optional) If defined, indicate whether token data should be authenticated
# or authenticated and encrypted. If MAC, token data is authenticated (with
# HMAC) in the cache. If ENCRYPT, token data is encrypted and authenticated in the
# cache. If the value is not one of these options or empty, auth_token will
# raise an exception on initialization.
# Defaults to $::os_service_default.
#
# [*memcache_use_advanced_pool*]
# (Optional) Use the advanced (eventlet safe) memcached client pool. The
# advanced pool will only work under python 2.x Boolean value
# Defaults to $::os_service_default.
#
# [*memcached_servers*]
# (Optional) Optionally specify a list of memcached server(s) to use for
# caching. If left undefined, tokens will instead be cached in-process.
# Defaults to $::os_service_default.
#
# [*region_name*]
# (Optional) The region in which the identity server can be found.
# Defaults to $::os_service_default.
#
# [*revocation_cache_time*]
# (Optional) Determines the frequency at which the list of revoked tokens is
# retrieved from the Identity service (in seconds). A high number of
# revocation events combined with a low cache duration may significantly
# reduce performance. Only valid for PKI tokens. Integer value
# Defaults to $::os_service_default.
#
# [*signing_dir*]
# (Optional) Directory used to cache files related to PKI tokens.
# Defaults to $::os_service_default.
#
# [*token_cache_time*]
# (Optional) In order to prevent excessive effort spent validating tokens,
# the middleware caches previously-seen tokens for a configurable duration
# (in seconds). Set to -1 to disable caching completely. Integer value
# Defaults to $::os_service_default.
#
class glare::keystone::authtoken(
$password,
$username = 'glare',
$auth_url = 'http://localhost:35357',
$project_name = 'services',
$user_domain_name = $::os_service_default,
$project_domain_name = $::os_service_default,
$insecure = $::os_service_default,
$auth_section = $::os_service_default,
$auth_type = 'password',
$auth_uri = 'http://localhost:5000',
$auth_version = $::os_service_default,
$cache = $::os_service_default,
$cafile = $::os_service_default,
$certfile = $::os_service_default,
$check_revocations_for_cached = $::os_service_default,
$delay_auth_decision = $::os_service_default,
$enforce_token_bind = $::os_service_default,
$hash_algorithms = $::os_service_default,
$http_connect_timeout = $::os_service_default,
$http_request_max_retries = $::os_service_default,
$include_service_catalog = $::os_service_default,
$keyfile = $::os_service_default,
$memcache_pool_conn_get_timeout = $::os_service_default,
$memcache_pool_dead_retry = $::os_service_default,
$memcache_pool_maxsize = $::os_service_default,
$memcache_pool_socket_timeout = $::os_service_default,
$memcache_pool_unused_timeout = $::os_service_default,
$memcache_secret_key = $::os_service_default,
$memcache_security_strategy = $::os_service_default,
$memcache_use_advanced_pool = $::os_service_default,
$memcached_servers = $::os_service_default,
$region_name = $::os_service_default,
$revocation_cache_time = $::os_service_default,
$signing_dir = $::os_service_default,
$token_cache_time = $::os_service_default,
) {
keystone::resource::authtoken { 'glare_config':
username => $username,
password => $password,
project_name => $project_name,
auth_url => $auth_url,
auth_uri => $auth_uri,
auth_version => $auth_version,
auth_type => $auth_type,
auth_section => $auth_section,
user_domain_name => $user_domain_name,
project_domain_name => $project_domain_name,
insecure => $insecure,
cache => $cache,
cafile => $cafile,
certfile => $certfile,
check_revocations_for_cached => $check_revocations_for_cached,
delay_auth_decision => $delay_auth_decision,
enforce_token_bind => $enforce_token_bind,
hash_algorithms => $hash_algorithms,
http_connect_timeout => $http_connect_timeout,
http_request_max_retries => $http_request_max_retries,
include_service_catalog => $include_service_catalog,
keyfile => $keyfile,
memcache_pool_conn_get_timeout => $memcache_pool_conn_get_timeout,
memcache_pool_dead_retry => $memcache_pool_dead_retry,
memcache_pool_maxsize => $memcache_pool_maxsize,
memcache_pool_socket_timeout => $memcache_pool_socket_timeout,
memcache_secret_key => $memcache_secret_key,
memcache_security_strategy => $memcache_security_strategy,
memcache_use_advanced_pool => $memcache_use_advanced_pool,
memcache_pool_unused_timeout => $memcache_pool_unused_timeout,
memcached_servers => $memcached_servers,
region_name => $region_name,
revocation_cache_time => $revocation_cache_time,
signing_dir => $signing_dir,
token_cache_time => $token_cache_time,
}
}

135
manifests/logging.pp Normal file
View File

@ -0,0 +1,135 @@
# Class glare::logging
#
# glare logging configuration
#
# == parameters
#
# [*debug*]
# (Optional) Should the daemons log debug messages
# Defaults to $::os_service_default
#
# [*use_syslog*]
# (Optional) Use syslog for logging.
# Defaults to $::os_service_default
#
# [*use_stderr*]
# (optional) Use stderr for logging
# Defaults to $::os_service_default
#
# [*syslog_log_facility*]
# (Optional) Syslog facility to receive log lines.
# Defaults to $::os_service_default
#
# [*log_dir*]
# (optional) Directory where logs should be stored.
# If set to boolean false, it will not log to any directory.
# Defaults to '/var/log/glare'.
#
# [*log_file*]
# (optional) File where logs should be stored.
# Defaults to '/var/log/glare/glare.log'
#
# [*logging_context_format_string*]
# (optional) Format string to use for log messages with context.
# Defaults to $::os_service_default
# 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 $::os_service_default
# 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 $::os_service_default
# Example: '%(funcName)s %(pathname)s:%(lineno)d'
#
# [*logging_exception_prefix*]
# (optional) Prefix each line of exception output with this format.
# Defaults to $::os_service_default
# Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s'
#
# [*log_config_append*]
# (optional) The name of an additional logging configuration file.
# Defaults to $::os_service_default
# See https://docs.python.org/2/howto/logging.html
#
# [*default_log_levels*]
# (optional) Hash of logger (keys) and level (values) pairs.
# Defaults to $::os_service_default
# 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', 'glaremiddleware' => 'WARN',
# 'routes.middleware' => 'WARN', stevedore => 'WARN' }
#
# [*publish_errors*]
# (optional) Publish error events (boolean value).
# Defaults to $::os_service_default
#
# [*fatal_deprecations*]
# (optional) Make deprecations fatal (boolean value)
# Defaults to $::os_service_default
#
# [*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 $::os_service_default
# Example: instance_uuid_format='[instance: %(uuid)s] '
#
# [*log_date_format*]
# (optional) Format string for %%(asctime)s in log records.
# Defaults to $::os_service_default
# Example: 'Y-%m-%d %H:%M:%S'
class glare::logging(
$use_syslog = $::os_service_default,
$use_stderr = $::os_service_default,
$syslog_log_facility = $::os_service_default,
$log_dir = '/var/log/glare',
$log_file = '/var/log/glare/glare.log',
$debug = $::os_service_default,
$logging_context_format_string = $::os_service_default,
$logging_default_format_string = $::os_service_default,
$logging_debug_format_suffix = $::os_service_default,
$logging_exception_prefix = $::os_service_default,
$log_config_append = $::os_service_default,
$default_log_levels = $::os_service_default,
$publish_errors = $::os_service_default,
$fatal_deprecations = $::os_service_default,
$instance_format = $::os_service_default,
$instance_uuid_format = $::os_service_default,
$log_date_format = $::os_service_default,
) {
oslo::log { 'glare_config':
use_stderr => $use_stderr,
use_syslog => $use_syslog,
log_dir => $log_dir,
log_file => $log_file,
debug => $debug,
logging_context_format_string => $logging_context_format_string,
logging_default_format_string => $logging_default_format_string,
logging_debug_format_suffix => $logging_debug_format_suffix,
logging_exception_prefix => $logging_exception_prefix,
log_config_append => $log_config_append,
default_log_levels => $default_log_levels,
publish_errors => $publish_errors,
fatal_deprecations => $fatal_deprecations,
instance_format => $instance_format,
instance_uuid_format => $instance_uuid_format,
log_date_format => $log_date_format,
syslog_log_facility => $syslog_log_facility,
}
}

16
manifests/params.pp Normal file
View File

@ -0,0 +1,16 @@
# Parameters for puppet-glare
#
class glare::params {
include ::openstacklib::defaults
case $::osfamily {
'RedHat': {
}
'Debian': {
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem")
}
} # Case $::osfamily
}

41
manifests/policy.pp Normal file
View File

@ -0,0 +1,41 @@
# == Class: glare::policy
#
# Configure the glare policies
#
# === Parameters
#
# [*policies*]
# (optional) Set of policies to configure for glare
# Example :
# {
# 'glare-context_is_admin' => {
# 'key' => 'context_is_admin',
# 'value' => 'true'
# },
# 'glare-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/glare/policy.json
#
class glare::policy (
$policies = {},
$policy_path = '/etc/glare/policy.json',
) {
validate_hash($policies)
Openstacklib::Policy::Base {
file_path => $policy_path,
}
create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'glare_config': policy_file => $policy_path }
}

36
metadata.json Normal file
View File

@ -0,0 +1,36 @@
{
"name": "openstack-glare",
"version": "0.0.1",
"author": "OpenStack Contributors",
"summary": "Puppet module for OpenStack Glare",
"license": "Apache-2.0",
"source": "git://github.com/openstack/puppet-glare.git",
"project_page": "https://launchpad.net/puppet-glare",
"issues_url": "https://bugs.launchpad.net/puppet-glare",
"description": "Installs and configures OpenStack Glare.",
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": ["8"]
},
{
"operatingsystem": "Fedora",
"operatingsystemrelease": ["21","22"]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": ["7"]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": ["14.04","16.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": "openstack/openstacklib", "version_requirement": ">=9.2.0 <10.0.0" },
{ "name": "openstack/keystone", "version_requirement": ">=9.2.0 <10.0.0" },
{ "name": "openstack/oslo", "version_requirement": ">=9.2.0 <10.0.0" }
]
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,10 @@
HOSTS:
ubuntu-16.04-amd64:
roles:
- master
platform: ubuntu-16.04-amd64
hypervisor: none
ip: 127.0.0.1
CONFIG:
type: foss
set_env: false

View File

@ -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

View File

@ -0,0 +1,73 @@
require 'spec_helper'
describe 'glare::db::mysql' do
let :pre_condition do
'include mysql::server'
end
let :required_params do
{ :password => 'fooboozoo_default_password', }
end
shared_examples_for 'glare-db-mysql' do
context 'with only required params' do
let :params do
required_params
end
it { is_expected.to contain_openstacklib__db__mysql('glare').with(
:user => 'glare',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'glare',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
context 'overriding allowed_hosts param to array' do
let :params do
{ :allowed_hosts => ['127.0.0.1','%'] }.merge(required_params)
end
it { is_expected.to contain_openstacklib__db__mysql('glare').with(
:user => 'glare',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'glare',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => ['127.0.0.1','%']
)}
end
describe 'overriding allowed_hosts param to string' do
let :params do
{ :allowed_hosts => '192.168.1.1' }.merge(required_params)
end
it { is_expected.to contain_openstacklib__db__mysql('glare').with(
:user => 'glare',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'glare',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '192.168.1.1'
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'glare-db-mysql'
end
end
end

View File

@ -0,0 +1,37 @@
require 'spec_helper'
describe 'glare::db::postgresql' do
let :pre_condition do
'include postgresql::server'
end
let :required_params do
{ :password => 'pw' }
end
shared_examples_for 'glare-db-postgresql' do
context 'with only required parameters' do
let :params do
required_params
end
it { is_expected.to contain_postgresql__server__db('glare').with(
:user => 'glare',
:password => 'md5000e10ee12052d5996f40620414c021a'
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({ :concat_basedir => '/var/lib/puppet/concat' }))
end
it_behaves_like 'glare-db-postgresql'
end
end
end

View File

@ -0,0 +1,114 @@
require 'spec_helper'
describe 'glare::db' do
shared_examples 'glare::db' do
context 'with default parameters' do
it { is_expected.to contain_glare_config('database/connection').with_value('sqlite:////var/lib/glare/glare.sqlite') }
it { is_expected.to contain_glare_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/max_retries').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/max_pool_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/max_overflow').with_value('<SERVICE DEFAULT>') }
end
context 'with specific parameters' do
let :params do
{ :database_connection => 'mysql+pymysql://glare:glare@localhost/glare',
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_retries => '11',
:database_retry_interval => '11',
:database_max_pool_size => '11',
:database_max_overflow => '21',
}
end
it { is_expected.to contain_glare_config('database/connection').with_value('mysql+pymysql://glare:glare@localhost/glare') }
it { is_expected.to contain_glare_config('database/idle_timeout').with_value('3601') }
it { is_expected.to contain_glare_config('database/min_pool_size').with_value('2') }
it { is_expected.to contain_glare_config('database/max_retries').with_value('11') }
it { is_expected.to contain_glare_config('database/retry_interval').with_value('11') }
it { is_expected.to contain_glare_config('database/max_pool_size').with_value('11') }
it { is_expected.to contain_glare_config('database/max_overflow').with_value('21') }
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://glare:glare@localhost/glare', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
end
end
context 'with MySQL-python library as backend package' do
let :params do
{ :database_connection => 'mysql://glare:glare@localhost/glare', }
end
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
end
context 'with incorrect database_connection string' do
let :params do
{ :database_connection => 'foodb://glare:glare@localhost/glare', }
end
it_raises 'a Puppet::Error', /validate_re/
end
context 'with incorrect pymysql database_connection string' do
let :params do
{ :database_connection => 'foo+pymysql://glare:glare@localhost/glare', }
end
it_raises 'a Puppet::Error', /validate_re/
end
end
shared_examples_for 'glare::db on Debian' do
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
end
it 'install the proper backend package' do
is_expected.to contain_package('db_backend_package').with(
:ensure => 'present',
:name => 'python-pymysql',
:tag => 'openstack'
)
end
end
end
shared_examples_for 'glare::db on RedHat' do
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
end
it 'install the proper backend package' do
is_expected.not_to contain_package('db_backend_package')
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'glare::db'
it_configures "glare::db on #{facts[:osfamily]}"
end
end
end

View File

@ -0,0 +1,128 @@
#
# Unit tests for glare::keystone::auth
#
require 'spec_helper'
describe 'glare::keystone::auth' do
shared_examples_for 'glare-keystone-auth' do
context 'with default class parameters' do
let :params do
{ :password => 'glare_password',
:tenant => 'foobar' }
end
it { is_expected.to contain_keystone_user('glare').with(
:ensure => 'present',
:password => 'glare_password',
) }
it { is_expected.to contain_keystone_user_role('glare@foobar').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('glare::FIXME').with(
:ensure => 'present',
:description => 'glare FIXME Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/glare::FIXME').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:FIXME',
:admin_url => 'http://127.0.0.1:FIXME',
:internal_url => 'http://127.0.0.1:FIXME',
) }
end
context 'when overriding URL parameters' do
let :params do
{ :password => 'glare_password',
: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
it { is_expected.to contain_keystone_endpoint('RegionOne/glare::FIXME').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
context 'when overriding auth name' do
let :params do
{ :password => 'foo',
:auth_name => 'glarey' }
end
it { is_expected.to contain_keystone_user('glarey') }
it { is_expected.to contain_keystone_user_role('glarey@services') }
it { is_expected.to contain_keystone_service('glare::FIXME') }
it { is_expected.to contain_keystone_endpoint('RegionOne/glare::FIXME') }
end
context 'when overriding service name' do
let :params do
{ :service_name => 'glare_service',
:auth_name => 'glare',
:password => 'glare_password' }
end
it { is_expected.to contain_keystone_user('glare') }
it { is_expected.to contain_keystone_user_role('glare@services') }
it { is_expected.to contain_keystone_service('glare_service::FIXME') }
it { is_expected.to contain_keystone_endpoint('RegionOne/glare_service::FIXME') }
end
context 'when disabling user configuration' do
let :params do
{
:password => 'glare_password',
:configure_user => false
}
end
it { is_expected.not_to contain_keystone_user('glare') }
it { is_expected.to contain_keystone_user_role('glare@services') }
it { is_expected.to contain_keystone_service('glare::FIXME').with(
:ensure => 'present',
:description => 'glare FIXME Service'
) }
end
context 'when disabling user and user role configuration' do
let :params do
{
:password => 'glare_password',
:configure_user => false,
:configure_user_role => false
}
end
it { is_expected.not_to contain_keystone_user('glare') }
it { is_expected.not_to contain_keystone_user_role('glare@services') }
it { is_expected.to contain_keystone_service('glare::FIXME').with(
:ensure => 'present',
:description => 'glare FIXME Service'
) }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'glare-keystone-auth'
end
end
end

View File

@ -0,0 +1,145 @@
require 'spec_helper'
describe 'glare::keystone::authtoken' do
let :params do
{ :password => 'secrete', }
end
shared_examples 'glare authtoken' do
context 'with default parameters' do
it 'configure keystone_authtoken' do
is_expected.to contain_glare_config('keystone_authtoken/username').with_value('glare')
is_expected.to contain_glare_config('keystone_authtoken/password').with_value('secrete')
is_expected.to contain_glare_config('keystone_authtoken/auth_url').with_value('http://localhost:35357')
is_expected.to contain_glare_config('keystone_authtoken/project_name').with_value('services')
is_expected.to contain_glare_config('keystone_authtoken/user_domain_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/project_domain_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/insecure').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/auth_section').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/auth_type').with_value('password')
is_expected.to contain_glare_config('keystone_authtoken/auth_uri').with_value('http://localhost:5000')
is_expected.to contain_glare_config('keystone_authtoken/auth_version').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/cache').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/cafile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/certfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/check_revocations_for_cached').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/delay_auth_decision').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/enforce_token_bind').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/hash_algorithms').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/http_connect_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/http_request_max_retries').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/include_service_catalog').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/keyfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_conn_get_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_dead_retry').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_maxsize').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_socket_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_unused_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcache_secret_key').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcache_security_strategy').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcache_use_advanced_pool').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/memcached_servers').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/region_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/revocation_cache_time').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/signing_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glare_config('keystone_authtoken/token_cache_time').with_value('<SERVICE DEFAULT>')
end
end
context 'when overriding parameters' do
before do
params.merge!({
:auth_uri => 'https://10.0.0.1:9999/',
:username => 'myuser',
:password => 'mypasswd',
:auth_url => 'https://127.0.0.1:35357',
:project_name => 'service_project',
:user_domain_name => 'domainX',
:project_domain_name => 'domainX',
:insecure => false,
:auth_section => 'new_section',
:auth_type => 'password',
:auth_version => 'v3',
:cache => 'somevalue',
:cafile => '/opt/stack/data/cafile.pem',
:certfile => 'certfile.crt',
:check_revocations_for_cached => false,
:delay_auth_decision => false,
:enforce_token_bind => 'permissive',
:hash_algorithms => 'md5',
:http_connect_timeout => '300',
:http_request_max_retries => '3',
:include_service_catalog => true,
:keyfile => 'keyfile',
:memcache_pool_conn_get_timeout => '9',
:memcache_pool_dead_retry => '302',
:memcache_pool_maxsize => '11',
:memcache_pool_socket_timeout => '2',
:memcache_pool_unused_timeout => '61',
:memcache_secret_key => 'secret_key',
:memcache_security_strategy => 'ENCRYPT',
:memcache_use_advanced_pool => true,
:memcached_servers => ['memcached01:11211','memcached02:11211'],
:region_name => 'region2',
:revocation_cache_time => '11',
:signing_dir => '/var/cache',
:token_cache_time => '301',
})
end
it 'configure keystone_authtoken' do
is_expected.to contain_glare_config('keystone_authtoken/auth_uri').with_value('https://10.0.0.1:9999/')
is_expected.to contain_glare_config('keystone_authtoken/username').with_value(params[:username])
is_expected.to contain_glare_config('keystone_authtoken/password').with_value(params[:password]).with_secret(true)
is_expected.to contain_glare_config('keystone_authtoken/auth_url').with_value(params[:auth_url])
is_expected.to contain_glare_config('keystone_authtoken/project_name').with_value(params[:project_name])
is_expected.to contain_glare_config('keystone_authtoken/user_domain_name').with_value(params[:user_domain_name])
is_expected.to contain_glare_config('keystone_authtoken/project_domain_name').with_value(params[:project_domain_name])
is_expected.to contain_glare_config('keystone_authtoken/insecure').with_value(params[:insecure])
is_expected.to contain_glare_config('keystone_authtoken/auth_section').with_value(params[:auth_section])
is_expected.to contain_glare_config('keystone_authtoken/auth_type').with_value(params[:auth_type])
is_expected.to contain_glare_config('keystone_authtoken/auth_version').with_value(params[:auth_version])
is_expected.to contain_glare_config('keystone_authtoken/cache').with_value(params[:cache])
is_expected.to contain_glare_config('keystone_authtoken/cafile').with_value(params[:cafile])
is_expected.to contain_glare_config('keystone_authtoken/certfile').with_value(params[:certfile])
is_expected.to contain_glare_config('keystone_authtoken/check_revocations_for_cached').with_value(params[:check_revocations_for_cached])
is_expected.to contain_glare_config('keystone_authtoken/delay_auth_decision').with_value(params[:delay_auth_decision])
is_expected.to contain_glare_config('keystone_authtoken/enforce_token_bind').with_value(params[:enforce_token_bind])
is_expected.to contain_glare_config('keystone_authtoken/hash_algorithms').with_value(params[:hash_algorithms])
is_expected.to contain_glare_config('keystone_authtoken/http_connect_timeout').with_value(params[:http_connect_timeout])
is_expected.to contain_glare_config('keystone_authtoken/http_request_max_retries').with_value(params[:http_request_max_retries])
is_expected.to contain_glare_config('keystone_authtoken/include_service_catalog').with_value(params[:include_service_catalog])
is_expected.to contain_glare_config('keystone_authtoken/keyfile').with_value(params[:keyfile])
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_conn_get_timeout').with_value(params[:memcache_pool_conn_get_timeout])
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_dead_retry').with_value(params[:memcache_pool_dead_retry])
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_maxsize').with_value(params[:memcache_pool_maxsize])
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_socket_timeout').with_value(params[:memcache_pool_socket_timeout])
is_expected.to contain_glare_config('keystone_authtoken/memcache_pool_unused_timeout').with_value(params[:memcache_pool_unused_timeout])
is_expected.to contain_glare_config('keystone_authtoken/memcache_secret_key').with_value(params[:memcache_secret_key])
is_expected.to contain_glare_config('keystone_authtoken/memcache_security_strategy').with_value(params[:memcache_security_strategy])
is_expected.to contain_glare_config('keystone_authtoken/memcache_use_advanced_pool').with_value(params[:memcache_use_advanced_pool])
is_expected.to contain_glare_config('keystone_authtoken/memcached_servers').with_value('memcached01:11211,memcached02:11211')
is_expected.to contain_glare_config('keystone_authtoken/region_name').with_value(params[:region_name])
is_expected.to contain_glare_config('keystone_authtoken/revocation_cache_time').with_value(params[:revocation_cache_time])
is_expected.to contain_glare_config('keystone_authtoken/signing_dir').with_value(params[:signing_dir])
is_expected.to contain_glare_config('keystone_authtoken/token_cache_time').with_value(params[:token_cache_time])
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'glare authtoken'
end
end
end

View File

@ -0,0 +1,139 @@
require 'spec_helper'
describe 'glare::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/glare/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',
:use_syslog => true,
:use_stderr => false,
:syslog_log_facility => 'LOG_FOO',
:log_dir => '/var/log',
:log_file => '/var/log/glare.log',
:debug => true,
}
end
shared_examples_for 'glare-logging' do
context 'with basic logging options and default settings' do
it_configures 'basic default logging settings'
end
context 'with basic logging options and non-default settings' do
before { params.merge!( log_params ) }
it_configures 'basic non-default logging settings'
end
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 'basic default logging settings' do
it 'configures glare logging settins with default values' do
is_expected.to contain_glare_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_glare_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_glare_config('DEFAULT/syslog_log_facility').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_glare_config('DEFAULT/log_dir').with(:value => '/var/log/glare')
is_expected.to contain_glare_config('DEFAULT/log_file').with(:value => '/var/log/glare/glare.log')
is_expected.to contain_glare_config('DEFAULT/debug').with(:value => '<SERVICE DEFAULT>')
end
end
shared_examples 'basic non-default logging settings' do
it 'configures glare logging settins with non-default values' do
is_expected.to contain_glare_config('DEFAULT/use_syslog').with(:value => 'true')
is_expected.to contain_glare_config('DEFAULT/use_stderr').with(:value => 'false')
is_expected.to contain_glare_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO')
is_expected.to contain_glare_config('DEFAULT/log_dir').with(:value => '/var/log')
is_expected.to contain_glare_config('DEFAULT/log_file').with(:value => '/var/log/glare.log')
is_expected.to contain_glare_config('DEFAULT/debug').with(:value => 'true')
end
end
shared_examples_for 'logging params set' do
it 'enables logging params' do
is_expected.to contain_glare_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_glare_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_glare_config('DEFAULT/logging_debug_format_suffix').with_value(
'%(funcName)s %(pathname)s:%(lineno)d')
is_expected.to contain_glare_config('DEFAULT/logging_exception_prefix').with_value(
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
is_expected.to contain_glare_config('DEFAULT/log_config_append').with_value(
'/etc/glare/logging.conf')
is_expected.to contain_glare_config('DEFAULT/publish_errors').with_value(
true)
is_expected.to contain_glare_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_glare_config('DEFAULT/fatal_deprecations').with_value(
true)
is_expected.to contain_glare_config('DEFAULT/instance_format').with_value(
'[instance: %(uuid)s] ')
is_expected.to contain_glare_config('DEFAULT/instance_uuid_format').with_value(
'[instance: %(uuid)s] ')
is_expected.to contain_glare_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_glare_config("DEFAULT/#{param}").with_value('<SERVICE DEFAULT>') }
}
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'glare-logging'
end
end
end

View File

@ -0,0 +1,36 @@
require 'spec_helper'
describe 'glare::policy' do
shared_examples_for 'glare-policies' do
let :params do
{
:policy_path => '/etc/glare/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
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'glare-policies'
end
end
end

5
spec/shared_examples.rb Normal file
View File

@ -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

13
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,13 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'shared_examples'
require 'puppet-openstack_spec_helper/defaults'
require 'rspec-puppet-facts'
include RspecPuppetFacts
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! }

View File

@ -0,0 +1 @@
require 'puppet-openstack_spec_helper/beaker_spec_helper'

View File

@ -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(:glare_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::Glare_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::Glare_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::Glare_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::Glare_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

View File

@ -0,0 +1,64 @@
require 'puppet'
require 'puppet/type/glare_config'
describe 'Puppet::Type.type(:glare_config)' do
before :each do
@glare_config = Puppet::Type.type(:glare_config).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should require a name' do
expect {
Puppet::Type.type(:glare_config).new({})
}.to raise_error(Puppet::Error, 'Title or name must be provided')
end
it 'should not expect a name with whitespace' do
expect {
Puppet::Type.type(:glare_config).new(:name => 'f oo')
}.to raise_error(Puppet::Error, /Parameter name failed/)
end
it 'should fail when there is no section' do
expect {
Puppet::Type.type(:glare_config).new(:name => 'foo')
}.to raise_error(Puppet::Error, /Parameter name failed/)
end
it 'should not require a value when ensure is absent' do
Puppet::Type.type(:glare_config).new(:name => 'DEFAULT/foo', :ensure => :absent)
end
it 'should accept a valid value' do
@glare_config[:value] = 'bar'
expect(@glare_config[:value]).to eq('bar')
end
it 'should not accept a value with whitespace' do
@glare_config[:value] = 'b ar'
expect(@glare_config[:value]).to eq('b ar')
end
it 'should accept valid ensure values' do
@glare_config[:ensure] = :present
expect(@glare_config[:ensure]).to eq(:present)
@glare_config[:ensure] = :absent
expect(@glare_config[:ensure]).to eq(:absent)
end
it 'should not accept invalid ensure values' do
expect {
@glare_config[:ensure] = :latest
}.to raise_error(Puppet::Error, /Invalid value/)
end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'glare')
catalog.add_resource package, @glare_config
dependency = @glare_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@glare_config)
expect(dependency[0].source).to eq(package)
end
end

12
tests/init.pp Normal file
View File

@ -0,0 +1,12 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation
# errors and view a log of events) or by fully applying the test in a virtual
# environment (to compare the resulting system state to the desired state).
#
# Learn more about module testing here:
# http://docs.puppetlabs.com/guides/tests_smoke.html
#
include ::glare