RETIRED, Chef Cookbook - common OpenStack configuration
Go to file
Andy McCrae 1d049e7076 Update libraries to be rubocop compliant
- Update .rubocop.yml to include libraries/**
- Update libraries to be rubocop compliant
- Update recipes/default.rb to remove unrequired rubocop:disable

Addresses: blueprint rubocop-for-common
Change-Id: I12a86bec70d1b9127d3b7d52356441637253e4f1
2014-01-28 13:17:35 +00:00
attributes Move to use "get_password" instead of "{user,service,db}_password" 2014-01-15 18:27:45 +00:00
libraries Update libraries to be rubocop compliant 2014-01-28 13:17:35 +00:00
recipes Update libraries to be rubocop compliant 2014-01-28 13:17:35 +00:00
spec Update spec files to be rubocop compliant 2014-01-24 15:02:19 +00:00
templates/default Support neutron configuration 2013-12-12 17:00:07 +08:00
.gitignore hide .cookbooks testing artifact 2013-10-22 15:05:59 -05:00
.gitreview Adds requisite .gitreview file for Gerrit reviews 2013-05-14 16:35:46 -04:00
.rubocop.yml Update libraries to be rubocop compliant 2014-01-28 13:17:35 +00:00
Berksfile Moved to a run_tests runner. 2013-01-29 11:59:11 -08:00
CHANGELOG.md first pass at adding havana repo for centOS/RHEL 2014-01-13 11:16:47 +00:00
Gemfile Update the Gemfile to sync with latest Chef and ChefSpec. 2014-01-09 14:29:28 -06:00
Gemfile.lock Update the Gemfile to sync with latest Chef and ChefSpec. 2014-01-09 14:29:28 -06:00
LICENSE Initial commit 2012-11-07 20:52:47 -05:00
metadata.rb first pass at adding havana repo for centOS/RHEL 2014-01-13 11:16:47 +00:00
README.md Add charset=utf8 to DB2 URI 2014-01-16 20:44:54 -05:00
Strainerfile Update spec files to be rubocop compliant 2014-01-24 15:02:19 +00:00
TESTING.md Filling out initial rubocop support. 2014-01-08 16:31:35 -06:00

Description

This cookbook provides common setup recipes, helper methods and attributes that describe an OpenStack deployment as part of the OpenStack reference deployment Chef for OpenStack.

Requirements

  • Chef 0.10.0 or higher required (for Chef environment use).

Cookbooks

The following cookbooks are dependencies:

  • apt
  • database

Attributes

Please see the extensive inline documentation in attributes/default.rb for descriptions of all the settable attributes for this cookbook.

Note that all attributes are in the default["openstack"] "namespace"

Recipes

default

Installs/Configures common recipes

"run_list": [
    "recipe[openstack-common]"
]

logging

Installs/Configures common logging

"run_list": [
    "recipe[openstack-common::logging]"
]

set_endpoints_by_interface

Iterates over the contents of the node['openstack']['endpoints'] hash and finds any occurrence of bind_interface to set the IP address (node['openstack']['endpoints']['identity']['bind_interface'] = 'eth0' for example, overriding node['openstack']['endpoints']['identity']['host']). If bind_interface isn't set, the value of host is not modified.

"run_list": [
    "recipe[openstack-common::set_endpoints_by_interface]"
]

sysctl

Iterates over the contents of the node['openstack']['sysctl'] hash and writes the entries to /etc/sysctl.d/60-openstack.conf.

"run_list": [
    "recipe[openstack-common::sysctl]"
]

Libraries

This cookbook exposes a set of default library routines:

  • endpoint -- Used to return a ::URI object representing the named OpenStack endpoint
  • endpoints -- Useful for operating on all OpenStack endpoints
  • db -- Returns a Hash of information about a named OpenStack database
  • db_uri -- Returns the SQLAlchemy RFC-1738 DB URI (see: http://rfc.net/rfc1738.html) for a named OpenStack database
  • db_create_with_user -- Creates a database and database user for a named OpenStack database
  • secret -- Returns the value of an encrypted data bag for a named OpenStack secret key and key-section
  • get_password -- Ease-of-use helper that returns the decrypted password for a named database, service or keystone user.

Usage

The following are code examples showing the above library routines in action. Remember when using the library routines exposed by this library to include the Openstack routines in your recipe's ::Chef::Recipe namespace, like so:

class ::Chef::Recipe
  include ::Openstack
end

Example of using the endpoint routine:

nova_api_ep = endpoint "compute-api"
::Chef::Log.info("Using Openstack Compute API endpoint at #{nova_api_ep.to_s}")

# Note that endpoint URIs may contain variable interpolation markers such
# as `%(tenant_id)s`, so you may need to decode them. Do so like this:

require "uri"

puts ::URI.decode nova_api_ap.to_s

Example of using the get_password and db_uri routine:

db_pass = get_password "db" "cinder"
db_user = node["cinder"]["db"]["user"]
sql_connection = db_uri "volume", db_user, db_pass

template "/etc/cinder/cinder.conf" do
  source "cinder.conf.erb"
  owner  node["cinder"]["user"]
  group  node["cinder"]["group"]
  mode   00644
  variables(
    "sql_connection" => sql_connection
  )
end

URI Operations

Use the Openstack::uri_from_hash routine to helpfully return a ::URI::Generic object for a hash that contains any of the following keys:

  • host
  • uri
  • port
  • path
  • scheme

If the uri key is in the hash, that will be used as the URI, otherwise the URI will be constructed from the various parts of the hash corresponding to the keys above.

# Suppose node hash contains the following subhash in the :identity_service key:
# {
#   :host => 'identity.example.com',
#   :port => 5000,
#   :scheme => 'https'
# }
uri = ::Openstack::uri_from_hash(node[:identity_service])
# uri.to_s would == "https://identity.example.com:5000"

The routine will return nil if neither a uri or host key exists in the supplied hash.

Using the library without prefixing with ::Openstack

Don't like prefixing calls to the library's routines with ::Openstack? Do this:

class ::Chef::Recipe
  include ::Openstack
end

in your recipe.

Testing

Please refer to the TESTING.md for instructions for testing the cookbook.

License and Author

Author Jay Pipes (jaypipes@att.com)
Author John Dewey (jdewey@att.com)
Author Matt Ray (matt@opscode.com)
Author Craig Tracey (craigtracey@gmail.com)
Author Sean Gallagher (sean.gallagher@att.com)
Author Ionut Artarisi (iartarisi@suse.cz)
Author Chen Zhiwei (zhiwchen@cn.ibm.com)
Copyright Copyright (c) 2012-2013, AT&T Services, Inc.
Copyright Copyright (c) 2013, Opscode, Inc.
Copyright Copyright (c) 2013, Craig Tracey
Copyright Copyright (c) 2013, SUSE Linux GmbH
Copyright Copyright (c) 2013-2014, IBM, Corp.

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.