Add define oslo::cache

This define aims to manage all parameters in [cache] section
which belongs to oslo.cache.

We would use this define to take management of [cache] parameters
in other modules.
This commit is contained in:
Xingchao Yu 2016-01-18 12:26:05 +08:00
parent 37042fd488
commit 59387cc544
11 changed files with 266 additions and 547 deletions

41
Gemfile Normal file
View File

@ -0,0 +1,41 @@
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 'rspec-puppet-facts', :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'
gem 'puppet-openstack_spec_helper',
:git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper',
:require => false
end
group :system_tests do
gem 'beaker-rspec', :require => 'false'
gem 'beaker-puppet_install_helper', :require => 'false'
gem 'r10k', :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

85
Rakefile Normal file
View File

@ -0,0 +1,85 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'json'
modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
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", "only_variable_string"]
end
desc "Run acceptance tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end
Rake::Task[:spec_prep].clear
desc 'Create the fixtures directory'
task :spec_prep do
# Allow to test the module with custom dependencies
# like you could do with .fixtures file
if ENV['PUPPETFILE']
puppetfile = ENV['PUPPETFILE']
if ENV['GEM_HOME']
gem_home = ENV['GEM_HOME']
gem_bin_dir = "#{gem_home}" + '/bin/'
else
gem_bin_dir = ''
end
r10k = ['env']
r10k += ["PUPPETFILE=#{puppetfile}"]
r10k += ["PUPPETFILE_DIR=#{Dir.pwd}/spec/fixtures/modules"]
r10k += ["#{gem_bin_dir}r10k"]
r10k += ['puppetfile', 'install', '-v']
sh(*r10k)
else
# otherwise, use official OpenStack Puppetfile
zuul_ref = ENV['ZUUL_REF']
zuul_branch = ENV['ZUUL_BRANCH']
zuul_url = ENV['ZUUL_URL']
repo = 'openstack/puppet-openstack-integration'
rm_rf(repo)
if File.exists?('/usr/zuul-env/bin/zuul-cloner')
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}"]
sh(*zuul_clone_cmd)
else
sh("git clone https://git.openstack.org/#{repo} #{repo}")
end
script = ['env']
script += ["PUPPETFILE_DIR=#{Dir.pwd}/spec/fixtures/modules"]
script += ["ZUUL_REF=#{zuul_ref}"]
script += ["ZUUL_BRANCH=#{zuul_branch}"]
script += ["ZUUL_URL=#{zuul_url}"]
script += ['bash', "#{repo}/install_modules_unit.sh"]
sh(*script)
end
rm_rf("spec/fixtures/modules/#{modname}")
ln_s(Dir.pwd, "spec/fixtures/modules/#{modname}")
mkdir_p('spec/fixtures/manifests')
touch('spec/fixtures/manifests/site.pp')
end
Rake::Task[:spec_clean].clear
desc 'Clean up the fixtures directory'
task :spec_clean do
rm_rf('spec/fixtures/modules')
rm_rf('openstack')
if File.zero?('spec/fixtures/manifests/site.pp')
rm_f('spec/fixtures/manifests/site.pp')
end
end

140
manifests/cache.pp Normal file
View File

