add support for PostgreSQL

Change-Id: Id6b6997b588e2647c33746bfc56e211c3352ecf3
This commit is contained in:
Ionuț Arțăriși 2013-07-04 14:47:20 +02:00
parent 374579d4ff
commit 24a1b1107d
8 changed files with 120 additions and 3 deletions

View File

@ -54,6 +54,14 @@ None
- configures the mysql server for OpenStack
## postgresql-client ##
- calls postgresql::ruby and postgresql::client and installs 'postgresql_python_packages'
## postgresql-server ##
- configures the PostgreSQL server for OpenStack
## openstack-db ##
- creates necessary tables, users, and grants for OpenStack

View File

@ -23,8 +23,11 @@ default["openstack"]["db"]["bind_interface"] = "lo"
case platform
when "fedora", "redhat", "centos" # :pragma-foodcritic: ~FC024 - won"t fix this
default["openstack"]["db"]["platform"]["mysql_python_packages"] = [ "MySQL-python" ]
default["openstack"]["db"]["platform"]["postgresql_python_packages"] = [ "python-psycopg2" ]
when "suse"
default["openstack"]["db"]["platform"]["mysql_python_packages"] = [ "python-mysql" ]
default["openstack"]["db"]["platform"]["postgresql_python_packages"] = [ "python-psycopg2" ]
when "ubuntu"
default["openstack"]["db"]["platform"]["mysql_python_packages"] = [ "python-mysqldb" ]
default["openstack"]["db"]["platform"]["postgresql_python_packages"] = [ "python-psycopg2" ]
end

View File

@ -8,7 +8,9 @@ version "7.0.0"
recipe "client", "Installs client packages for the database used by the deployment."
recipe "server", "Installs and configures server packages for the database used by the deployment."
recipe "mysql-client", "Installs MySQL client packages."
recipe "mysql-server", "Installs and configured MySQL server packages."
recipe "mysql-server", "Installs and configures MySQL server packages."
recipe "postgresql-client", "Installs PostgreSQL client packages."
recipe "postgresql-server", "Installs and configures PostgreSQL server packages."
recipe "openstack-db", "Creates necessary tables, users, and grants for OpenStack."
%w{ fedora ubuntu redhat centos suse }.each do |os|

View File

@ -0,0 +1,27 @@
#
# Cookbook Name:: openstack-ops-database
# Recipe:: postgresql-client
#
# Copyright 2013, Opscode, Inc.
# Copyright 2013, AT&T Services, Inc.
# Copyright 2013, SUSE Linux GmbH
#
# 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.
#
include_recipe "postgresql::ruby"
include_recipe "postgresql::client"
node["openstack"]["db"]["platform"]["postgresql_python_packages"].each do |pkg|
package pkg
end

View File

@ -0,0 +1,32 @@
#
# Cookbook Name:: openstack-ops-database
# Recipe:: postgresql-server
#
# Copyright 2013, Opscode, Inc.
# Copyright 2012-2013, Rackspace US, Inc.
# Copyright 2013, AT&T Services, Inc.
# Copyright 2013, SUSE Linux GmbH
#
# 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 ::Chef::Recipe
include ::Openstack
end
listen_address = address_for node["openstack"]["db"]["bind_interface"]
node.override["postgresql"]["config"]["listen_addresses"] = listen_address
include_recipe "openstack-ops-database::postgresql-client"
include_recipe "postgresql::server"

View File

@ -4,11 +4,21 @@ describe "openstack-ops-database::client" do
before { ops_database_stubs }
describe "ubuntu" do
it "uses proper database client recipe" do
it "uses mysql database client recipe by default" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
chef_run.converge "openstack-ops-database::client"
expect(chef_run).to include_recipe "openstack-ops-database::mysql-client"
end
it "uses postgresql database client recipe when configured" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["db"]["service_type"] = "postgresql"
chef_run.converge "openstack-ops-database::client"
expect(chef_run).to include_recipe "openstack-ops-database::postgresql-client"
end
end
end

View File

@ -0,0 +1,21 @@
require_relative "spec_helper"
describe "openstack-ops-database::postgresql-server" do
before { ops_database_stubs }
describe "ubuntu" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
# The postgresql cookbook will raise an "uninitialized constant
# Chef::Application" error without this attribute when running
# the tests
@chef_run.node.set["postgresql"]["password"]["postgres"] = String.new
@chef_run.converge "openstack-ops-database::postgresql-server"
end
it "includes postgresql recipes" do
expect(@chef_run).to include_recipe(
"openstack-ops-database::postgresql-client")
expect(@chef_run).to include_recipe "postgresql::server"
end
end
end

View File

@ -4,7 +4,7 @@ describe "openstack-ops-database::server" do
before { ops_database_stubs }
describe "ubuntu" do
it "uses proper database server recipe" do
it "uses mysql database server recipe by default" do
chef_run = ::ChefSpec::ChefRunner.new(::UBUNTU_OPTS) do |n|
n.set["mysql"] = {
"server_debian_password" => "server-debian-password",
@ -16,5 +16,19 @@ describe "openstack-ops-database::server" do
expect(chef_run).to include_recipe "openstack-ops-database::mysql-server"
end
it "uses postgresql database server recipe when configured" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["db"]["service_type"] = "postgresql"
# The postgresql cookbook will raise an "uninitialized constant
# Chef::Application" error without this attribute when running
# the tests
n.set["postgresql"]["password"]["postgres"] = String.new
end
chef_run.converge "openstack-ops-database::server"
expect(chef_run).to include_recipe "openstack-ops-database::postgresql-server"
end
end
end