From 1598196ae7898174b5f30e70293320f3c1a67598 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 23 Apr 2013 12:09:49 -0400 Subject: [PATCH] Add glance::db::postgresql class. This allows Glance to be used with PostgreSQL. Requires the puppetlabs/postgresql module. NOTE: I did add this dependency to fixtures but did not add it to the Modulefile due to the fact that the postgresql::python module hasn't been released to puppetforge yet (although it is committed and tests pass). Change-Id: I3522d50935c81c8859c9f597df64aa0af6ca4e71 --- .fixtures.yml | 1 + manifests/db/postgresql.pp | 21 ++++++++++++++++++ spec/classes/glance_db_postgresql_spec.rb | 26 +++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 manifests/db/postgresql.pp create mode 100644 spec/classes/glance_db_postgresql_spec.rb diff --git a/.fixtures.yml b/.fixtures.yml index 300d1d75..accff587 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -6,5 +6,6 @@ fixtures: "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" "rabbitmq": "git://github.com/puppetlabs/puppetlabs-rabbitmq.git" 'inifile': 'git://github.com/cprice-puppet/puppetlabs-inifile' + "postgresql": "git://github.com/puppetlabs/puppet-postgresql.git" symlinks: "glance": "#{source_dir}" diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp new file mode 100644 index 00000000..6a0e98c2 --- /dev/null +++ b/manifests/db/postgresql.pp @@ -0,0 +1,21 @@ +# +# Class that configures postgresql for glance +# +# Requires the Puppetlabs postgresql module. +class glance::db::postgresql( + $password, + $dbname = 'glance', + $user = 'glance' +) { + + require 'postgresql::python' + + Postgresql::Db[$dbname] ~> Exec<| title == 'glance-manage db_sync' |> + Package['python-psycopg2'] -> Exec<| title == 'glance-manage db_sync' |> + + postgresql::db { "${dbname}": + user => "${user}", + password => "${password}", + } + +} diff --git a/spec/classes/glance_db_postgresql_spec.rb b/spec/classes/glance_db_postgresql_spec.rb new file mode 100644 index 00000000..dcb2b012 --- /dev/null +++ b/spec/classes/glance_db_postgresql_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'glance::db::postgresql' do + + let :req_params do + {:password => 'pw'} + end + + let :facts do + { + :postgres_default_version => '8.4', + :osfamily => 'RedHat', + } + end + + describe 'with only required params' do + let :params do + req_params + end + it { should contain_postgresql__db('glance').with( + :user => 'glance', + :password => 'pw' + ) } + end + +end