Rewrite puppet-sahara from scratch

During the Kilo summit, we talked about the state of the current
puppet-sahara module on stackforge, and especially about the brought up parity with
other modules.

For theses reasons, the rewrite was launched/leaded by Robbie Harwood,
but directly coded on Github (and not in a feature branch in this
repository), for this reason, this patch is non-atomic, and import the
latest frozencemetery/puppet-sahara version¹.

This rewrite/import was approved on puppet-openstack mailing list
(following this thread²).

The «reset» of the stackforge repo was discussed (in order to keep the history
of Robbie module) on #openstack-infra, but it seems we have no simple solution.

¹05af265b15
²https://groups.google.com/a/puppetlabs.com/forum/#!topic/puppet-openstack/0BETdNvrd70

Co-Authored-By: Robbie Harwood <rharwood@redhat.com>
Change-Id: Ic3dd7547fdfcba275d8a8b90b8ba84bc3ce1d7c0
This commit is contained in:
Sebastien Badia 2015-01-07 13:41:43 +01:00
parent 638e4d0439
commit a0f14ef9dd
39 changed files with 1686 additions and 1161 deletions

View File

@ -6,9 +6,7 @@ fixtures:
repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
ref: 'origin/2.2.x'
'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git'
'postgresql':
repo: "git://github.com/puppetlabs/puppet-postgresql.git"
ref: '2.5.0'
'postgresql': 'git://github.com/puppetlabs/puppetlabs-postgresql.git'
'qpid': 'git://github.com/dprince/puppet-qpid.git'
'rabbitmq':
repo: 'git://github.com/puppetlabs/puppetlabs-rabbitmq'

View File

@ -2,8 +2,11 @@ source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', '~> 0.3.2'
gem 'puppet-lint', '~> 1.1'
gem 'rspec-puppet', '~> 1.0.1'
gem 'puppet-lint-param-docs', '1.1.0'
gem 'metadata-json-lint'
gem 'puppet-syntax'
gem 'rake', '10.1.1'
gem 'rspec', '< 2.99'
gem 'json'
@ -15,5 +18,3 @@ if puppetversion = ENV['PUPPET_GEM_VERSION']
else
gem 'puppet', :require => false
end
# vim:ft=ruby

176
LICENSE Normal file
View File

@ -0,0 +1,176 @@
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.
END OF TERMS AND CONDITIONS

View File