@ -0,0 +1,140 @@
# == Define: oslo::cache
#
# Configure oslo.cache options
#
# This resource configures Oslo cache resources for an OpenStack service.
# It will manage the [cache] section in the given config resource.
# It supports all of the oslo.cache parameters specified at
# https://github.com/openstack/oslo.cache/blob/master/oslo_cache/_opts.py
#
# For example, when configuring glance cache, instead of doing this:
#
# glance_api_config {
# 'cache/memcached_servers': value => $memcached_servers;
# 'cache/memcache_dead_retry': value => $memcache_dead_retry;
# ...
# }
#
# manifests should do this instead::
#
# oslo::cache { 'glance_api_config':
# memcached_servers => $memcached_servers,
# memcache_dead_retry => $memcache_dead_retry,
# ...
# }
#
# or add following code in glance::api:
#
# create_resources(oslo::cache, $authtoken_config)
#
# Then in hiera should add this:
#
# oslo::cache::cache_config:
# 'glance_api_config':
# memcached_servers: '127.0.0.1'
# memcache_dead_retry: '100'
#
# === Parameters:
#
# [*config_prefix*]
# (Optional) Prefix for building the configuration dictionary for
# the cache region. This should not need to be changed unless there
# is another dogpile.cache region with the same configuration name.
# Defaults to 'cache.oslo'.
#
# [*expiration_time*]
# (Optional) Default TTL, in seconds, for any cached item in the
# dogpile.cache region. This applies to any cached method that
# doesn't have an explicit cache expiration time defined for it.
# Defaults to 600.
#
# [*backend*]
# (Optional) Dogpile.cache backend module. It is recommended that
# Memcache with pooling (oslo_cache.memcache_pool) or Redis
# (dogpile.cache.redis) be used in production deployments.
# Defaults to 'dogpile.cache.null'.
#
# [*backend_argument*]
# (Optional) Arguments supplied to the backend module. Specify this option
# once per argument to be passed to the dogpile.cache backend.
# Example format: "<argname>:<value>".
# Defaults to [].
#
# [*proxies*]
# (Optional) Proxy classes to import that will affect the way the
# dogpile.cache backend functions. See the dogpile.cache documentation on
# changing-backend-behavior.
# Defaults to [].
#
# [*enabled*]
# (Optional) Global toggle for caching.
# Defaults to false.
#
# [*debug_cache_backend*]
# (Optional) Extra debugging from the cache backend (cache keys,
# get/set/delete/etc calls). This is only really useful if you need
# to see the specific cache-backend get/set/delete calls with the keys/values.
# Typically this should be left set to false.
# Defaults to false.
#
# [*memcache_servers*]
# (Optional) Memcache servers in the format of "host:port".
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
# Defaults to ['localhost::11211'].
#
# [*memcache_dead_retry*]
# (Optional) Number of seconds memcached server is considered dead before
# it is tried again.
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
# Defaults to '300'.
#
# [*memcache_socket_timeout*]
# (Optional) Timeout in seconds for every call to a server.'
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
# Defaults to '3'.
#
# [*memcache_pool_maxsize*]
# (Optional) Timeout in seconds for every call to a server.'
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
# Defaults to '10'.
#
# [*memcache_pool_unused_timeout*]
# (Optional) Number of seconds a connection to memcached is held unused
# in the pool before it is closed.
# (oslo_cache.memcache_pool backend only)
# Defaults to '60'.
#
# [*memcache_pool_connection_get_timeout*]
# (Optional) Number of seconds that an operation will wait to get a memcache
# client connection.
# Defaults to '10'.
#
define oslo::cache(
$config_prefix = $::os_service_default,
$expiration_time = $::os_service_default,
$backend = $::os_service_default,
$backend_argument = $::os_service_default,
$proxies = $::os_service_default,
$enabled = $::os_service_default,
$debug_cache_backend = $::os_service_default,
$memcache_servers = $::os_service_default,
$memcache_dead_retry = $::os_service_default,
$memcache_socket_timeout = $::os_service_default,
$memcache_pool_maxsize = $::os_service_default,
$memcache_pool_unused_timeout = $::os_service_default,
$memcache_pool_connection_get_timeout = $::os_service_default,
){
create_resources($name, {'cache/config_prefix' => { value => $config_prefix }})
create_resources($name, {'cache/expiration_time' => { value => $expiration_time }})
create_resources($name, {'cache/backend' => { value => $backend }})
create_resources($name, {'cache/backend_argument' => { value => $backend_argument }})
create_resources($name, {'cache/proxies' => { value => $proxies }})
create_resources($name, {'cache/enabled' => { value => $enabled }})
create_resources($name, {'cache/debug_cache_backend' => { value => $debug_cache_backend }})
create_resources($name, {'cache/memcache_servers' => { value => $memcache_servers }})
create_resources($name, {'cache/memcache_dead_retry' => { value => $memcache_dead_retry }})
create_resources($name, {'cache/memcache_socket_timeout' => { value => $memcache_socket_timeout }})
create_resources($name, {'cache/memcache_pool_maxsize' => { value => $memcache_pool_maxsize }})
create_resources($name, {'cache/memcache_pool_unused_timeout' => { value => $memcache_pool_unused_timeout }})
create_resources($name, {'cache/memcache_pool_connection_get_timeout' => { value => $memcache_pool_connection_get_timeout }})
}

View File

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

View File

