Retire openstack/puppet-tuskar

Tuskar is not maintained anymore.
Further maintenance should be done in stable branches, but master is no
longer supported.

Change-Id: I957ef8dc587086f32c918676a66dd8e247e50280
This commit is contained in:
Emilien Macchi 2016-01-05 16:31:24 -05:00
parent cb68e4142e
commit d54150a1ad
44 changed files with 2 additions and 2853 deletions

11
.gitignore vendored
View File

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

View File

@ -1,28 +0,0 @@
##2015-11-25 - 7.0.0
###Summary
This is a backwards-compatible major release for OpenStack Liberty.
####Features
- keystone/auth: make service description configurable
- add tag to package and service resources
- add tuskar::config class
- reflect provider change in puppet-openstacklib
- put all the logging related parameters to the logging class
- introduce tuskar::db class
- switch Tuskar to $::os_service_default
- db: use postgresql lib class for psycopg package
####Bugfixes
- rely on autorequire for config resource ordering
####Maintenance
- initial msync run for all Puppet OpenStack modules
- try to use zuul-cloner to prepare fixtures
- remove class_parameter_defaults puppet-lint check
- fix rspec 3.x syntax
##2015-07-08 - 6.0.0
###Summary
- Initial release of the puppet-tuskar module

37
Gemfile
View File

@ -1,37 +0,0 @@
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'
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

176
LICENSE
View File

@ -1,176 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

View File

