From 829cfb0bd84bb497cd300f214377adfe8a22de86 Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Tue, 30 Dec 2014 22:10:44 +0100 Subject: [PATCH] db: Added postgresql backend using openstacklib helper Standardize neutron module, and add postgresql backend. Change-Id: I2dcfa1075b6f23680357f2056731d481b97792d9 Implements: blueprint commmon-openstack-database-resource --- .fixtures.yml | 2 + manifests/db/postgresql.pp | 45 +++++++++++++++++ spec/classes/neutron_db_postgresql_spec.rb | 58 ++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 manifests/db/postgresql.pp create mode 100644 spec/classes/neutron_db_postgresql_spec.rb diff --git a/.fixtures.yml b/.fixtures.yml index 40413b17e..714df6bf6 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,5 +1,6 @@ fixtures: repositories: + 'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git' "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" "inifile": "git://github.com/puppetlabs/puppetlabs-inifile" "keystone": "git://github.com/stackforge/puppet-keystone.git" @@ -8,6 +9,7 @@ fixtures: ref: 'origin/2.2.x' "nova": "git://github.com/stackforge/puppet-nova.git" "openstacklib": "git://github.com/stackforge/puppet-openstacklib.git" + 'postgresql': 'git://github.com/puppetlabs/puppet-postgresql.git' "vswitch": "git://github.com/stackforge/puppet-vswitch" 'sysctl': 'git://github.com/duritong/puppet-sysctl.git' symlinks: diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp new file mode 100644 index 000000000..3f113da2e --- /dev/null +++ b/manifests/db/postgresql.pp @@ -0,0 +1,45 @@ +# == Class: neutron::db::postgresql +# +# Class that configures postgresql for neutron +# Requires the Puppetlabs postgresql module. +# +# === Parameters +# +# [*password*] +# (Required) Password to connect to the database. +# +# [*dbname*] +# (Optional) Name of the database. +# Defaults to 'neutron'. +# +# [*user*] +# (Optional) User to connect to the database. +# Defaults to 'neutron'. +# +# [*encoding*] +# (Optional) The charset to use for the database. +# Default to undef. +# +# [*privileges*] +# (Optional) Privileges given to the database user. +# Default to 'ALL' +# +class neutron::db::postgresql( + $password, + $dbname = 'neutron', + $user = 'neutron', + $encoding = undef, + $privileges = 'ALL', +) { + + ::openstacklib::db::postgresql { 'neutron': + password_hash => postgresql_password($user, $password), + dbname => $dbname, + user => $user, + encoding => $encoding, + privileges => $privileges, + } + + ::Openstacklib::Db::Postgresql['neutron'] ~> Service <| title == 'neutron-server' |> + +} diff --git a/spec/classes/neutron_db_postgresql_spec.rb b/spec/classes/neutron_db_postgresql_spec.rb new file mode 100644 index 000000000..7e8613a07 --- /dev/null +++ b/spec/classes/neutron_db_postgresql_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +describe 'neutron::db::postgresql' do + + let :req_params do + { :password => 'pw' } + end + + let :pre_condition do + 'include postgresql::server' + end + + context 'on a RedHat osfamily' do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '7.0', + :concat_basedir => '/var/lib/puppet/concat' + } + end + + context 'with only required parameters' do + let :params do + req_params + end + + it { should contain_postgresql__server__db('neutron').with( + :user => 'neutron', + :password => 'md5696acd1dd66513a556a18a1beccd03d1' + )} + end + + end + + context 'on a Debian osfamily' do + let :facts do + { + :operatingsystemrelease => '7.8', + :operatingsystem => 'Debian', + :osfamily => 'Debian', + :concat_basedir => '/var/lib/puppet/concat' + } + end + + context 'with only required parameters' do + let :params do + req_params + end + + it { should contain_postgresql__server__db('neutron').with( + :user => 'neutron', + :password => 'md5696acd1dd66513a556a18a1beccd03d1' + )} + end + + end + +end