@ -1,97 +0,0 @@
# == Class: oslo::db
#
# Configure the oslo database
#
# === Parameters
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to "sqlite:////var/lib/oslo/oslo.sqlite".
#
# [*database_idle_timeout*]
# Timeout when db connections should be reaped.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_retries*]
# Maximum number of database connection retries during startup.
# Setting -1 implies an infinite retry count.
# (Optional) Defaults to $::os_service_default
#
# [*database_retry_interval*]
# Interval between retries of opening a database connection.
# (Optional) Defaults to $::os_service_default
#
# [*database_min_pool_size*]
# Minimum number of SQL connections to keep open in a pool.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_pool_size*]
# Maximum number of SQL connections to keep open in a pool.
# (Optional) Defaults to $::os_service_default
#
# [*database_max_overflow*]
# If set, use this value for max_overflow with sqlalchemy.
# (Optional) Defaults to $::os_service_default
#
class oslo::db (
$database_connection = 'sqlite:////var/lib/oslo/oslo.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,
) {
$database_connection_real = pick($::oslo::database_connection, $database_connection)
$database_idle_timeout_real = pick($::oslo::database_idle_timeout, $database_idle_timeout)
$database_min_pool_size_real = pick($::oslo::database_min_pool_size, $database_min_pool_size)
$database_max_pool_size_real = pick($::oslo::database_max_pool_size, $database_max_pool_size)
$database_max_retries_real = pick($::oslo::database_max_retries, $database_max_retries)
$database_retry_interval_real = pick($::oslo::database_retry_interval, $database_retry_interval)
$database_max_overflow_real = pick($::oslo::database_max_overflow, $database_max_overflow)
validate_re($database_connection_real,
'(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
case $database_connection_real {
/^mysql(\+pymysql)?:\/\//: {
require 'mysql::bindings'
require 'mysql::bindings::python'
if $database_connection_real =~ /^mysql\+pymysql/ {
$backend_package = $::oslo::params::pymysql_package_name
} else {
$backend_package = false
}
}
/^postgresql:\/\//: {
$backend_package = false
require 'postgresql::lib::python'
}
/^sqlite:\/\//: {
$backend_package = $::oslo::params::sqlite_package_name
}
default: {
fail('Unsupported backend configured')
}
}
if $backend_package and !defined(Package[$backend_package]) {
package {'oslo-backend-package':
ensure => present,
name => $backend_package,
tag => 'openstack',
}
}
oslo_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;
}
}

View File

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

View File

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

View File

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

View File

@ -1,91 +0,0 @@
# == Class: oslo::keystone::auth
#
# Configures oslo user, service and endpoint in Keystone.
#
# === Parameters
#
# [*password*]
# (required) Password for oslo user.
#
# [*auth_name*]
# Username for oslo service. Defaults to 'oslo'.
#
# [*email*]
# Email for oslo user. Defaults to 'oslo@localhost'.
#
# [*tenant*]
# Tenant for oslo user. Defaults to 'services'.
#
# [*configure_endpoint*]
# Should oslo 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 auth_name.
#
# [*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 oslo::keystone::auth (
$password,
$auth_name = 'oslo',
$email = 'oslo@localhost',
$tenant = 'services',
$configure_endpoint = true,
$configure_user = true,
$configure_user_role = true,
$service_name = undef,
$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',
) {
$real_service_name = pick($service_name, $auth_name)
if $configure_user_role {
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'oslo-server' |>
}
Keystone_endpoint["${region}/${real_service_name}::${service_type}"] ~> Service <| name == 'oslo-server' |>
keystone::resource::service_identity { 'oslo':
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 => 'oslo FIXME Service',
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

@ -1,143 +0,0 @@
# Class oslo::logging
#
# oslo logging configuration
#
# == parameters
#
# [*verbose*]
# (Optional) Should the daemons log verbose messages
# Defaults to $::os_service_default
#
# [*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
#
# [*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/oslo'.
#
# [*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*]
# 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', 'oslomiddleware' => '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 oslo::logging(
$use_syslog = $::os_service_default,
$use_stderr = $::os_service_default,
$log_facility = $::os_service_default,
$log_dir = '/var/log/oslo',
$verbose = $::os_service_default,
$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,
) {
if is_service_default($default_log_levels) {
$default_log_levels_real = $default_log_levels
} else {
$default_log_levels_real = join(sort(join_keys_to_values($default_log_levels, '=')), ',')
}
oslo_config {
'DEFAULT/use_syslog' : value => $use_syslog;
'DEFAULT/use_stderr' : value => $use_stderr;
'DEFAULT/syslog_log_facility' : value => $log_facility;
'DEFAULT/log_dir' : value => $log_dir;
'DEFAULT/log_file': value => $log_file;
'DEFAULT/verbose' : value => $verbose;
'DEFAULT/debug' : value => $debug;
'DEFAULT/default_log_levels' : value => $default_log_levels_real;
'DEFAULT/logging_context_format_string' : value => $logging_context_format_string;
'DEFAULT/logging_default_format_string' : value => $logging_default_format_string;
'DEFAULT/logging_debug_format_suffix' : value => $logging_debug_format_suffix;
'DEFAULT/logging_exception_prefix' : value => $logging_exception_prefix;
'DEFAULT/log_config_append' : value => $log_config_append;
'DEFAULT/publish_errors' : value => $publish_errors;
'DEFAULT/fatal_deprecations' : value => $fatal_deprecations;
'DEFAULT/instance_format' : value => $instance_format;
'DEFAULT/instance_uuid_format' : value => $instance_uuid_format;
'DEFAULT/log_date_format' : value => $log_date_format;
}
}

View File

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