@ -1,81 +1,3 @@
puppet-tuskar
=============
This project is no longer maintained.
7.0.0 - 2015.2 - Liberty
#### Table of Contents
1. [Overview - What is the tuskar module?](#overview)
2. [Module Description - What does the module do?](#module-description)
3. [Setup - The basics of getting started with tuskar](#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 tuskar 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 as part of the core software. The module itself is used to flexibly configure and manage the management service for Openstack.
Module Description
------------------
Setup
-----
**What the tuskar module affects:**
* tuskar, the management service for Openstack.
Implementation
--------------
### tuskar
tuskar is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers.
### Types
#### tuskar_config
The `tuskar_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/tuskar/tuskar.conf` file.
```puppet
tuskar_config { 'DEFAULT/verbose' :
value => true,
}
```
This will write `verbose=true` in the `[DEFAULT]` section.
##### name
Section/setting name to manage from `tuskar.conf`
##### value
The value of the setting to be defined.
##### secret
Whether to hide the value from Puppet logs. Defaults to `false`.
##### ensure_absent_val
If value is equal to ensure_absent_val then the resource will behave as if `ensure => absent` was specified. Defaults to `<SERVICE DEFAULT>`
Limitations
-----------
Development
-----------
Developer documentation for the entire puppet-openstack project.
* https://wiki.openstack.org/wiki/Puppet-openstack#Developer_documentation
Contributors
------------
* https://github.com/openstack/puppet-tuskar/graphs/contributors
The contents of this repository are still available in the Git source code management system. To see the contents of this repository before it reached its end of life, please check out the previous commit with "git checkout HEAD^1".

View File

@ -1,85 +0,0 @@
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

View File

@ -1,27 +0,0 @@
# This is an example of site.pp to deploy Tuskar
class { '::tuskar::client': }
class { '::tuskar::keystone::auth':
admin_address => '10.0.0.1',
internal_address => '10.0.0.1',
public_address => '10.0.0.1',
password => 'verysecrete',
region => 'OpenStack'
}
class { '::tuskar::db::mysql':
password => 'dbpass',
host => '10.0.0.1',
allowed_hosts => '10.0.0.1'
}
class { '::tuskar':
database_connection => 'mysql://tuskar:secrete@10.0.0.1/tuskar?charset=utf8',
}
class { '::tuskar::api':
bind_host => '10.0.0.1',
identity_uri => 'https://identity.openstack.org:35357',
keystone_password => 'verysecrete'
}

View File

@ -1,113 +0,0 @@
require 'json'
require 'puppet/util/inifile'
class Puppet::Provider::Tuskar < Puppet::Provider
def self.conf_filename
'/etc/tuskar/tuskar.conf'
end
def self.withenv(hash, &block)
saved = ENV.to_hash
hash.each do |name, val|
ENV[name.to_s] = val
end
yield
ensure
ENV.clear
saved.each do |name, val|
ENV[name] = val
end
end
def self.tuskar_credentials
@tuskar_credentials ||= get_tuskar_credentials
end
def self.get_tuskar_credentials
auth_keys = ['auth_host', 'auth_port', 'auth_protocol',
'admin_tenant_name', 'admin_user', 'admin_password']
conf = tuskar_conf
if conf and conf['keystone_authtoken'] and
auth_keys.all?{|k| !conf['keystone_authtoken'][k].nil?}
return Hash[ auth_keys.map \
{ |k| [k, conf['keystone_authtoken'][k].strip] } ]
else
raise(Puppet::Error, "File: #{conf_filename} does not contain all \
required sections. Tuskar types will not work if tuskar is not \
correctly configured.")
end
end
def tuskar_credentials
self.class.tuskar_credentials
end
def self.auth_endpoint
@auth_endpoint ||= get_auth_endpoint
end
def self.get_auth_endpoint
q = tuskar_credentials
"#{q['auth_protocol']}://#{q['auth_host']}:#{q['auth_port']}/v2.0/"
end
def self.tuskar_conf
return @tuskar_conf if @tuskar_conf
@tuskar_conf = Puppet::Util::IniConfig::File.new
@tuskar_conf.read(conf_filename)
@tuskar_conf
end
def self.auth_tuskar(*args)
q = tuskar_credentials
authenv = {
:OS_AUTH_URL => self.auth_endpoint,
:OS_USERNAME => q['admin_user'],
:OS_TENANT_NAME => q['admin_tenant_name'],
:OS_PASSWORD => q['admin_password']
}
begin
withenv authenv do
tuskar(args)
end
rescue Exception => e
if (e.message =~ /\[Errno 111\] Connection refused/) or
(e.message =~ /\(HTTP 400\)/)
sleep 10
withenv authenv do
tuskar(args)
end
else
raise(e)
end
end
end
def auth_tuskar(*args)
self.class.auth_tuskar(args)
end
def tuskar_manage(*args)
cmd = args.join(" ")
output = `#{cmd}`
$?.exitstatus
end
def self.reset
@tuskar_conf = nil
@tuskar_credentials = nil
end
def self.list_tuskar_resources(type, *args)
json = auth_tuskar("--json", "#{type}-list", *args)
return JSON.parse(json)
end
def self.get_tuskar_resource_attrs(type, id)
json = auth_tuskar("--json", "#{type}-show", id)
return JSON.parse(json)
end
end

View File

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

View File

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

View File

@ -1,143 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Class tuskar::api
#
# Configure API service in tuskar
#
# == Parameters
#
# [*manage_service*]
# (optional) Whether to start/stop the service
# Defaults to true
#
# [*package_ensure*]
# (optional) Whether the tuskar api package will be installed
# Defaults to 'present'
#
# [*keystone_password*]
# (required) Password used to authentication.
#
# [*verbose*]
# (optional) Rather to log the tuskar api service at verbose level.
# Default: undef
#
# [*debug*]
# (optional) Rather to log the tuskar api service at debug level.
# Default: undef
#
# [*bind_host*]
# (optional) The address of the host to bind to.
# Default: $::os_service_default
#
# [*bind_port*]
# (optional) The port the server should bind to.
# Default: $::os_service_default
#
# [*log_file*]
# (optional) The path of file used for logging
# If set to boolean false, it will not log to any file.
# Default: undef
#
# [*log_dir*]
# (optional) directory to which tuskar logs are sent.
# If set to boolean false, it will not log to any directory.
# Defaults to undef
#
# [*keystone_tenant*]
# (optional) Tenant to authenticate to.
# Defaults to services.
#
# [*keystone_user*]
# (optional) User to authenticate as with keystone.
# Defaults to 'tuskar'.
# [*enabled*]
# (optional) Whether to enable services.
# Defaults to true.
#
# [*use_syslog*]
# (optional) Use syslog for logging.
# Defaults to undef.
#
# [*use_stderr*]
# (optional) Use stderr for logging
# Defaults to undef
#
# [*log_facility*]
# (optional) Syslog facility to receive log lines.
# Defaults to undef.
#
# [*purge_config*]
# (optional) Whether to set only the specified config options
# in the api config.
# Defaults to false.
#
# [*identity_uri*]
# (optional) Complete admin Identity API endpoint.
# Defaults to 'http://127.0.0.1:35357'.
#
class tuskar::api(
$keystone_password,
$verbose = undef,
$debug = undef,
$use_syslog = undef,
$log_facility = undef,
$log_dir = undef,
$use_stderr = undef,
$log_file = undef,
$bind_host = $::os_service_default,
$bind_port = $::os_service_default,
$keystone_tenant = 'services',
$keystone_user = 'tuskar',
$identity_uri = 'http://127.0.0.1:35357',
$enabled = true,
$purge_config = false,
$manage_service = true,
$package_ensure = 'present',
) inherits tuskar {
require ::keystone::python
include ::tuskar::logging
include ::tuskar::db
include ::tuskar::params
Tuskar_config<||> ~> Exec['post-tuskar_config']
Tuskar_config<||> ~> Service['tuskar-api']
# basic service config
tuskar_config {
'DEFAULT/tuskar_api_bind_ip': value => $bind_host;
'DEFAULT/tuskar_api_port': value => $bind_port;
'keystone_authtoken/identity_uri': value => $identity_uri;
'keystone_authtoken/admin_user': value => $keystone_user;
'keystone_authtoken/admin_password': value => $keystone_password, secret => true;
'keystone_authtoken/admin_tenant_name': value => $keystone_tenant;
}
resources { 'tuskar_config':
purge => $purge_config,
}
tuskar::generic_service { 'api':
enabled => $enabled,
manage_service => $manage_service,
package_ensure => $package_ensure,
package_name => $::tuskar::params::api_package_name,
service_name => $::tuskar::params::api_service_name,
}
}

View File

@ -1,40 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# 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.
# tuskar::client
#
# Manages the tuskar client package on systems
#
# === Parameters:
#
# [*package_ensure*]
# (optional) The state of the package
# Defaults to present
#
#
class tuskar::client (
$package_ensure = present
) {
include ::tuskar::params
package { 'python-tuskarclient':
ensure => $package_ensure,
name => $::tuskar::params::client_package_name,
}
}

View File

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

View File

@ -1,104 +0,0 @@
# == Class: tuskar::db
#
# Configure the Neutron database
#
# === Parameters
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to 'sqlite:////var/lib/tuskar/tuskar.sqlite'.
#
# [*database_idle_timeout*]
# Timeout when db connections should be reaped.
# (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_retries*]
# Maximum db 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 sql connection.
# (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 tuskar::db (
$database_connection = 'sqlite:////var/lib/tuskar/tuskar.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,
) {
include ::tuskar::params
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use tuskar::<myparam> if tuskar::db::<myparam> isn't specified.
$database_connection_real = pick($::tuskar::database_connection, $database_connection)
$database_idle_timeout_real = pick($::tuskar::database_idle_timeout, $database_idle_timeout)
$database_min_pool_size_real = pick($::tuskar::database_min_pool_size, $database_min_pool_size)
$database_max_pool_size_real = pick($::tuskar::database_max_pool_size, $database_max_pool_size)
$database_max_retries_real = pick($::tuskar::database_max_retries, $database_max_retries)
$database_retry_interval_real = pick($::tuskar::database_retry_interval, $database_retry_interval)
$database_max_overflow_real = pick($::tuskar::database_max_overflow, $database_max_overflow)
validate_re($database_connection_real,
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
if $database_connection_real {
case $database_connection_real {
/^mysql(\+pymysql)?:\/\//: {
require 'mysql::bindings'
require 'mysql::bindings::python'
if $database_connection_real =~ /^mysql\+pymysql/ {
$backend_package = $::tuskar::params::pymysql_package_name
} else {
$backend_package = false
}
}
/^postgresql:\/\//: {
$backend_package = false
require 'postgresql::lib::python'
}
/^sqlite:\/\//: {
$backend_package = $::tuskar::params::sqlite_package_name
}
default: {
fail('Unsupported backend configured')
}
}
if $backend_package and !defined(Package[$backend_package]) {
package {'tuskar-backend-package':
ensure => present,
name => $backend_package,
tag => 'openstack',
}
}
tuskar_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,83 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Class: tuskar::db::mysql
#
# The tuskar::db::mysql class creates a MySQL database for tuskar.
# It must be used on the MySQL server
#
# === Parameters
#
# [*password*]
# (required) Password that will be used for the tuskar db user.
#
# [*dbname*]
# (optional) Name of tuskar database.
# Defaults to tuskar
#
# [*user*]
# (optional) Name of tuskar user.
# Defaults to tuskar
#
# [*host*]
# (optional) Host where user should be allowed all privileges for database.
# Defaults to 127.0.0.1
#
# [*allowed_hosts*]
# (optional) Hosts allowed to use the database
# Defaults to undef.
#
# [*charset*]
# (optional) Charset of tuskar database
# Defaults 'utf8'.
#
# [*collate*]
# (optional) Charset collate of tuskar database
# Defaults 'utf8_general_ci'.
#
# [*mysql_module*]
# (optional) Deprecated. Does nothing
#
class tuskar::db::mysql(
$password,
$dbname = 'tuskar',
$user = 'tuskar',
$host = '127.0.0.1',
$allowed_hosts = undef,
$charset = 'utf8',
$collate = 'utf8_general_ci',
$mysql_module = undef,
) {
if $mysql_module {
warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
}
validate_string($password)
::openstacklib::db::mysql { 'tuskar':
user => $user,
password_hash => mysql_password($password),
dbname => $dbname,
host => $host,
charset => $charset,
collate => $collate,
allowed_hosts => $allowed_hosts,
}
::Openstacklib::Db::Mysql['tuskar'] ~> Exec<| title == 'tuskar-dbsync' |>
}

View File

@ -1,47 +0,0 @@
# == Class: tuskar::db::postgresql
#
# Class that configures postgresql for tuskar
# Requires the Puppetlabs postgresql module.
#
# === Parameters:
#
# [*password*]
# (Required) Password to connect to the database.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'tuskar'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'tuskar'.
#
# [*encoding*]
# (Optional) The charset to use for the database.
# Default to undef.
#
# [*privileges*]
# (Optional) Privileges given to the database user.
# Default to 'ALL'
#
class tuskar::db::postgresql(
$password,
$dbname = 'tuskar',
$user = 'tuskar',
$encoding = undef,
$privileges = 'ALL',
) {
Class['tuskar::db::postgresql'] -> Service<| title == 'tuskar' |>
::openstacklib::db::postgresql { 'tuskar':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}
::Openstacklib::Db::Postgresql['tuskar'] ~> Exec<| title == 'tuskar-dbsync' |>
}

View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Class to execute "tuskar-dbsync"
#
class tuskar::db::sync {
exec { 'tuskar-dbsync':
path => '/usr/bin',
user => 'tuskar',
refreshonly => true,
subscribe => [Package['tuskar-api'], Tuskar_config['database/connection']],
}
}

View File

@ -1,93 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# 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.
#
# == Define: tuskar::generic_service
#
# This defined type implements basic tuskar services.
# It is introduced to attempt to consolidate
# common code.
#
# It also allows users to specify ad-hoc services
# as needed
#
# This define creates a service resource with title tuskar-${name} and
# conditionally creates a package resource with title tuskar-${name}
#
# === Parameters:
#
# [*package_name*]
# (mandatory) The package name (for the generic_service)
#
# [*service_name*]
# (mandatory) The service name (for the generic_service)
#
# [*enabled*]
# (optional) Define if the service must be enabled or not
# Defaults to false.
#
# [*manage_service*]
# (optional) Manage or not the service (if a service_name is provided).
# Defaults to true.
#
# [*package_ensure*]
# (optional) Control the ensure parameter for the package ressource.
# Defaults to 'present'.
#
define tuskar::generic_service(
$package_name,
$service_name,
$enabled = false,
$manage_service = true,
$package_ensure = 'present'
) {
include ::tuskar::params
include ::tuskar::db::sync
$tuskar_title = "tuskar-${name}"
Exec['post-tuskar_config'] ~> Service<| title == $tuskar_title |>
Exec<| title == 'tuskar-dbsync' |> ~> Service<| title == $tuskar_title |>
if ($package_name) {
if !defined(Package[$package_name]) {
package { $tuskar_title:
ensure => $package_ensure,
name => $package_name,
notify => Service[$tuskar_title],
tag => ['openstack', 'tuskar-package'],
}
}
}
if $service_name {
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}
service { $tuskar_title:
ensure => $service_ensure,
name => $service_name,
enable => $enabled,
hasstatus => true,
tag => 'tuskar-service',
}
}
}

View File

@ -1,68 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# == Class: tuskar
#
# Tuskar base config
#
# == Parameters
#
# [*database_connection*]
# (optional) Connection url for the heat database.
# Defaults to undef.
#
# [*database_max_retries*]
# (optional) Maximum database connection retries during startup.
# Defaults to undef.
#
# [*database_idle_timeout*]
# (optional) Timeout before idle database connections are reaped.
# Defaults to undef.
#
# [*database_retry_interval*]
# (optional) Interval between retries of opening a database connection.
# Defaults to undef.
#
# [*database_min_pool_size*]
# (optional) Minimum number of SQL connections to keep open in a pool.
# Defaults to undef.
#
# [*database_max_pool_size*]
# (optional) Maximum number of SQL connections to keep open in a pool.
# Defaults to undef.
#
# [*database_max_overflow*]
# (optional) If set, use this value for max_overflow with sqlalchemy.
# Defaults to: undef.
#
class tuskar(
$database_connection = undef,
$database_max_retries = undef,
$database_idle_timeout = undef,
$database_retry_interval = undef,
$database_min_pool_size = undef,
$database_max_pool_size = undef,
$database_max_overflow = undef,
) {
include ::tuskar::params
exec { 'post-tuskar_config':
command => '/bin/echo "Tuskar config has changed"',
refreshonly => true,
}
}

View File

@ -1,213 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# 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.
#
# tuskar::keystone::auth
#
# Configures Tuskar user, service and endpoint in Keystone.
#
# === Parameters
#
# [*password*]
# (required) Password for Tuskar user.
#
# [*auth_name*]
# Username for Tuskar service. Defaults to 'tuskar'.
#
# [*email*]
# Email for Tuskar user. Defaults to 'tuskar@localhost'.
#
# [*tenant*]
# Tenant for Tuskar user. Defaults to 'services'.
#
# [*configure_endpoint*]
# Should Tuskar 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_name*]
# (Optional) Name of the service.
# Defaults to the value of auth_name, but must differ from the value.
#
# [*service_type*]
# Type of service. Defaults to 'management'.
#
# [*service_description*]
# Description for keystone service. Optional. Defaults to 'Tuskar Management Service'.
#
# [*public_protocol*]
# (optional) DEPRECATED: Use public_url instead.
# Protocol for public endpoint. Defaults to 'http'.
#
# [*public_address*]
# (optional) DEPRECATED: Use public_url instead.
# Public address for endpoint. Defaults to '127.0.0.1'.
#
# [*admin_protocol*]
# (optional) DEPRECATED: Use admin_url instead.
# Protocol for admin endpoint. Defaults to 'http'.
#
# [*admin_address*]
# (optional) DEPRECATED: Use admin_url instead.
# Admin address for endpoint. Defaults to '127.0.0.1'.
#
# [*internal_protocol*]
# (optional) DEPRECATED: Use internal_url instead.
# Protocol for internal endpoint. Defaults to 'http'.
#
# [*internal_address*]
# (optional) DEPRECATED: Use internal_url instead.
# Internal address for endpoint. Defaults to '127.0.0.1'.
#
# [*port*]
# (optional) DEPRECATED: Use public_url, internal_url and admin_url instead.
# Port for endpoint. Defaults to '8585'.
#
# [*public_port*]
# (optional) DEPRECATED: Use public_url instead.
# Port for public endpoint. Defaults to $port.
#
# [*region*]
# Region for endpoint. Defaults to 'RegionOne'.
#
# [*public_url*]
# (optional) The endpoint's public url. (Defaults to 'http://127.0.0.1:8585')
# This url should *not* contain any trailing '/'.
#
# [*admin_url*]
# (optional) The endpoint's admin url. (Defaults to 'http://127.0.0.1:8585')
# This url should *not* contain any trailing '/'.
#
# [*internal_url*]
# (optional) The endpoint's internal url. (Defaults to 'http://127.0.0.1:8585')
# This url should *not* contain any trailing '/'.
#
class tuskar::keystone::auth (
$password,
$auth_name = 'tuskar',
$email = 'tuskar@localhost',
$tenant = 'services',
$configure_endpoint = true,
$configure_user = true,
$configure_user_role = true,
$service_name = undef,
$service_type = 'management',
$service_description = 'Tuskar Management Service',
$region = 'RegionOne',
$public_url = 'http://127.0.0.1:8585',
$admin_url = 'http://127.0.0.1:8585',
$internal_url = 'http://127.0.0.1:8585',
# DEPRECATED
$port = undef,
$public_protocol = undef,
$public_address = undef,
$admin_protocol = undef,
$admin_address = undef,
$internal_protocol = undef,
$internal_address = undef,
$public_port = undef,
) {
if $port {
warning('The port parameter is deprecated, use public_url, internal_url and admin_url instead.')
}
if $public_port {
warning('The public_port parameter is deprecated, use public_url instead.')
}
if $public_protocol {
warning('The public_protocol parameter is deprecated, use public_url instead.')
}
if $public_address {
warning('The public_address parameter is deprecated, use public_url instead.')
}
if $internal_protocol {
warning('The internal_protocol parameter is deprecated, use internal_url instead.')
}
if $internal_address {
warning('The internal_address parameter is deprecated, use internal_url instead.')
}
if $admin_address {
warning('The admin_address parameter is deprecated, use admin_url instead.')
}
if $admin_protocol {
warning('The admin_protocol parameter is deprecated, use admin_url instead.')
}
if ($public_protocol or $public_address or $port or $public_port) {
$public_url_real = sprintf('%s://%s:%s',
pick($public_protocol, 'http'),
pick($public_address, '127.0.0.1'),
pick($public_port, $port, '8585'))
} else {
$public_url_real = $public_url
}
if ($admin_protocol or $admin_address or $port) {
$admin_url_real = sprintf('%s://%s:%s',
pick($admin_protocol, 'http'),
pick($admin_address, '127.0.0.1'),
pick($port, '8585'))
} else {
$admin_url_real = $admin_url
}
if ($internal_protocol or $internal_address or $port) {
$internal_url_real = sprintf('%s://%s:%s',
pick($internal_protocol, 'http'),
pick($internal_address, '127.0.0.1'),
pick($port, '8585'))
} else {
$internal_url_real = $internal_url
}
$real_service_name = pick($service_name, $auth_name)
if $configure_user_role {
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'tuskar-api' |>
}
Keystone_endpoint["${region}/${auth_name}::${service_type}"] ~> Service <| name == 'tuskar-api' |>
keystone::resource::service_identity { $auth_name:
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 => $service_description,
region => $region,
password => $password,
email => $email,
tenant => $tenant,
public_url => $public_url_real,
internal_url => $internal_url_real,
admin_url => $admin_url_real,
}
}

View File

@ -1,155 +0,0 @@
# Class tuskar::logging
#
# tuskar 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/tuskar'
#
# [*log_file*]
# (optional) The path of file used for logging
# If set to boolean false, it will not log to any file.
# Default to '/var/log/tuskar/tuskar-api.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*]
# 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',
# 'iso8601' => 'WARN',
# 'requests.packages.urllib3.connectionpool' => 'WARN' }
#
# [*publish_errors*]
# (optional) Publish error events (boolean value).
# Defaults to $::os_service_default (false if unconfigured).
#
# [*fatal_deprecations*]
# (optional) Make deprecations fatal (boolean value)
# Defaults to $::os_service_default (false if unconfigured).
#
# [*instance_format*]
# (optional) If an instance is passed with the log message, format it
# like this (string value).
# Defaults to $::os_service_default.
# 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 tuskar::logging(
$use_syslog = $::os_service_default,
$use_stderr = $::os_service_default,
$log_facility = $::os_service_default,
$log_dir = '/var/log/tuskar',
$log_file = '/var/log/tuskar/tuskar-api.log',
$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,
) {
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use tuskar::<myparam> first then tuskar::logging::<myparam>.
$use_syslog_real = pick($::tuskar::api::use_syslog,$use_syslog)
$use_stderr_real = pick($::tuskar::api::use_stderr,$use_stderr)
$log_facility_real = pick($::tuskar::api::log_facility,$log_facility)
$log_dir_real = pick($::tuskar::api::log_dir,$log_dir)
$log_file_real = pick($::tuskar::api::log_file,$log_file)
$verbose_real = pick($::tuskar::api::verbose,$verbose)
$debug_real = pick($::tuskar::api::debug,$debug)
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, '=')), ',')
}
tuskar_config {
'DEFAULT/debug': value => $debug_real;
'DEFAULT/verbose': value => $verbose_real;
'DEFAULT/use_stderr': value => $use_stderr_real;
'DEFAULT/use_syslog': value => $use_syslog_real;
'DEFAULT/log_dir': value => $log_dir_real;
'DEFAULT/log_file': value => $log_file_real;
'DEFAULT/syslog_log_facility': value => $log_facility_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/default_log_levels': value => $default_log_levels_real;
'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,29 +0,0 @@
# Parameters for puppet-tuskar
#
class tuskar::params {
case $::osfamily {
'RedHat': {
$client_package_name = 'python-tuskarclient'
$api_package_name = 'openstack-tuskar'
$api_service_name = 'openstack-tuskar-api'
$ui_package_name = 'openstack-tuskar-ui'
$ui_extras_package_name = 'openstack-tuskar-ui-extras'
$sqlite_package_name = undef
$pymysql_package_name = undef
}
'Debian': {
$client_package_name = 'python-tuskarclient'
$api_package_name = 'tuskar-api'
$api_service_name = 'tuskar-api'
$ui_package_name = 'tuskar-ui'
$ui_extras_package_name = 'tuskar-ui-extras'
$sqlite_package_name = 'python-pysqlite2'
$pymysql_package_name = 'python-pymysql'
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem")
}
} # Case $::osfamily
}

View File

@ -1,53 +0,0 @@
#
# Copyright (C) 2015 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# 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.
#
# tuskar::ui
#
# Install UI (and UI extras)
#
# === Parameters:
#
# [*package_ensure*]
# (optional) The state of the package
# Defaults to present
#
# [*extras*]
# (optional) Also install UI extras
# Defaults to false
#
class tuskar::ui (
$package_ensure = 'present',
$extras = false,
) {
include ::tuskar::params
package { 'tuskar-ui':
ensure => $package_ensure,
name => $::tuskar::params::ui_package_name,
tag => ['openstack', 'tuskar-package'],
}
if $extras {
package { 'tuskar-ui-extras':
ensure => $package_ensure,
name => $::tuskar::params::ui_extras_package_name,
tag => ['openstack', 'tuskar-package'],
}
}
}

View File

@ -1,39 +0,0 @@
{
"name": "openstack-tuskar",
"version": "7.0.0",
"author": "eNovance and OpenStack Contributors",
"summary": "Puppet module for OpenStack Tuskar",
"license": "Apache-2.0",
"source": "git://github.com/openstack/puppet-tuskar.git",
"project_page": "https://launchpad.net/puppet-tuskar",
"issues_url": "https://bugs.launchpad.net/puppet-tuskar",
"requirements": [
{ "name": "pe","version_requirement": "3.x" },
{ "name": "puppet","version_requirement": "3.x" }
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": ["8"]
},
{
"operatingsystem": "Fedora",
"operatingsystemrelease": ["20"]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": ["6.5","7"]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": ["14.04"]
}
],
"description": "Installs and configures OpenStack Tuskar (Management service).",
"dependencies": [
{ "name": "puppetlabs/inifile", "version_requirement": ">=1.0.0 <2.0.0" },
{ "name": "openstack/keystone", "version_requirement": ">=7.0.0 <8.0.0" },
{ "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" },
{ "name": "openstack/openstacklib", "version_requirement": ">=7.0.0 <8.0.0" }
]
}