@ -1,11 +1,73 @@
# puppet-sahara
sahara
======
Installs the OpenStack [sahara UI and backend](https://launchpad.net/sahara)
#### Table of Contents
If you want an example of how it's used see example/example.pp.
1. [Overview - What is the sahara module?](#overview)
2. [Module Description - What does the module do?](#module-description)
3. [Setup - The basics of getting started with sahara](#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)
8. [Release Notes - Notes on the most recent updates to the module](#release-notes)
Pull requests and suggestions gladly received!
Overview
--------
If you wish to participate in the Sahara project please
[see the Sahara OpenStack wiki page](http://docs.openstack.org/developer/sahara/devref/how_to_participate.html)
for more information.
The Sahara module itself is used to flexibly configure and manage the
clustering service for OpenStack.
Module Description
------------------
The sahara module is an attempt to make Puppet capable of managing the
entirety of sahara.
Setup
-----
**What the sahara module affects:**
* sahara, the data processing service for OpenStack.
### Beginning with sahara
To use the sahara module's functionality you will need to declare multiple
resources. This is not an exhaustive list of all the components needed; we
recommend you consult and understand the
[core of openstack](http://docs.openstack.org) documentation.
Examples of usage can be found in the *examples* directory.
Implementation
--------------
### sahara
puppet-sahara is a combination of Puppet manifests and ruby code to deliver
configuration and extra functionality through types and providers.
Limitations
-----------
None.
Development
-----------
Developer documentation for the entire puppet-openstack project.
* https://wiki.openstack.org/wiki/Puppet-openstack#Developer_documentation
Contributors
------------
* https://github.com/stackforge/puppet-sahara/graphs/contributors
Release Notes
-------------
**5.0.0**
* Rewrite

View File

@ -1 +0,0 @@
This repo will contain puppet manifests for Sahara

View File

@ -3,6 +3,14 @@ require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_autoloader_layout')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
exclude_tests_paths = ['pkg/**/*','vendor/**/*']
PuppetLint.configuration.ignore_paths = exclude_tests_paths
PuppetSyntax.exclude_paths = exclude_tests_paths
desc "Lint metadata.json file"
task :metadata do
sh "metadata-json-lint metadata.json"
end

View File

@ -1,23 +0,0 @@
class { 'sahara::db::mysql': password => 'sahara', }
class { 'sahara::keystone::auth':
password => 'sahara',
public_address => '127.0.0.1',
admin_address => '127.0.0.1',
internal_address => '127.0.0.1',
}
class { 'sahara':
sahara_host => '127.0.0.1',
db_host => '127.0.0.1',
sahara_db_password => 'sahara',
keystone_auth_host => '127.0.0.1',
keystone_password => 'sahara',
sahara_verbose => true,
}
class { 'sahara::dashboard':
sahara_host => '127.0.0.1',
use_neutron => true,
}

47
examples/basic.pp Normal file
View File

@ -0,0 +1,47 @@
# First, install a mysql server
class { 'mysql::server':
# sahara documentation recommends this configuration.
override_options => {
'mysqld' => {
'max_allowed_packet' => '256M'
}
},
# many configurations will need this line, too
package_name => 'mariadb-galera-server',
# if you're installing into an existing openstack
manage_config_file => false,
purge_conf_dir => false,
}
# Then, create a database
class { 'sahara::db::mysql':
password => 'a_big_secret',
}
# And connect a message bus
class { 'sahara::notify::rabbitmq':
rabbit_password => 'guest',
rabbit_use_ssl => false,
}
# Then the common class
class { 'sahara':
database_connection => 'mysql://sahara:a_big_secret@127.0.0.1:3306/sahara',
verbose => true,
debug => true,
keystone_username => 'admin',
keystone_password => 'secrets_everywhere',
keystone_tenant => 'admin',
keystone_url => 'http://127.0.0.1:5000/v2.0/',
identity_url => 'http://127.0.0.1:35357/',
service_host => '0.0.0.0',
service_port => 8386,
use_floating_ips => true,
}
# Finally, make it accessible
class { 'sahara::keystone::auth':
password => 'secrete',
}

View File

@ -0,0 +1,22 @@
Puppet::Type.type(:sahara_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def file_path
'/etc/sahara/sahara.conf'
end
end

View File

@ -1,32 +0,0 @@
Puppet::Type.type(:sahara_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
# the setting is always default
# this if for backwards compat with the old puppet providers for sahara_config
def section
resource[:name].split('/', 2)[0]
end
# assumes that the name was the setting
# this is to maintain backwards compat with the the older
# stuff
def setting
resource[:name].split('/', 2)[1]
end
def separator
'='
end
def self.file_path
'/etc/sahara/sahara.conf'
end
# this needs to be removed. This has been replaced with the class method
def file_path
self.class.file_path
end
end

View File

@ -1,8 +1,8 @@
Puppet::Type.newtype(:sahara_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from sahara.conf'
newvalues(/\S+\/\S+/)
end
@ -13,7 +13,6 @@ Puppet::Type.newtype(:sahara_config) do
value.capitalize! if value =~ /^(true|false)$/i
value
end
newvalues(/^[\S ]*$/)
def is_to_s(currentvalue)
if resource.secret?

21
manifests/client.pp Normal file
View File

@ -0,0 +1,21 @@
# == Class: sahara::client
#
# Installs the sahara python library.
#
# === Parameters
#
# [*package_ensure*]
# (Optional) Ensure state for package.
# Default: present.
#
class sahara::client (
$package_ensure = 'present'
) {
include sahara::params
package { 'python-saharaclient':
ensure => $package_ensure,
name => $::sahara::params::client_package_name,
}
}

View File

@ -1,83 +0,0 @@
# Copyright 2013 Zuercher Hochschule fuer Angewandte Wissenschaften
# All Rights Reserved.
#
# 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.
#
# Used to install sahara's horizon component
#
class sahara::dashboard (
$sahara_host = '127.0.0.1',
$sahara_port = '8386',
$use_neutron = false,
) {
include sahara::params
if use_neutron {
$neutron = 'True'
} else {
$neutron = 'False'
}
if !defined(Package['python-pip']) {
package { 'python-pip': ensure => latest, }
}
if $sahara::params::development {
info('Installing the developement version of sahara dashboard')
package { 'sahara-dashboard':
ensure => installed,
provider => pip,
source => $sahara::params::development_dashboard_build_url,
require => Package['python-pip'],
}
} elsif $sahara::params::rpm_install {
info('Installing RPM package of Sahara-dashboard')
package { $sahara::params::rpm_package_name_dashboard:
ensure => installed,
}
} else {
package { 'sahara-dashboard':
ensure => installed,
provider => pip,
require => Package['python-pip'],
}
}
exec { 'sahara-horizon-config':
command => "echo \"HORIZON_CONFIG['dashboards'] += ('sahara',)\" >> ${sahara::params::horizon_settings}",
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
unless => "grep \"HORIZON_CONFIG\['dashboards'\] +=\" ${sahara::params::horizon_settings}",
}
exec { 'sahara-installed-apps':
command => "echo \"INSTALLED_APPS += ('saharadashboard',)\" >> ${sahara::params::horizon_settings}",
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
unless => "grep \"INSTALLED_APPS +=\" ${sahara::params::horizon_settings}",
}
exec { 'sahara-use-neutron':
command => "echo 'SAHARA_USE_NEUTRON = ${neutron}' >> ${sahara::params::horizon_local_settings}",
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
unless => "grep \"SAHARA_USE_NEUTRON\" ${sahara::params::horizon_local_settings}",
}
exec { 'sahara-url':
command => "echo \"SAHARA_URL = 'http://${sahara_host}:${sahara_port}/v1.1'\" >> ${sahara::params::horizon_local_settings}",
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
unless => "grep \"SAHARA_URL\" ${sahara::params::horizon_local_settings}",
}
}

View File

@ -1,64 +1,58 @@
# Copyright 2013 Zuercher Hochschule fuer Angewandte Wissenschaften
# All Rights Reserved.
# == Class: sahara::db::mysql
#
# 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
# The sahara::db::mysql class creates a MySQL database for sahara.
# It must be used on the MySQL server.
#
# http://www.apache.org/licenses/LICENSE-2.0
# === Parameters
#
# 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.
# [*password*]
# (Required) Password to connect to the database.
#
# workaround for desire of python-mysqldb on RHEL
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'sahara'.
#
class mysql::bindings::python {
include mysql::params
package { 'python-mysqldb':
ensure => $mysql::params::python_package_ensure,
name => $mysql::params::python_package_name,
provider => $mysql::params::python_package_provider,
}
}
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'sahara'.
#
# Used to create the sahara db
# [*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) Charset collate of sahara database.
# Defaults to 'utf8_unicode_ci'.
#
class sahara::db::mysql(
$password = 'sahara',
$password,
$dbname = 'sahara',
$user = 'sahara',
$host = '127.0.0.1',
$allowed_hosts = undef, # ['127.0.0.1'],
$charset = 'utf8',) {
Class['mysql::server'] -> Class['sahara::db::mysql']
$allowed_hosts = undef,
$charset = 'utf8',
$collate = 'utf8_unicode_ci',
) {
require mysql::server
validate_string($password)
mysql::db { $dbname:
::openstacklib::db::mysql{ 'sahara':
user => $user,
password => $password,
password_hash => mysql_password($password),
dbname => $dbname,
host => $host,
charset => $charset,
require => Class['mysql::server::config'],
collate => $collate,
allowed_hosts => $allowed_hosts,
}
# Check allowed_hosts to avoid duplicate resource declarations
if is_array($allowed_hosts) and delete($allowed_hosts, $host) != [] {
$real_allowed_hosts = delete($allowed_hosts, $host)
} elsif is_string($allowed_hosts) and ($allowed_hosts != $host) {
$real_allowed_hosts = $allowed_hosts
}
if $real_allowed_hosts {
sahara::db::mysql::host_access { $real_allowed_hosts:
user => $user,
password => $password,
database => $dbname,
}
}
::Openstacklib::Db::Mysql['sahara'] ~> Exec<| title == 'sahara-dbmanage' |>
}

View File

@ -1,33 +0,0 @@
# Copyright 2013 Zuercher Hochschule fuer Angewandte Wissenschaften
# All Rights Reserved.
#
# 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.
#
# Used to grant access to the sahara mysql DB
#
define sahara::db::mysql::host_access ($user, $password, $database) {
database_user { "${user}@${name}":
password_hash => mysql_password($password),
provider => 'mysql',
require => Database[$database],
}
database_grant { "${user}@${name}/${database}":
# TODO figure out which privileges to grant.
privileges => 'all',
provider => 'mysql',
require => Database_user["${user}@${name}"]
}
}

View File

@ -0,0 +1,36 @@
# == Class: sahara::db:postgresql
#
# The sahara::db::postgresql creates a PostgreSQL database for sahara.
# It must be used on the PostgreSQL server.
#
# === Parameters
#
# [*password*]
# (Mandatory) Password to connect to the database.
# Defaults to 'false'.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'sahara'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'sahara'.
#
class sahara::db::postgresql (
$password,
$dbname = 'sahara',
$user = 'sahara',
) {
require postgresql::lib::python
validate_string($password)
postgresql::server::db { $dbname:
user => $user,
password => postgresql_password($user, $password),
}
PostgreSQL::Server::Db[$dbname] ~> Exec<| title == 'sahara-dbmanage' |>
Package['python-psycopg2'] -> Exec<| title == 'sahara-dbmanage' |>
}

View File

@ -1,109 +1,180 @@
# Copyright 2013 Zuercher Hochschule fuer Angewandte Wissenschaften
# All Rights Reserved.
#
# 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: sahara
#
# Installs the sahara backend.
# Sahara base package & configuration
#
# === Parameters
#
# Document parameters here.
# [*package_ensure*]
# (Optional) Ensure state for package
# Defaults to 'present'.
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
# e.g. "Specify one or more upstream ntp servers as an array."
# [*manage_service*]
# (optional) Whether the service should be managed by Puppet.
# Defaults to true.
#
# === Variables
# [*enabled*]
# (optional) Should the service be enabled.
# Defaults to true.
#
# Here you should define a list of variables that this module would require.
# [*verbose*]
# (Optional) Should the daemons log verbose messages
# Defaults to 'false'.
#
# [*debug*]
# (Optional) Should the daemons log debug messages
# Defaults to 'false'.
#
# [*service_host*]
# (Optional) Hostname for sahara to listen on
# Defaults to '0.0.0.0'.
#
# [*service_port*]
# (Optional) Port for sahara to listen on
# Defaults to 8386.
#
# [*use_neutron*]
# (Optional) Whether to use neutron
# Defaults to 'false'.
#
# [*use_floating_ips*]
# (Optional) Whether to use floating IPs to communicate with instances.
# Defaults to 'true'.
#
# [*database_connection*]
# (Optional) Non-sqllite database for sahara
# Defaults to 'mysql://sahara:secrete@localhost:3306/sahara'
#
# == keystone authentication options
#
# [*keystone_username*]
# (Optional) Username for sahara credentials
# Defaults to 'admin'.
#
# [*sahara_host*]
# The host on which the sahara process (API) runs. Defaults to '127.0.0.1'
# [*sahara_port*]
# The port on which the sahara process (API) runs on. Defaults to 3836
# [*db_host*]
# The host where the database is running. Sahara will use this to persist
# information about clusters. Defaults to '127.0.0.1'
# [*sahara_db_name*]
# [*sahara_db_password*]
# [*keystone_auth_protocol*]
# Defaults to 'http',
# [*keystone_auth_host*]
# Defaults to '127.0.0.1'
# [*keystone_auth_port*]
# Defaults to '35357'
# [*keystone_user*]
# Defaults to 'sahara'
# [*keystone_password*]
# Defaults to 'sahara'
# (Optional) Password for sahara credentials
# Defaults to false.
#
# [*keystone_tenant*]
# Defaults to undef
# [*sahara_verbose*]
# Defaults to false
# [*sahara_debug*]
# Defaults to false
# === Examples
# (Optional) Tenant for keystone_username
# Defaults to 'admin'.
#
# class{'sahara':
# sahara_host => '127.0.0.1',
# db_host => '127.0.0.1',
# sahara_db_password => 'sahara',
# keystone_auth_host => '127.0.0.1',
# keystone_password => 'admin',
# sahara_verbose => True,
#}
# [*keystone_url*]
# (Optional) Public identity endpoint
# Defaults to 'http://127.0.0.1:5000/v2.0/'.
#
# === Authors
# [*identity_url*]
# (Optional) Admin identity endpoint
# Defaults to 'http://127.0.0.1:35357/'.
#
# Andy Edmonds <andy@edmonds.be>
#
#
# TODOs
# - need to install disk builder and create image
# or generate and install
# - use a puppet type for configuration file
# - clean up documentation
class sahara(
$sahara_host = '127.0.0.1',
$sahara_port = '8386',
$sahara_verbose = false,
$sahara_debug = false,
# db
$db_host = '127.0.0.1',
$sahara_db_name = 'sahara',
$sahara_db_user = 'sahara',
$sahara_db_password = 'sahara',
# keystone
$keystone_auth_protocol = 'http',
$keystone_auth_host = '127.0.0.1',
$keystone_auth_port = '35357',
$keystone_user = 'sahara',
$keystone_password = 'sahara',
$keystone_tenant = undef,) {
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$verbose = false,
$debug = false,
$service_host = '0.0.0.0',
$service_port = 8386,
$use_neutron = false,
$use_floating_ips = true,
$database_connection = 'mysql://sahara:secrete@localhost:3306/sahara',
$keystone_username = 'admin',
$keystone_password = false,
$keystone_tenant = 'admin',
$keystone_url = 'http://127.0.0.1:5000/v2.0/',
$identity_url = 'http://127.0.0.1:35357/',
) {
include sahara::params
# move keystone and db classes here?
file { '/etc/sahara/':
ensure => directory,
owner => 'root',
group => 'sahara',
mode => '0750',
require => Package['sahara'],
}
if !$keystone_tenant {
$int_keystone_tenant = $keystone_user
file { '/etc/sahara/sahara.conf':
owner => 'root',
group => 'sahara',
mode => '0640',
require => File['/etc/sahara'],
}
package { 'sahara':
ensure => $package_ensure,
name => $::sahara::params::package_name,
}
Package['sahara'] -> Sahara_config<||>
Package['sahara'] ~> Service['sahara']
validate_re($database_connection, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
case $database_connection {
/^mysql:\/\//: {
require mysql::bindings
require mysql::bindings::python
}
/^postgresql:\/\//: {
require postgresql::lib::python
}
/^sqlite:\/\//: {
fail('Sahara does not support sqlite!')
}
default: {
fail('Unsupported db backend configured')
}
}
sahara_config {
'DEFAULT/use_neutron': value => $use_neutron;
'DEFAULT/use_floating_ips': value => $use_floating_ips;
'DEFAULT/host': value => $service_host;
'DEFAULT/port': value => $service_port;
'DEFAULT/debug': value => $debug;
'DEFAULT/verbose': value => $verbose;
'database/connection':
value => $database_connection,
secret => true;
}
if $keystone_password {
sahara_config {
'keystone_authtoken/auth_uri': value => $keystone_url;
'keystone_authtoken/identity_uri': value => $identity_url;
'keystone_authtoken/admin_user': value => $keystone_username;
'keystone_authtoken/admin_tenant_name': value => $keystone_tenant;
'keystone_authtoken/admin_password':
value => $keystone_password,
secret => true;
}
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$int_keystone_tenant = $keystone_tenant
$service_ensure = 'stopped'
}
}
service { 'sahara':
ensure => $service_ensure,
name => $::sahara::params::service_name,
hasstatus => true,
enable => $enabled,
hasrestart => true,
subscribe => Exec['sahara-dbmanage'],
}
exec { 'sahara-dbmanage':
command => $::sahara::params::dbmanage_command,
path => '/usr/bin',
user => 'root',
refreshonly => true,
subscribe => [Package['sahara'],Sahara_config['database/connection']],
logoutput => on_failure,
}
class { '::sahara::install':
} ->
class { '::sahara::service': }
}

View File

@ -1,173 +0,0 @@
# Copyright 2013 Zuercher Hochschule fuer Angewandte Wissenschaften
# All Rights Reserved.
#
# 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 sahara::install {
include sahara::params
# this is here until this fix is released
# https://bugs.launchpad.net/ubuntu/+source/python-pbr/+bug/1245676
if !defined(Package['git']) {
package { 'git': ensure => latest, }
}
if !defined(Package['python-pip']) {
package { 'python-pip':
ensure => latest,
require => Package['git']
}
}
if $::osfamily == 'Debian' {
if !defined(Package['python-dev']) {
package { 'python-dev':
ensure => latest,
require => Package['python-pip']
}
}
} elsif $::osfamily == 'Redhat' {
if !defined(Package['python-devel']) {
package { 'python-devel':
ensure => latest,
require => Package['python-pip']
}
}
if !defined(Package['python-jinja2']) {
package { 'python-jinja2':
ensure => latest,
require => Package['python-pip']
}
}
}
if $sahara::params::development {
info("Installing and using the sahara development version. URL:
${sahara::params::development_build_url}")
package { 'sahara':
ensure => installed,
provider => pip,
source => $sahara::params::development_build_url,
require => Package['python-pip'],
}
} elsif $sahara::params::rpm_install {
info('Installing RPM package of Sahara')
package { $sahara::params::rpm_package_name_service:
ensure => installed,
}
} else {
package { 'sahara':
ensure => installed,
provider => pip,
require => Package['python-pip'],
}
}
group { 'sahara':
ensure => present,
system => true,
} ->
user { 'sahara':
ensure => present,
gid => 'sahara',
system => true,
home => '/var/lib/sahara',
shell => '/bin/false'
} ->
file { '/var/lib/sahara':
ensure => 'directory',
owner => 'sahara',
group => 'sahara',
mode => '0750',
} ->
file { '/var/log/sahara':
ensure => 'directory',
owner => 'sahara',
group => 'sahara',
mode => '0750',
} ->
file { '/var/log/sahara/sahara.log':
ensure => 'file',
owner => 'sahara',
group => 'sahara',
mode => '0640',
} ->
file { '/etc/sahara':
ensure => 'directory',
owner => 'sahara',
group => 'sahara',
mode => '0750',
} ->
file { '/etc/sahara/sahara.conf':
ensure => file,
path => '/etc/sahara/sahara.conf',
content => template('sahara/sahara.conf.erb'),
owner => 'sahara',
group => 'sahara',
mode => '0640',
}
if $::osfamily == 'Debian' {
file { '/etc/init.d/sahara-api':
ensure => file,
path => '/etc/init.d/sahara-api',
content => template('sahara/sahara-api.erb'),
mode => '0750',
owner => 'root',
group => 'root',
} ->
file { '/etc/sahara/sahara-api.conf':
ensure => file,
path => '/etc/init/sahara-api.conf',
content => template('sahara/sahara-api.conf.erb'),
mode => '0750',
owner => 'root',
group => 'root',
notify => Service['sahara-api'],
}
} elsif $::osfamily == 'Redhat' {
file { '/etc/init.d/sahara-api':
ensure => file,
path => '/etc/init.d/sahara-api',
content => template('sahara/sahara-api-redhat.erb'),
mode => '0750',
owner => 'root',
group => 'root',
} ->
file { '/etc/sahara/sahara-api.conf':
ensure => file,
path => '/etc/init/sahara-api.conf',
content => template('sahara/sahara-api.conf.erb'),
mode => '0750',
owner => 'root',
group => 'root',
notify => Service['sahara-api'],
} ->
file { '/var/run/sahara':
ensure => 'directory',
owner => 'sahara',
group => 'root',
mode => '0750',
}
} else {
error('Sahara cannot be installed on this operating system.
It does not have the supported initscripts. There is only
support for Debian and Red Hat-based systems.')
}
info('Creating database schema, latest version')
exec { 'sahara-db-manage':
command => '/usr/bin/sahara-db-manage upgrade head'
}
}

View File

@ -1,41 +1,105 @@
# Copyright 2013 Zuercher Hochschule fuer Angewandte Wissenschaften
# All Rights Reserved.
# == Class: sahara::keystone::auth
#
# 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
# Configures sahara service and endpoint in Keystone.
#
# http://www.apache.org/licenses/LICENSE-2.0
# === Parameters
#
# 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.
# [*password*]
# (required) Password for Sahara user.
#
# Used to setup the sahara keystone user
# [*service_name*]
# (Optional) Name of the service.
# Defaults to the value of auth_name.
#
# [*auth_name*]
# (Optional) Username for sahara service.
# Defaults to 'sahara'.
#
# [*email*]
# (Optional) Email for Sahara user.
# Defaults to 'sahara@localhost'.
#
# [*tenant*]
# (Optional) Tenant for Sahara user.
# Defaults to 'services'.
#
# [*configure_endpoint*]
# (Optional) Should Sahara endpoint be configured?
# Defaults to 'true'.
#
# [*service_type*]
# (Optional) Type of service.
# Defaults to 'data-processing'.
#
# [*service_description*]
# (Optional) Description of service.
# Defaults to 'Sahara Data Processing'.
#
# [*region*]
# (Optional) Region for endpoint.
# Defaults to 'RegionOne'.
#
# [*public_protocol*]
# (Optional) Protocol for public endpoint.
# Defaults to 'http'.
#
# [*admin_protocol*]
# (Optional) Protocol for admin endpoint.
# Defaults to 'http'.
#
# [*internal_protocol*]
# (Optional) Protocol for internal endpoint.
# Defaults to 'http'.
#
# [*public_address*]
# (Optional) Public address for endpoint.
# Defaults to '127.0.0.1'.
#
# [*admin_address*]
# (Optional) Admin address for endpoint.
# Defaults to '127.0.0.1'.
#
# [*internal_address*]
# (Optional) Internal address for endpoint.
# Defaults to '127.0.0.1'.
#
# [*port*]
# (Optional) Port for endpoint.
# Defaults to '8386'.
#
# [*public_port*]
# Port for public endpoint. Defaults to $port.
#
# [*version*]
# (Optional) Version of API to use.
# Defaults to 'v1.1'.
#
class sahara::keystone::auth(
$password = 'sahara',
$password,
$service_name = undef,
$auth_name = 'sahara',
$email = 'sahara@localhost',
$tenant = 'services',
$service_type = 'data-processing',
$service_description = 'Sahara Data Processing',
$configure_endpoint = true,
$service_type = 'data_processing',
$region = 'RegionOne',
$public_protocol = 'http',
$admin_protocol = 'http',
$internal_protocol = 'http',
$public_address = '127.0.0.1',
$admin_address = '127.0.0.1',
$internal_address = '127.0.0.1',
$port = '8386',
$public_port = undef,
$region = 'RegionOne',
$public_protocol = 'http',
$internal_protocol = 'http',
$version = 'v1.1',
) {
Keystone_user_role["${auth_name}@${tenant}"] ~>
Service <| name == 'sahara-api' |>
if $service_name == undef {
$real_service_name = $auth_name
} else {
$real_service_name = $service_name
}
if ! $public_port {
$real_public_port = $port
@ -43,19 +107,19 @@ class sahara::keystone::auth (
$real_public_port = $public_port
}
keystone::resource::service_identity { $auth_name:
keystone::resource::service_identity { $real_service_name:
configure_user => true,
configure_user_role => true,
configure_endpoint => $configure_endpoint,
service_type => $service_type,
service_description => 'Openstack Data Processing',
service_description => $service_description,
region => $region,
password => $password,
email => $email,
tenant => $tenant,
public_url => "${public_protocol}://${public_address}:${real_public_port}/",
internal_url => "${internal_protocol}://${internal_address}:${port}/",
admin_url => "${internal_protocol}://${admin_address}:${port}/",
public_url => "${public_protocol}://${public_address}:${real_public_port}/${version}/%(tenant_id)s",
admin_url => "${admin_protocol}://${admin_address}:${port}/${version}/%(tenant_id)s",
internal_url => "${internal_protocol}://${internal_address}:${port}/${version}/%(tenant_id)s",
}
}

150
manifests/notify/qpid.pp Normal file
View File

@ -0,0 +1,150 @@
# == Class: sahara::notify::qpid
#
# Qpid broker configuration for Sahara
#
# === Parameters
#
# [*durable_queues*]
# (Optional) Use durable queues in broker.
# Defaults to false.
#
# [*qpid_hostname*]
# (Optional) IP or hostname of the qpid server.
# Defaults to '127.0.0.1'.
#
# [*qpid_port*]
# (Optional) Port of the qpid server.
# Defaults to 5672.
#
# [*qpid_username*]
# (Optional) User to connect to the qpid server.
# Defaults to 'guest'.
#
# [*qpid_password*]
# (Optional) Password to connect to the qpid server.
# Defaults to 'guest'.
#
# [*qpid_sasl_mechanisms*]
# (Optional) String of SASL mechanisms to use.
# Defaults to ''.
#
# [*qpid_heartbeat*]
# (Optional) Seconds between connection keepalive heartbeats.
# Defaults to 60.
#
# [*qpid_protocol*]
# (Optional) Protocol to use for qpid (tcp/ssl).
# Defaults to tcp.
#
# [*qpid_tcp_nodelay*]
# (Optional) Whether to disable the Nagle algorithm.
# Defaults to true.
#
# [*qpid_receiver_capacity*]
# (Optional) Number of prefetched messages to hold.
# Defaults to 1.
#
# [*qpid_topology_version*]
# (Optional) Version of qpid toplogy to use.
# Defaults to 2.
#
# [*notification_topics*]
# (Optional) Topic to use for notifications.
# Defaults to 'notifications'.
#
# [*control_exchange*]
# (Optional) The default exchange to scope topics.
# Defaults to 'openstack'.
#
# [*kombu_ssl_version*]
# (optional) SSL version to use (valid only if SSL enabled).
# Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be
# available on some distributions.
# Defaults to 'TLSv1'
#
# [*kombu_ssl_keyfile*]
# (Optional) SSL key file (valid only if SSL enabled).
# Defaults to undef.
#
# [*kombu_ssl_certfile*]
# (Optional) SSL cert file (valid only if SSL enabled).
# Defaults to undef.
#
# [*kombu_ssl_ca_certs*]
# (optional) SSL certification authority file (valid only if SSL enabled).
# Defaults to undef.
#
# [*kombu_reconnect_delay*]
# (Optional) Backoff on cancel notification (valid only if SSL enabled).
# Defaults to '1.0'; floating-point value.
#
class sahara::notify::qpid(
$durable_queues = false,
$qpid_hostname = 'localhost',
$qpid_port = 5672,
$qpid_username = 'guest',
$qpid_password = 'guest',
$qpid_sasl_mechanisms = '',
$qpid_heartbeat = 60,
$qpid_protocol = 'tcp',
$qpid_tcp_nodelay = true,
$qpid_receiver_capacity = 1,
$qpid_topology_version = 2,
$notification_topics = 'notifications',
$control_exchange = 'openstack',
$kombu_ssl_version = 'TLSv1',
$kombu_ssl_keyfile = undef,
$kombu_ssl_certfile = undef,
$kombu_ssl_ca_certs = undef,
$kombu_reconnect_delay = '1.0',
) {
if $qpid_protocol == 'ssl' {
if !$kombu_ssl_keyfile {
fail('kombu_ssl_keyfile must be set when using SSL in qpid')
}
if !$kombu_ssl_certfile {
fail('kombu_ssl_certfile must be set when using SSL in qpid')
}
if !$kombu_ssl_ca_certs {
fail('kombu_ca_certs must be set when using SSL in qpid')
}
sahara_config {
'DEFAULT/kombu_ssl_version': value => $kombu_ssl_version;
'DEFAULT/kombu_ssl_keyfile': value => $kombu_ssl_keyfile;
'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile;
'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs;
'DEFAULT/kombu_reconnect_delay': value => $kombu_reconnect_delay;
}
} elsif $qpid_protocol == 'tcp' {
sahara_config {
'DEFAULT/kombu_ssl_version': ensure => absent;
'DEFAULT/kombu_ssl_keyfile': ensure => absent;
'DEFAULT/kombu_ssl_certfile': ensure => absent;
'DEFAULT/kombu_ssl_ca_certs': ensure => absent;
'DEFAULT/kombu_reconnect_delay': ensure => absent;
}
} else {
fail("valid qpid_protocol settings are 'tcp' and 'ssl' only")
}
sahara_config {
'DEFAULT/rpc_backend': value => 'qpid';
'DEFAULT/qpid_hosts': value => '$qpid_hostname:$qpid_port';
'DEFAULT/amqp_durable_queues': value => $durable_queues;
'DEFAULT/qpid_hostname': value => $qpid_hostname;
'DEFAULT/qpid_port': value => $qpid_port;
'DEFAULT/qpid_username': value => $qpid_username;
'DEFAULT/qpid_password':
value => $qpid_password,
secret => true;
'DEFAULT/qpid_sasl_mechanisms': value => $qpid_sasl_mechanisms;
'DEFAULT/qpid_heartbeat': value => $qpid_heartbeat;
'DEFAULT/qpid_protocol': value => $qpid_protocol;
'DEFAULT/qpid_tcp_nodelay': value => $qpid_tcp_nodelay;
'DEFAULT/qpid_receiver_capacity': value => $qpid_receiver_capacity;
'DEFAULT/qpid_topology_version': value => $qpid_topology_version;
'DEFAULT/notification_topics': value => $notification_topics;
'DEFAULT/control_exchange': value => $control_exchange;
}
}

View File

@ -0,0 +1,165 @@
# == Class: sahara::notify::rabbitmq
#
# RabbitMQ broker configuration for Sahara
#
# === Parameters
#
# [*durable_queues*]
# (Optional) Use durable queues in broker.
# Defaults to false.
#
# [*rabbit_host*]
# (Optional) IP or hostname of the rabbit server.
# Defaults to '127.0.0.1'.
#
# [*rabbit_port*]
# (Optional) Port of the rabbit server.
# Defaults to 5672.
#
# [*rabbit_hosts*]
# (Optional) IP or hostname of the rabbits servers.
# comma separated array (ex: ['1.0.0.10:5672','1.0.0.11:5672'])
# Defaults to false.
#
# [*rabbit_use_ssl*]
# (Optional) Connect over SSL for RabbitMQ.
# Defaults to false.
#
# [*rabbit_userid*]
# (Optional) User to connect to the rabbit server.
# Defaults to 'guest'.
#
# [*rabbit_password*]
# (Optional) Password to connect to the rabbit server.
# Defaults to 'guest'.
#
# [*rabbit_login_method*]
# (Optional) Method to auth with the rabbit server.
# Defaults to 'AMQPLAIN'.
#
# [*rabbit_virtual_host*]
# (Optional) Virtual host to use.
# Defaults to '/'.
#
# [*rabbit_retry_interval*]
# (Optional) Reconnection attempt frequency for rabbit.
# Defaults to 1.
#
# [*rabbit_retry_backoff*]
# (Optional) Backoff between reconnection attempts for rabbit.
# Defaults to 2.
#
# [*rabbit_max_retries*]
# (Optional) Number of times to retry (0 == no limit).
# Defaults to 0.
#
# [*notification_topics*]
# (Optional) Topic to use for notifications.
# Defaults to 'notifications'.
#
# [*control_exchange*]
# (Optional) The default exchange to scope topics.
# Defaults to 'openstack'.
#
# [*kombu_ssl_version*]
# (optional) SSL version to use (valid only if SSL enabled).
# Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be
# available on some distributions.
# Defaults to 'TLSv1'
#
# [*kombu_ssl_keyfile*]
# (Optional) SSL key file (valid only if SSL enabled).
# Defaults to undef.
#
# [*kombu_ssl_certfile*]
# (Optional) SSL cert file (valid only if SSL enabled).
# Defaults to undef.
#
# [*kombu_ssl_ca_certs*]
# (Optional) SSL certification authority file (valid only if SSL enabled).
# Defaults to undef
#
# [*kombu_reconnect_delay*]
# (Optional) Backoff on cancel notification (valid only if SSL enabled).
# Defaults to '1.0'; floating-point value.
#
class sahara::notify::rabbitmq(
$durable_queues = false,
$rabbit_host = 'localhost',
$rabbit_hosts = false,
$rabbit_port = 5672,
$rabbit_use_ssl = false,
$rabbit_userid = 'guest',
$rabbit_password = 'guest',
$rabbit_login_method = 'AMQPLAIN',
$rabbit_virtual_host = '/',
$rabbit_retry_interval = 1,
$rabbit_retry_backoff = 2,
$rabbit_max_retries = 0,
$notification_topics = 'notifications',
$control_exchange = 'openstack',
$kombu_ssl_version = 'TLSv1',
$kombu_ssl_keyfile = undef,
$kombu_ssl_certfile = undef,
$kombu_ssl_ca_certs = undef,
$kombu_reconnect_delay = '1.0',
) {
if $rabbit_use_ssl {
if !$kombu_ssl_keyfile {
fail('kombu_ssl_keyfile must be set when using SSL in rabbit')
}
if !$kombu_ssl_certfile {
fail('kombu_ssl_certfile must be set when using SSL in rabbit')
}
if !$kombu_ssl_ca_certs {
fail('kombu_ssl_ca_certs must be set when using SSL in rabbit')
}
sahara_config {
'DEFAULT/kombu_ssl_version': value => $kombu_ssl_version;
'DEFAULT/kombu_ssl_keyfile': value => $kombu_ssl_keyfile;
'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile;
'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs;
'DEFAULT/kombu_reconnect_delay': value => $kombu_reconnect_delay;
}
} else {
sahara_config {
'DEFAULT/kombu_ssl_version': ensure => absent;
'DEFAULT/kombu_ssl_keyfile': ensure => absent;
'DEFAULT/kombu_ssl_certfile': ensure => absent;
'DEFAULT/kombu_ssl_ca_certs': ensure => absent;
'DEFAULT/kombu_reconnect_delay': ensure => absent;
}
}
if $rabbit_hosts {
sahara_config {
'DEFAULT/rabbit_hosts': value => join($rabbit_hosts, ',');
'DEFAULT/rabbit_ha_queues': value => true
}
} else {
sahara_config {
'DEFAULT/rabbit_host': value => $rabbit_host;
'DEFAULT/rabbit_port': value => $rabbit_port;
'DEFAULT/rabbit_ha_queues': value => false;
# single-quotes to get literal dollar signs
'DEFAULT/rabbit_hosts': value => '$rabbit_host:$rabbit_port';
}
}
sahara_config {
'DEFAULT/rpc_backend': value => 'rabbit';
'DEFAULT/amqp_durable_queues': value => $durable_queues;
'DEFAULT/rabbit_use_ssl': value => $rabbit_use_ssl;
'DEFAULT/rabbit_userid': value => $rabbit_userid;
'DEFAULT/rabbit_password':
value => $rabbit_password,
secret => true;
'DEFAULT/rabbit_login_method': value => $rabbit_login_method;
'DEFAULT/rabbit_virtual_host': value => $rabbit_virtual_host;
'DEFAULT/rabbit_retry_interval': value => $rabbit_retry_interval;
'DEFAULT/rabbit_retry_backoff': value => $rabbit_retry_backoff;
'DEFAULT/rabbit_max_retries': value => $rabbit_max_retries;
'DEFAULT/notification_topics': value => $notification_topics;
'DEFAULT/control_exchange': value => $control_exchange;
}
}

108
manifests/notify/zeromq.pp Normal file
View File

@ -0,0 +1,108 @@
# == Class: sahara::notify::zeromq
#
# Zeromq broker configuration for Sahara
#
# === Parameters
#
# [*zeromq_bind_address*]
# (Optional) Bind address; wildcard, ethernet, or ip address.
# Defaults to '*'.
#
# [*zeromq_port*]
# (Optional) Receiver listening port.
# Defaults to 9501.
#
# [*zeromq_contexts*]
# (Optional) Number of contexsts for zeromq.
# Defaults to 1.
#
# [*zeromq_topic_backlog*]
# (Optional) Number of incoming messages to buffer.
# Defaults to 'None'.
#
# [*zeromq_ipc_dir*]
# (Optional) Directory for zeromq IPC.
# Defaults to '/var/run/openstack'.
#
# [*zeromq_host*]
# (Optional) Name of the current node: hostname, FQDN, or IP.
# Defaults to 'sahara'.
#
# [*cast_timeout*]
# (Optional) TTL for zeromq messages.
# Defaults to 30.
#
# [*kombu_ssl_version*]
# (optional) SSL version to use (valid only if SSL enabled).
# Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be
# available on some distributions.
# Defaults to 'TLSv1'
#
# [*kombu_ssl_keyfile*]
# (Optional) SSL key file (valid only if SSL enabled).
# Defaults to undef.
#
# [*kombu_ssl_certfile*]
# (Optional) SSL cert file (valid only if SSL enabled).
# Defaults to undef.
#
# [*kombu_ssl_ca_certs*]
# (optional) SSL certification authority file (valid only if SSL enabled).
# Defaults to undef.
#
# [*kombu_reconnect_delay*]
# (Optional) Backoff on cancel notification (valid only if SSL enabled).
# Defaults to '1.0'; floating-point value.
#
class sahara::notify::zeromq(
$zeromq_bind_address = '*',
$zeromq_port = 9501,
$zeromq_contexts = 1,
$zeromq_topic_backlog = 'None',
$zeromq_ipc_dir = '/var/run/openstack',
$zeromq_host = 'sahara',
$cast_timeout = 30,
$kombu_ssl_version = 'TLSv1',
$kombu_ssl_keyfile = undef,
$kombu_ssl_certfile = undef,
$kombu_ssl_ca_certs = undef,
$kombu_reconnect_delay = '1.0',
) {
if $kombu_ssl_keyfile or $kombu_ssl_certfile or $kombu_ssl_ca_certs {
if !$kombu_ssl_keyfile {
fail('kombu_ssl_keyfile must be set when using SSL in zeromq')
}
if !$kombu_ssl_certfile {
fail('kombu_ssl_certfile must be set when using SSL in zeromq')
}
if !$kombu_ssl_ca_certs {
fail('kombu_ca_certs must be set when using SSL in zeromq')
}
sahara_config {
'DEFAULT/kombu_ssl_version': value => $kombu_ssl_version;
'DEFAULT/kombu_ssl_keyfile': value => $kombu_ssl_keyfile;
'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile;
'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs;
'DEFAULT/kombu_reconnect_delay': value => $kombu_reconnect_delay;
}
} else {
sahara_config {
'DEFAULT/kombu_ssl_version': ensure => absent;
'DEFAULT/kombu_ssl_keyfile': ensure => absent;
'DEFAULT/kombu_ssl_certfile': ensure => absent;
'DEFAULT/kombu_ssl_ca_certs': ensure => absent;
'DEFAULT/kombu_reconnect_delay': ensure => absent;
}
}
sahara_config {
'DEFAULT/rpc_backend': value => 'zmq';
'DEFAULT/rpc_zmq_bind_address': value => $zeromq_bind_address;
'DEFAULT/rpc_zmq_port': value => $zeromq_port;
'DEFAULT/rpc_zmq_contexts': value => $zeromq_contexts;
'DEFAULT/rpc_zmq_topic_backlog': value => $zeromq_topic_backlog;
'DEFAULT/rpc_zmq_ipc_dir': value => $zeromq_ipc_dir;
'DEFAULT/rpc_zmq_host': value => $zeromq_host;
'DEFAULT/rpc_cast_timeout': value => $cast_timeout;
}
}

View File

@ -1,42 +1,31 @@
# Copyright 2013 Zuercher Hochschule fuer Angewandte Wissenschaften
# All Rights Reserved.
# == Class: sahara::params
#
# 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
# Parameters for puppet-sahara
#
# 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 sahara::params {
$sys_rundir = '/var/run'
$sahara_service = 'sahara-api'
$sahara_logdir = '/var/log/sahara'
$sahara_rundir = '/var/run/sahara'
$sahara_lockdir = '/var/lock/sahara'
$sahara_conf_file = '/etc/sahara/sahara.conf'
$sahara_syslog = false
$sahara_usefips = false
$sahara_node_domain = 'novalocal'
# installs source version from github builds
$development = false
$development_build_url =
'http://tarballs.openstack.org/sahara/sahara-master.tar.gz'
$development_dashboard_build_url =
'http://tarballs.openstack.org/sahara-dashboard/sahara-dashboard-master.tar.gz'
$dbmanage_command = 'sahara-db-manage --config-file /etc/sahara/sahara.conf upgrade head'
$client_package_name = 'python-saharaclient'
$rpm_install = false
$rpm_package_name_service = 'openstack-sahara'
$rpm_package_name_dashboard = 'python-django-sahara'
# these two paths are OS specific - on redhat they're diff
$horizon_settings =
'/usr/share/openstack-dashboard/openstack_dashboard/settings.py'
$horizon_local_settings =
'/usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py'
case $::osfamily {
'RedHat': {
$package_name = 'openstack-sahara'
$service_name = 'openstack-sahara-all'
}
'Debian': {
case $::operatingsystem {
'Debian': {
$package_name = 'sahara'
$service_name = 'sahara'
}
default: {
fail('While Sahara is packaged in Debian, it is not packaged in \
Ubuntu or any derivatives (yet). If you would like to package \
Sahara for this system, please contact the Sahara team.')
}
}
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}")
}
}
}

View File

@ -1,23 +0,0 @@
# Copyright 2013 Zuercher Hochschule fuer Angewandte Wissenschaften
# All Rights Reserved.
#
# 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 sahara::service ($enable = true,) {
service { 'sahara-api':
ensure => running,
enable => $enable,
hasrestart => true,
hasstatus => true,
}
}

View File

@ -1,9 +1,9 @@
{
"name": "stackforge-sahara",
"version": "5.0.0",
"author": "StackForge Contributors",
"author": "Red Hat and StackForge Contributors",
"summary": "Puppet module for OpenStack Sahara",
"license": "Apache License 2.0",
"license": "Apache-2.0",
"source": "git://github.com/stackforge/puppet-sahara.git",
"project_page": "https://launchpad.net/puppet-sahara",
"issues_url": "https://bugs.launchpad.net/puppet-sahara",
@ -13,22 +13,25 @@
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": ["7"]
"operatingsystem": "Fedora",
"operatingsystemrelease": ["20"]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": ["6.5","7"]
"operatingsystemrelease": ["7"]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": ["14.04"]
"operatingsystem": "Debian",
"operatingsystemrelease": ["8"]
}
],
"description": "Installs and configures OpenStack Sahara (Data Processing).",
"dependencies": [
{ "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" },
{ "name": "duritong/sysctl", "version_requirement": ">=0.0.1 <1.0.0" },
{ "name": "stackforge/keystone", "version_requirement": ">=5.0.0 <6.0.0" },
{ "name": "puppetlabs/inifile", "version_requirement": ">=5.0.0 <6.0.0" },
{ "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" },
{ "name": "puppetlabs/postgresql", "version_requirement": ">=3.0.0" },
{ "name": "stackforge/openstacklib", "version_requirement": ">=5.0.0" }
]
}

View File

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

View File

@ -0,0 +1,92 @@
#
# Unit tests for sahara::db::mysql
#
require 'spec_helper'
describe 'sahara::db::mysql' do
let :pre_condition do
['include mysql::server']
end
let :params do
{ :dbname => 'sahara',
:password => 's3cr3t',
:user => 'sahara',
:charset => 'utf8',
:collate => 'utf8_unicode_ci',
:host => '127.0.0.1',
}
end
shared_examples_for 'sahara mysql database' do
context 'when omiting the required parameter password' do
before { params.delete(:password) }
it { expect { should raise_error(Puppet::Error) } }
end
it 'creates a mysql database' do
should contain_openstacklib__db__mysql('sahara').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 {
should contain_openstacklib__db__mysql('sahara').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 {
should contain_openstacklib__db__mysql('sahara').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 'sahara mysql database'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'sahara mysql database'
end
end

View File

@ -0,0 +1,26 @@
require 'spec_helper'
describe 'sahara::db::postgresql' do
let :req_params do
{:password => 'pw'}
end
let :facts do
{
:operatingsystemrelease => '6.5',
:osfamily => 'RedHat',
}
end
describe 'with only required params' do
let :params do
req_params
end
it { should contain_postgresql__server__db('sahara').with(
:user => 'sahara',
:password => 'md59b1dd0cc439677764ef5a848112ef0ab'
) }
end
end

View File

@ -0,0 +1,49 @@
#
# Unit tests for sahara::init
#
require 'spec_helper'
describe 'sahara' do
let :params do
{
:keystone_password => 'secrete'
}
end
shared_examples_for 'sahara' do
it { should contain_class('sahara::params') }
it { should contain_class('mysql::bindings::python') }
it { should contain_exec('sahara-dbmanage') }
end
context 'on Debian platforms' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian'
}
end
it_configures 'sahara'
it_behaves_like 'generic sahara service', {
:name => 'sahara',
:package_name => 'sahara',
:service_name => 'sahara' }
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'sahara'
it_behaves_like 'generic sahara service', {
:name => 'sahara',
:package_name => 'openstack-sahara',
:service_name => 'openstack-sahara-all' }
end
end

View File

@ -0,0 +1,84 @@
#
# Unit tests for sahara::keystone::auth
#
require 'spec_helper'
describe 'sahara::keystone::auth' do
let :facts do
{ :osfamily => 'Debian' }
end
describe 'with default class parameters' do
let :params do
{ :password => 'sahara_password',
:tenant => 'foobar' }
end
it { should contain_keystone_user('sahara').with(
:ensure => 'present',
:password => 'sahara_password',
:tenant => 'foobar'
) }
it { should contain_keystone_user_role('sahara@foobar').with(
:ensure => 'present',
:roles => 'admin'
)}
it { should contain_keystone_service('sahara').with(
:ensure => 'present',
:type => 'data-processing',
:description => 'Sahara Data Processing'
) }
it { should contain_keystone_endpoint('RegionOne/sahara').with(
:ensure => 'present',
:public_url => "http://127.0.0.1:8386/v1.1/%(tenant_id)s",
:admin_url => "http://127.0.0.1:8386/v1.1/%(tenant_id)s",
:internal_url => "http://127.0.0.1:8386/v1.1/%(tenant_id)s"
) }
end
describe 'when configuring sahara-server' do
let :pre_condition do
"class { 'sahara::server': auth_password => 'test' }"
end
let :params do
{ :password => 'sahara_password',
:tenant => 'foobar' }
end
end
describe 'when overriding public_protocol, public_port and public address' do
let :params do
{ :password => 'sahara_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 { should contain_keystone_endpoint('RegionOne/sahara').with(
:ensure => 'present',
:public_url => "https://10.10.10.10:80/v1.1/%(tenant_id)s",
:internal_url => "http://10.10.10.11:81/v1.1/%(tenant_id)s",
:admin_url => "http://10.10.10.12:81/v1.1/%(tenant_id)s"
) }
end
describe 'when overriding auth name' do
let :params do
{ :password => 'foo',
:auth_name => 'saharay' }
end
it { should contain_keystone_user('saharay') }
it { should contain_keystone_user_role('saharay@services') }
it { should contain_keystone_service('saharay') }
it { should contain_keystone_endpoint('RegionOne/saharay') }
end
end

View File

@ -0,0 +1,58 @@
require 'spec_helper'
describe 'sahara::notify::qpid' do
let :facts do
{
:osfamily => 'Debian'
}
end
describe 'when default params and qpid_password' do
let :params do
{:qpid_password => 'pass'}
end
it { should contain_sahara_config('DEFAULT/qpid_username').with_value('guest') }
it { should contain_sahara_config('DEFAULT/qpid_password').with_value('pass') }
it { should contain_sahara_config('DEFAULT/qpid_password').with_value(params[:qpid_password]).with_secret(true) }
it { should contain_sahara_config('DEFAULT/qpid_hostname').with_value('localhost') }
it { should contain_sahara_config('DEFAULT/qpid_port').with_value('5672') }
it { should contain_sahara_config('DEFAULT/qpid_protocol').with_value('tcp') }
end
describe 'when passing params' do
let :params do
{
:qpid_password => 'pass2',
:qpid_username => 'guest2',
:qpid_hostname => 'localhost2',
:qpid_port => '5673'
}
end
it { should contain_sahara_config('DEFAULT/qpid_username').with_value('guest2') }
it { should contain_sahara_config('DEFAULT/qpid_hostname').with_value('localhost2') }
it { should contain_sahara_config('DEFAULT/qpid_port').with_value('5673') }
it { should contain_sahara_config('DEFAULT/qpid_protocol').with_value('tcp') }
end
describe 'when configuring with ssl' do
let :params do
{
:qpid_password => 'pass3',
:qpid_username => 'guest3',
:qpid_hostname => 'localhost3',
:qpid_port => '5671',
:qpid_protocol => 'ssl',
:kombu_ssl_keyfile => '/srv/sahara_ssl.key',
:kombu_ssl_certfile => '/srv/sahara_ssl.crt',
:kombu_ssl_ca_certs => '/srv/cacert',
}
end
it { should contain_sahara_config('DEFAULT/qpid_username').with_value('guest3') }
it { should contain_sahara_config('DEFAULT/qpid_hostname').with_value('localhost3') }
it { should contain_sahara_config('DEFAULT/qpid_port').with_value('5671') }
it { should contain_sahara_config('DEFAULT/qpid_protocol').with_value('ssl') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_keyfile').with_value('/srv/sahara_ssl.key') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_certfile').with_value('/srv/sahara_ssl.crt') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_ca_certs').with_value('/srv/cacert') }
end
end

View File

@ -0,0 +1,120 @@
require 'spec_helper'
describe 'sahara::notify::rabbitmq' do
let :facts do
{
:osfamily => 'Debian'
}
end
describe 'when defaults with rabbit pass specified' do
let :params do
{:rabbit_password => 'pass'}
end
it { should contain_sahara_config('DEFAULT/rabbit_password').with_value('pass') }
it { should contain_sahara_config('DEFAULT/rabbit_password').with_value(params[:rabbit_password]).with_secret(true) }
it { should contain_sahara_config('DEFAULT/rabbit_userid').with_value('guest') }
it { should contain_sahara_config('DEFAULT/rabbit_host').with_value('localhost') }
it { should contain_sahara_config('DEFAULT/rabbit_port').with_value('5672') }
xit { should contain_sahara_config('DEFAULT/rabbit_hosts').with_value('localhost:5672') }
it { should contain_sahara_config('DEFAULT/rabbit_ha_queues').with_value('false') }
it { should contain_sahara_config('DEFAULT/amqp_durable_queues').with_value('false') }
it { should contain_sahara_config('DEFAULT/rabbit_virtual_host').with_value('/') }
it { should contain_sahara_config('DEFAULT/control_exchange').with_value('openstack') }
it { should contain_sahara_config('DEFAULT/notification_topics').with_value('notifications') }
end
describe 'when passing params' do
let :params do
{
:rabbit_password => 'pass',
:rabbit_userid => 'guest2',
:rabbit_host => 'localhost2',
:rabbit_port => '5673',
:durable_queues => true,
}
it { should contain_sahara_config('DEFAULT/rabbit_userid').with_value('guest2') }
it { should contain_sahara_config('DEFAULT/rabbit_host').with_value('localhost2') }
it { should contain_sahara_config('DEFAULT/rabbit_port').with_value('5673') }
it { should contain_sahara_config('DEFAULT/rabbit_durable_queues').with_value('true') }
end
end
describe 'with rabbit ssl cert parameters' do
let :params do
{
:rabbit_password => 'pass',
:rabbit_use_ssl => 'true',
:kombu_ssl_ca_certs => '/etc/ca.cert',
:kombu_ssl_certfile => '/etc/certfile',
:kombu_ssl_keyfile => '/etc/key',
}
end
it { should contain_sahara_config('DEFAULT/rabbit_use_ssl').with_value('true') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_ca_certs').with_value('/etc/ca.cert') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_certfile').with_value('/etc/certfile') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_keyfile').with_value('/etc/key') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') }
end
describe 'with rabbit ssl disabled' do
let :params do
{
:rabbit_password => 'pass',
:rabbit_use_ssl => false,
:kombu_ssl_ca_certs => 'undef',
:kombu_ssl_certfile => 'undef',
:kombu_ssl_keyfile => 'undef'
}
end
it { should contain_sahara_config('DEFAULT/rabbit_use_ssl').with_value('false') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') }
it { should contain_sahara_config('DEFAULT/kombu_ssl_version').with_ensure('absent') }
end
describe 'when passing params for single rabbit host' do
let :params do
{
:rabbit_password => 'pass',
:rabbit_userid => 'guest2',
:rabbit_host => 'localhost2',
:rabbit_port => '5673',
:durable_queues => true,
}
end
it { should contain_sahara_config('DEFAULT/rabbit_userid').with_value('guest2') }
it { should contain_sahara_config('DEFAULT/rabbit_host').with_value('localhost2') }
it { should contain_sahara_config('DEFAULT/rabbit_port').with_value('5673') }
xit { should contain_sahara_config('DEFAULT/rabbit_hosts').with_value('localhost2:5673') }
it { should contain_sahara_config('DEFAULT/amqp_durable_queues').with_value('true') }
end
describe 'when passing params for multiple rabbit hosts' do
let :params do
{
:rabbit_password => 'pass',
:rabbit_userid => 'guest3',
:rabbit_hosts => ['nonlocalhost3:5673', 'nonlocalhost4:5673']
}
end
it { should contain_sahara_config('DEFAULT/rabbit_userid').with_value('guest3') }
it { should contain_sahara_config('DEFAULT/rabbit_hosts').with_value(
'nonlocalhost3:5673,nonlocalhost4:5673') }
it { should contain_sahara_config('DEFAULT/rabbit_ha_queues').with_value('true') }
it { should_not contain_sahara_config('DEFAULT/rabbit_port') }
it { should_not contain_sahara_config('DEFAULT/rabbit_host') }
end
describe 'when using deprecated params' do
let :params do
{
:durable_queues => true,
:rabbit_password => 'pass'
}
end
it { should contain_sahara_config('DEFAULT/amqp_durable_queues').with_value('true') }
end
end

56
spec/shared_examples.rb Normal file
View File

@ -0,0 +1,56 @@
shared_examples_for "a Puppet::Error" do |description|
it "with message matching #{description.inspect}" do
expect { should have_class_count(1) }.to raise_error(Puppet::Error, description)
end
end
shared_examples 'generic sahara service' do |service|
context 'with default parameters' do
it 'installs package and service' do
should contain_package(service[:name]).with({
:name => service[:package_name],
:ensure => 'present',
:notify => "Service[#{service[:name]}]"
})
should contain_service(service[:name]).with({
:name => service[:service_name],
:ensure => 'running',
:hasstatus => true,
:enable => true
})
end
end
context 'with overridden parameters' do
let :params do
{ :enabled => true,
:package_ensure => '2014.2-1' }
end
it 'installs package and service' do
should contain_package(service[:name]).with({
:name => service[:package_name],
:ensure => '2014.2-1',
:notify => "Service[#{service[:name]}]"
})
should contain_service(service[:name]).with({
:name => service[:service_name],
:ensure => 'running',
:hasstatus => true,
:enable => true
})
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
should contain_service(service[:name]).without_ensure
end
end
end

View File

@ -1,20 +1,5 @@
# Copyright 2013 Zürcher Hochschule für Angewandte Wissenschaften
# All Rights Reserved.
#
# 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.
#
require 'puppetlabs_spec_helper/module_spec_helper'
require 'shared_examples'
RSpec.configure do |c|
c.alias_it_should_behave_like_to :it_configures, 'configures'

View File

@ -1,102 +0,0 @@
#!/bin/sh
#
# sahara-api OpenStack Hadoop Cluster API
#
# chkconfig: - 99 02
# description: OpenStack Hadoop Cluster Management API service
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $syslog
# Default-Stop: 0 1 6
# Short-Description: Sahara API server
# Description: OpenStack Hadoop Cluster Management API service
### END INIT INFO
. /etc/rc.d/init.d/functions
suffix=api
prog=sahara-$suffix
config="/etc/sahara/sahara.conf"
exec="/usr/bin/sahara-$suffix"
pidfile="/var/run/sahara/sahara-$suffix.pid"
user=sahara
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon --user $user --pidfile $pidfile "$exec -d &>/dev/null & echo \$! > $pidfile"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?

View File

@ -1,18 +0,0 @@
description "Sahara API Server upstart job"
author "Andy Edmonds <andy@edmonds.be>"
start on runlevel [2345]
stop on runlevel [!2345]
chdir <%= scope.lookupvar("sahara::params::sys_rundir") %>
pre-start script
mkdir -p <%= scope.lookupvar("sahara::params::sahara_rundir") %>
chown sahara:root <%= scope.lookupvar("sahara::params::sahara_rundir") %>
mkdir -p <%= scope.lookupvar("sahara::params::sahara_lockdir") %>
chown sahara:root <%= scope.lookupvar("sahara::params::sahara_lockdir") %>
end script
exec start-stop-daemon --start --chuid sahara --exec /usr/local/bin/<%= scope.lookupvar("sahara::params::sahara_service") %> -- --config-file=<%= scope.lookupvar("sahara::params::sahara_conf_file") %>

View File

@ -1,119 +0,0 @@
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
UPSTART_JOB_CONF="/etc/default/upstart-job"
INITSCRIPT="$(basename "$0")"
JOB="${INITSCRIPT%.sh}"
if [ "$JOB" = "upstart-job" ]; then
if [ -z "$1" ]; then
echo "Usage: upstart-job JOB COMMAND" 1>&2
exit 1
fi
JOB="$1"
INITSCRIPT="$1"
shift
else
if [ -z "$1" ]; then
echo "Usage: $0 COMMAND" 1>&2
exit 1
fi
fi
COMMAND="$1"
shift
ECHO=echo
ECHO_ERROR=echo
if [ -e "$UPSTART_JOB_CONF" ]; then
. "$UPSTART_JOB_CONF"
fi
if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
ECHO=:
ECHO_ERROR=:
fi
$ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"
# Only check if jobs are disabled if the currently _running_ version of
# Upstart (which may be older than the latest _installed_ version)
# supports such a query.
#
# This check is necessary to handle the scenario when upgrading from a
# release without the 'show-config' command (introduced in
# Upstart for Ubuntu version 0.9.7) since without this check, all
# installed packages with associated Upstart jobs would be considered
# disabled.
#
# Once Upstart can maintain state on re-exec, this change can be
# dropped (since the currently running version of Upstart will always
# match the latest installed version).
UPSTART_VERSION_RUNNING=$(initctl version|awk '{print $3}'|tr -d ')')
if dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 0.9.7
then
initctl show-config -e "$JOB"|grep -q '^ start on' || DISABLED=1
fi
case $COMMAND in
status)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
$COMMAND "$JOB"
;;
start|stop)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
if status "$JOB" 2>/dev/null | grep -q ' start/'; then
RUNNING=1
fi
if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
exit 0
elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
exit 0
elif [ -n "$DISABLED" ] && [ "$COMMAND" = "start" ]; then
exit 0
fi
$COMMAND "$JOB"
;;
restart)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
$ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
if status "$JOB" 2>/dev/null | grep -q ' start/'; then
RUNNING=1
fi
if [ -n "$RUNNING" ] ; then
stop "$JOB"
fi
# If the job is disabled and is not currently running, the job is
# not restarted. However, if the job is disabled but has been forced into the
# running state, we *do* stop and restart it since this is expected behaviour
# for the admin who forced the start.
if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
exit 0
fi
start "$JOB"
;;
reload|force-reload)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB"
reload "$JOB"
;;
*)
$ECHO_ERROR
$ECHO_ERROR "The script you are attempting to invoke has been converted to an Upstart" 1>&2
$ECHO_ERROR "job, but $COMMAND is not supported for Upstart jobs." 1>&2
exit 1
esac

View File

@ -1,267 +0,0 @@
[DEFAULT]
#
# Options defined in sahara.config
#
# set host (string value)
host=<%= @sahara_host %>
# set port (integer value)
port=<%= @sahara_port %>
#
# Options defined in sahara.main
#
# Protocol used to access OpenStack Identity service (string
# value)
os_auth_protocol=<%= @keystone_auth_protocol %>
# IP or hostname of machine on which OpenStack Identity
# service is located (string value)
os_auth_host=<%= @keystone_auth_host %>
# Port of OpenStack Identity service (string value)
os_auth_port=<%= @keystone_auth_port %>
# This OpenStack user is used to verify provided tokens. The
# user must have admin role in <os_admin_tenant_name> tenant
# (string value)
os_admin_username=<%= @keystone_user %>
# Password of the admin user (string value)
os_admin_password=<%= @keystone_password %>
# Name of tenant where the user is admin (string value)
os_admin_tenant_name=<%= scope.lookupvar("sahara::keystone::auth::tenant") %>
#
# Options defined in sahara.openstack.common.db.sqlalchemy.session
#
# the filename to use with sqlite (string value)
#sqlite_db=sahara.sqlite
# If true, use synchronous mode for sqlite (boolean value)
#sqlite_synchronous=true
#
# Options defined in sahara.openstack.common.lockutils
#
# Whether to disable inter-process locks (boolean value)
#disable_process_locking=false
# Directory to use for lock files. Default to a temp directory
# (string value)
lock_path=<%= scope.lookupvar("sahara::params::sahara_lockdir") %>
#
# Options defined in sahara.openstack.common.log
#
# Print debugging output (set logging level to DEBUG instead
# of default WARNING level). (boolean value)
debug=<%= @sahara_debug %>
# Print more verbose output (set logging level to INFO instead
# of default WARNING level). (boolean value)
verbose=<%= @sahara_verbose %>
# Log output to standard error (boolean value)
#use_stderr=true
# format string to use for log messages with context (string
# value)
#logging_context_format_string=%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user)s %(tenant)s] %(instance)s%(message)s
# format string to use for log messages without context
# (string value)
#logging_default_format_string=%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s
# data to append to log format when level is DEBUG (string
# value)
#logging_debug_format_suffix=%(funcName)s %(pathname)s:%(lineno)d
# prefix each line of exception output with this format
# (string value)
#logging_exception_prefix=%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s
# list of logger=LEVEL pairs (list value)
#default_log_levels=amqplib=WARN,sqlalchemy=WARN,boto=WARN,suds=INFO,keystone=INFO,eventlet.wsgi.server=WARN
# publish error events (boolean value)
#publish_errors=false
# make deprecations fatal (boolean value)
#fatal_deprecations=false
# If an instance is passed with the log message, format it
# like this (string value)
#instance_format="[instance: %(uuid)s] "
# If an instance UUID is passed with the log message, format
# it like this (string value)
#instance_uuid_format="[instance: %(uuid)s] "
# If this option is specified, the logging configuration file
# specified is used and overrides any other logging options
# specified. Please see the Python logging module
# documentation for details on logging configuration files.
# (string value)
#log_config=<None>
# A logging.Formatter log message format string which may use
# any of the available logging.LogRecord attributes. This
# option is deprecated. Please use
# logging_context_format_string and
# logging_default_format_string instead. (string value)
#log_format=<None>
# Format string for %%(asctime)s in log records. Default:
# %(default)s (string value)
#log_date_format=%Y-%m-%d %H:%M:%S
# (Optional) Name of log file to output to. If no default is
# set, logging will go to stdout. (string value)
log_file=<%= scope.lookupvar("sahara::params::sahara_logdir") %>/sahara.log
# (Optional) The base directory used for relative --log-file
# paths (string value)
# log_dir=<%= scope.lookupvar("sahara::params::sahara_logdir") %>
# Use syslog for logging. (boolean value)
use_syslog=<%= scope.lookupvar("sahara::params::sahara_syslog") %>
# syslog facility to receive log lines (string value)
#syslog_log_facility=LOG_USER
#
# Options defined in sahara.openstack.common.notifier.api
#
# Driver or drivers to handle sending notifications (multi
# valued)
#notification_driver=
# Default notification level for outgoing notifications
# (string value)
#default_notification_level=INFO
# Default publisher_id for outgoing notifications (string
# value)
#default_publisher_id=$host
#
# Options defined in sahara.plugins.base
#
# TODO(dizz): parameterise the following!
# List of plugins to be loaded. Sahara preserves the order of
# the list when returning it. (list value) - vanilla, hdp
plugins=vanilla
[plugin:vanilla]
plugin_class=sahara.plugins.vanilla.plugin:VanillaProvider
#[plugin:hdp]
#plugin_class=sahara.plugins.hdp.plugin:AmbariPlugin
#
# Options defined in sahara.service.networks
#
# When set to false, Sahara uses only internal IP of VMs.
# When set to true, Sahara expects OpenStack to auto-assign
# floating IPs to cluster nodes. Internal IPs will be used for
# inter-cluster communication, while floating ones will be
# used by Sahara to configure nodes. Also floating IPs will
# be exposed in service URLs. (boolean value)
use_floating_ips=<%= scope.lookupvar("sahara::params::sahara_usefips") %>
# The suffix of the node's FQDN. In nova-network that is
# dhcp_domain config parameter (string value)
node_domain=<%= scope.lookupvar("sahara::params::sahara_node_domain") %>
[database]
#
# Options defined in sahara.db.migration.cli
#
# URL to database (string value)
# connection=sqlite:////tmp/sahara-server.db
connection=mysql://<%= @sahara_db_user %>:<%= @sahara_db_password %>@<%= @db_host %>/<%= @sahara_db_name %>
#
# Options defined in sahara.openstack.common.db.api
#
# The backend to use for db (string value)
#backend=sqlalchemy
# Enable the experimental use of thread pooling for all DB API
# calls (boolean value)
#use_tpool=false
#
# Options defined in sahara.openstack.common.db.sqlalchemy.session
#
# The SQLAlchemy connection string used to connect to the
# database (string value)
#connection=sqlite:////sahara/openstack/common/db/$sqlite_db
# The SQLAlchemy connection string used to connect to the
# slave database (string value)
#slave_connection=
# timeout before idle sql connections are reaped (integer
# value)
#idle_timeout=3600
# Minimum number of SQL connections to keep open in a pool
# (integer value)
#min_pool_size=1
# Maximum number of SQL connections to keep open in a pool
# (integer value)
#max_pool_size=<None>
# maximum db connection retries during startup. (setting -1
# implies an infinite retry count) (integer value)
#max_retries=10
# interval between retries of opening a sql connection
# (integer value)
#retry_interval=10
# If set, use this value for max_overflow with sqlalchemy
# (integer value)
#max_overflow=<None>
# Verbosity of SQL debugging information. 0=None,
# 100=Everything (integer value)
#connection_debug=0
# Add python stack traces to SQL as comment strings (boolean
# value)
#connection_trace=false
# If set, use this value for pool_timeout with sqlalchemy
# (integer value)
#pool_timeout=<None>
# Total option count: 51

View File

@ -1,26 +0,0 @@
# Copyright 2013 Zürcher Hochschule für Angewandte Wissenschaften
# All Rights Reserved.
#
# 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.
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation errors
# and view a log of events) or by fully applying the test in a virtual environment
# (to compare the resulting system state to the desired state).
#
# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html
#
include sahara