View File

@ -1,11 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,11 +0,0 @@
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

@ -1,91 +0,0 @@
#
# Unit tests for tuskar::api
#
require 'spec_helper'
describe 'tuskar::api' do
let :params do
{ :keystone_password => 'passw0rd',
:keystone_user => 'tuskar',
:identity_uri => 'https://identity.os.net:5000',
:keystone_tenant => '_services_',
}
end
shared_examples 'tuskar-api' do
context 'with default parameters' do
it 'contains the logging class' do
is_expected.to contain_class('tuskar::logging')
end
it 'installs tuskar-api package and service' do
is_expected.to contain_service('tuskar-api').with(
:name => platform_params[:api_service_name],
:ensure => 'running',
:hasstatus => true,
:enable => true
)
is_expected.to contain_package('tuskar-api').with(
:name => platform_params[:api_package_name],
:ensure => 'present',
:notify => 'Service[tuskar-api]'
)
end
it 'configures tuskar-api with default parameters' do
is_expected.to contain_tuskar_config('DEFAULT/tuskar_api_bind_ip').with_value('<SERVICE DEFAULT>')
is_expected.to contain_tuskar_config('DEFAULT/tuskar_api_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_tuskar_config('keystone_authtoken/identity_uri').with_value(params[:identity_uri])
is_expected.to contain_tuskar_config('keystone_authtoken/admin_tenant_name').with_value(params[:keystone_tenant])
is_expected.to contain_tuskar_config('keystone_authtoken/admin_user').with_value(params[:keystone_user])
is_expected.to contain_tuskar_config('keystone_authtoken/admin_password').with_value(params[:keystone_password])
is_expected.to contain_tuskar_config('keystone_authtoken/admin_password').with_value(params[:keystone_password]).with_secret(true)
end
context 'when using MySQL' do
let :pre_condition do
"class { 'tuskar':
database_connection => 'mysql://tuskar:pass@10.0.0.1/tuskar'}"
end
it 'configures tuskar-api with RabbitMQ' do
is_expected.to contain_tuskar_config('database/connection').with_value('mysql://tuskar:pass@10.0.0.1/tuskar')
is_expected.to contain_tuskar_config('database/connection').with_value('mysql://tuskar:pass@10.0.0.1/tuskar').with_secret(true)
end
end
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian'
})
end
let :platform_params do
{ :api_package_name => 'tuskar-api',
:api_service_name => 'tuskar-api' }
end
it_configures 'tuskar-api'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat'
})
end
let :platform_params do
{ :api_package_name => 'openstack-tuskar',
:api_service_name => 'openstack-tuskar-api' }
end
it_configures 'tuskar-api'
end
end

View File

@ -1,38 +0,0 @@
#
# Unit tests for tuskar::client
#
require 'spec_helper'
describe 'tuskar::client' do
shared_examples_for 'tuskar client' do
context 'with default parameters' do
it { is_expected.to contain_package('python-tuskarclient').with_ensure('present') }
end
context 'with package_ensure parameter provided' do
let :params do
{ :package_ensure => false }
end
it { is_expected.to contain_package('python-tuskarclient').with_ensure('false') }
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'tuskar client'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'tuskar client'
end
end

View File

@ -1,20 +0,0 @@
require 'spec_helper'
describe 'tuskar::config' do
let :params do
{ :tuskar_config => {
'DEFAULT/foo' => { 'value' => 'fooValue' },
'DEFAULT/bar' => { 'value' => 'barValue' },
'DEFAULT/baz' => { 'ensure' => 'absent' }
}
}
end
it 'configures arbitrary tuskar configurations' do
is_expected.to contain_tuskar_config('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_tuskar_config('DEFAULT/bar').with_value('barValue')
is_expected.to contain_tuskar_config('DEFAULT/baz').with_ensure('absent')
end
end

View File

@ -1,95 +0,0 @@
#
# Unit tests for tuskar::db::mysql
#
require 'spec_helper'
describe 'tuskar::db::mysql' do
let :pre_condition do
[
'include mysql::server',
'include tuskar::db::sync'
]
end
let :params do
{ :dbname => 'tuskar',
:password => 's3cr3t',
:user => 'tuskar',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:host => '127.0.0.1',
}
end
shared_examples_for 'tuskar mysql database' do
context 'when omiting the required parameter password' do
before { params.delete(:password) }
it { expect { is_expected.to raise_error(Puppet::Error) } }
end
it 'creates a mysql database' do
is_expected.to contain_openstacklib__db__mysql('tuskar').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
:host => params[:host],
:charset => params[:charset]
)
end
context 'overriding allowed_hosts param to array' do
before :each do
params.merge!(
:allowed_hosts => ['127.0.0.1','%']
)
end
it {
is_expected.to contain_openstacklib__db__mysql('tuskar').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
:host => params[:host],
:charset => params[:charset],
:allowed_hosts => ['127.0.0.1','%']
)}
end
context 'overriding allowed_hosts param to string' do
before :each do
params.merge!(
:allowed_hosts => '192.168.1.1'
)
end
it {
is_expected.to contain_openstacklib__db__mysql('tuskar').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
:host => params[:host],
:charset => params[:charset],
:allowed_hosts => '192.168.1.1'
)}
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'tuskar mysql database'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'tuskar mysql database'
end
end

View File

@ -1,58 +0,0 @@
require 'spec_helper'
describe 'tuskar::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('tuskar').with(
:user => 'tuskar',
:password => 'md532cc9d9d42efb508bc9d6267d873d63d'
)}
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('tuskar').with(
:user => 'tuskar',
:password => 'md532cc9d9d42efb508bc9d6267d873d63d'
)}
end
end
end

View File

@ -1,128 +0,0 @@
require 'spec_helper'
describe 'tuskar::db' do
shared_examples 'tuskar::db' do
context 'with default parameters' do
it { is_expected.to contain_tuskar_config('database/connection').with_value('sqlite:////var/lib/tuskar/tuskar.sqlite').with_secret(true) }
it { is_expected.to contain_tuskar_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_tuskar_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_tuskar_config('database/max_retries').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_tuskar_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
end
context 'with specific parameters' do
let :params do
{ :database_connection => 'mysql+pymysql://tuskar:tuskar@localhost/tuskar',
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_retries => '11',
:database_retry_interval => '11', }
end
it { is_expected.to contain_tuskar_config('database/connection').with_value('mysql+pymysql://tuskar:tuskar@localhost/tuskar').with_secret(true) }
it { is_expected.to contain_tuskar_config('database/idle_timeout').with_value('3601') }
it { is_expected.to contain_tuskar_config('database/min_pool_size').with_value('2') }
it { is_expected.to contain_tuskar_config('database/max_retries').with_value('11') }
it { is_expected.to contain_tuskar_config('database/retry_interval').with_value('11') }
end
context 'with MySQL-python library as backend package' do
let :params do
{ :database_connection => 'mysql://tuskar:tuskar@localhost/tuskar', }
end
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://tuskar:tuskar@localhost/tuskar', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
end
end
context 'with incorrect database_connection string' do
let :params do
{ :database_connection => 'redis://tuskar:tuskar@localhost/tuskar', }
end
it_raises 'a Puppet::Error', /validate_re/
end
context 'with incorrect pymysql database_connection string' do
let :params do
{ :database_connection => 'foo+pymysql://tuskar:tuskar@localhost/tuskar', }
end
it_raises 'a Puppet::Error', /validate_re/
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
end
it_configures 'tuskar::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://tuskar:tuskar@localhost/tuskar', }
end
it 'install the proper backend package' do
is_expected.to contain_package('tuskar-backend-package').with(
:ensure => 'present',
:name => 'python-pymysql',
:tag => 'openstack'
)
end
end
context 'with sqlite backend' do
let :params do
{ :database_connection => 'sqlite:///var/lib/tuskar/tuskar.sqlite', }
end
it 'install the proper backend package' do
is_expected.to contain_package('tuskar-backend-package').with(
:ensure => 'present',
:name => 'python-pysqlite2',
:tag => 'openstack'
)
end
end
end
context 'on Redhat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
end
it_configures 'tuskar::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://tuskar:tuskar@localhost/tuskar', }
end
it { is_expected.not_to contain_package('tuskar-backend-package') }
end
end
end

View File

@ -1,30 +0,0 @@
#
# Unit tests for tuskar::init
#
require 'spec_helper'
describe 'tuskar' do
shared_examples_for 'tuskar' do
it {
is_expected.to contain_class('tuskar::params')
is_expected.to contain_exec('post-tuskar_config')
}
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'tuskar'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'tuskar'
end
end

View File

@ -1,114 +0,0 @@
#
# Unit tests for tuskar::keystone::auth
#
require 'spec_helper'
describe 'tuskar::keystone::auth' do
let :facts do
{ :osfamily => 'Debian' }
end
describe 'with default class parameters' do
let :params do
{ :password => 'tuskar_password',
:tenant => 'foobar' }
end
it { is_expected.to contain_keystone_user('tuskar').with(
:ensure => 'present',
:password => 'tuskar_password',
) }
it { is_expected.to contain_keystone_user_role('tuskar@foobar').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('tuskar::management').with(
:ensure => 'present',
:description => 'Tuskar Management Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/tuskar::management').with(
:ensure => 'present',
:public_url => "http://127.0.0.1:8585",
:admin_url => "http://127.0.0.1:8585",
:internal_url => "http://127.0.0.1:8585"
) }
end
describe 'with endpoint parameters' do
let :params do
{ :password => 'tuskar_password',
:public_url => 'https://10.0.0.10:8585',
:admin_url => 'https://10.0.0.11:8585',
:internal_url => 'https://10.0.0.11:8585' }
end
it { is_expected.to contain_keystone_endpoint('RegionOne/tuskar::management').with(
:ensure => 'present',
:public_url => 'https://10.0.0.10:8585',
:admin_url => 'https://10.0.0.11:8585',
:internal_url => 'https://10.0.0.11:8585'
) }
end
describe 'when configuring tuskar-server' do
let :pre_condition do
"class { 'tuskar::server': auth_password => 'test' }"
end
let :params do
{ :password => 'tuskar_password',
:tenant => 'foobar' }
end
end
describe 'when overriding public_protocol, public_port and public address' do
let :params do
{ :password => 'tuskar_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/tuskar::management').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 => 'tuskary' }
end
it { is_expected.to contain_keystone_user('tuskary') }
it { is_expected.to contain_keystone_user_role('tuskary@services') }
it { is_expected.to contain_keystone_service('tuskary::management') }
it { is_expected.to contain_keystone_endpoint('RegionOne/tuskary::management') }
end
describe 'when overriding various parameters' do
let :params do
{ :password => 'foo',
:service_name => 'mytuskar',
:configure_user => false,
:configure_user_role => false }
end
it { is_expected.to contain_keystone__resource__service_identity('tuskar').with(
:service_name => 'mytuskar',
:configure_user => false,
:configure_user_role => false,
) }
end
end

View File

@ -1,146 +0,0 @@
require 'spec_helper'
describe 'tuskar::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/tuskar/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,
:log_facility => 'LOG_FOO',
:log_dir => '/var/log',
:log_file => '/var/log/foo/bar.log',
:verbose => true,
:debug => true,
}
end
shared_examples_for 'tuskar-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 tuskar logging settins with default values' do
is_expected.to contain_tuskar_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_tuskar_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_tuskar_config('DEFAULT/log_dir').with(:value => '/var/log/tuskar')
is_expected.to contain_tuskar_config('DEFAULT/log_file').with(:value => '/var/log/tuskar/tuskar-api.log')
is_expected.to contain_tuskar_config('DEFAULT/verbose').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_tuskar_config('DEFAULT/debug').with(:value => '<SERVICE DEFAULT>')
end
end
shared_examples 'basic non-default logging settings' do
it 'configures tuskar logging settins with non-default values' do
is_expected.to contain_tuskar_config('DEFAULT/use_syslog').with(:value => 'true')
is_expected.to contain_tuskar_config('DEFAULT/use_stderr').with(:value => 'false')
is_expected.to contain_tuskar_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO')
is_expected.to contain_tuskar_config('DEFAULT/log_dir').with(:value => '/var/log')
is_expected.to contain_tuskar_config('DEFAULT/log_file').with(:value => '/var/log/foo/bar.log')
is_expected.to contain_tuskar_config('DEFAULT/verbose').with(:value => 'true')
is_expected.to contain_tuskar_config('DEFAULT/debug').with(:value => 'true')
end
end
shared_examples_for 'logging params set' do
it 'enables logging params' do
is_expected.to contain_tuskar_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_tuskar_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_tuskar_config('DEFAULT/logging_debug_format_suffix').with_value(
'%(funcName)s %(pathname)s:%(lineno)d')
is_expected.to contain_tuskar_config('DEFAULT/logging_exception_prefix').with_value(
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
is_expected.to contain_tuskar_config('DEFAULT/log_config_append').with_value(
'/etc/tuskar/logging.conf')
is_expected.to contain_tuskar_config('DEFAULT/publish_errors').with_value(
true)
is_expected.to contain_tuskar_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_tuskar_config('DEFAULT/fatal_deprecations').with_value(
true)
is_expected.to contain_tuskar_config('DEFAULT/instance_format').with_value(
'[instance: %(uuid)s] ')
is_expected.to contain_tuskar_config('DEFAULT/instance_uuid_format').with_value(
'[instance: %(uuid)s] ')
is_expected.to contain_tuskar_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_tuskar_config("DEFAULT/#{param}").with_value('<SERVICE DEFAULT>') }
}
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
end
it_configures 'tuskar-logging'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'tuskar-logging'
end
end

View File

@ -1,79 +0,0 @@
#
# Unit tests for tuskar::ui
#
require 'spec_helper'
describe 'tuskar::ui' do
shared_examples_for 'tuskar ui' do
context 'with default parameters' do
it 'installs tuskar-ui package' do
is_expected.to contain_package('tuskar-ui').with(
:name => platform_params[:ui_package_name],
:ensure => 'present',
:tag => ['openstack', 'tuskar-package'],
)
is_expected.to_not contain_package('tuskar-ui-extras')
end
end
context 'with extras parameter parameter provided' do
let :params do
{ :extras => true }
end
it 'installs tuskar-ui and tuskar-ui-extras packages' do
is_expected.to contain_package('tuskar-ui').with(
:name => platform_params[:ui_package_name],
:ensure => 'present',
:tag => ['openstack', 'tuskar-package'],
)
is_expected.to contain_package('tuskar-ui-extras').with(
:name => platform_params[:ui_extras_package_name],
:ensure => 'present',
:tag => ['openstack', 'tuskar-package'],
)
end
end
context 'with package_ensure parameter provided' do
let :params do
{ :package_ensure => 'absent' }
end
it 'installs tuskar-ui and tuskar-ui-extras packages' do
is_expected.to contain_package('tuskar-ui').with(
:name => platform_params[:ui_package_name],
:ensure => 'absent',
:tag => ['openstack', 'tuskar-package'],
)
end
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
let :platform_params do
{ :ui_package_name => 'tuskar-ui',
:ui_extras_package_name => 'tuskar-ui-extras' }
end
it_configures 'tuskar ui'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
let :platform_params do
{ :ui_package_name => 'openstack-tuskar-ui',
:ui_extras_package_name => 'openstack-tuskar-ui-extras' }
end
it_configures 'tuskar ui'
end
end

View File

@ -1,60 +0,0 @@
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
shared_examples 'generic Tuskar service' do |service|
context 'with default parameters' do
it 'installs package and service' do
is_expected.to contain_package(service[:name]).with({
:name => service[:package_name],
:ensure => 'present',
:notify => "Service[#{service[:name]}]",
:tag => ['openstack', 'tuskar-package'],
})
is_expected.to contain_service(service[:name]).with({
:name => service[:service_name],
:ensure => 'stopped',
:hasstatus => true,
:enable => false,
:tag => 'tuskar-service',
})
end
end
context 'with overridden parameters' do
let :params do
{ :enabled => true,
:ensure_package => '2014.1-1' }
end
it 'installs package and service' do
is_expected.to contain_package(service[:name]).with({
:name => service[:package_name],
:ensure => '2014.1-1',
:notify => "Service[#{service[:name]}]",
:tag => ['openstack', 'tuskar-package'],
})
is_expected.to contain_service(service[:name]).with({
:name => service[:service_name],
:ensure => 'running',
:hasstatus => true,
:enable => true,
:tag => 'tuskar-service',
})
end
end
context 'while not managing service state' do
let :params do
{ :enabled => false,
:manage_service => false }
end
it 'does not control service state' do
is_expected.to contain_service(service[:name]).without_ensure
end
end
end

View File

@ -1,13 +0,0 @@
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'
c.before :each do
@default_facts = { :os_service_default => '<SERVICE DEFAULT>' }
end
end
at_exit { RSpec::Puppet::Coverage.report! }

View File

@ -1,56 +0,0 @@
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

View File

@ -1,66 +0,0 @@
# 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(:tuskar_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::Tuskar_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::Tuskar_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::Tuskar_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::Tuskar_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

@ -1,63 +0,0 @@
require 'puppet'
require 'puppet/type/tuskar_config'
describe 'Puppet::Type.type(:tuskar_config)' do
before :each do
@tuskar_config = Puppet::Type.type(:tuskar_config).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should require a name' do
expect {
Puppet::Type.type(:tuskar_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(:tuskar_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(:tuskar_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(:tuskar_config).new(:name => 'DEFAULT/foo', :ensure => :absent)
end
it 'should accept a valid value' do
@tuskar_config[:value] = 'bar'
expect(@tuskar_config[:value]).to eq('bar')
end
it 'should not accept a value with whitespace' do
@tuskar_config[:value] = 'b ar'
expect(@tuskar_config[:value]).to eq('b ar')
end
it 'should accept valid ensure values' do
@tuskar_config[:ensure] = :present
expect(@tuskar_config[:ensure]).to eq(:present)
@tuskar_config[:ensure] = :absent
expect(@tuskar_config[:ensure]).to eq(:absent)
end
it 'should not accept invalid ensure values' do
expect {
@tuskar_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 => 'tuskar-api')
catalog.add_resource package, @tuskar_config
dependency = @tuskar_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@tuskar_config)
expect(dependency[0].source).to eq(package)
end
end