diff --git a/.fixtures.yml b/.fixtures.yml index 56328390..5463341b 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,15 +1,14 @@ fixtures: repositories: 'apt': 'git://github.com/puppetlabs/puppetlabs-apt.git' + 'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git' 'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile' 'keystone': 'git://github.com/stackforge/puppet-keystone.git' 'mysql': 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/puppet-postgresql.git' 'qpid': 'git://github.com/dprince/puppet-qpid.git' 'rabbitmq': repo: 'git://github.com/puppetlabs/puppetlabs-rabbitmq' diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp index 719a50ad..58c613ab 100644 --- a/manifests/db/postgresql.pp +++ b/manifests/db/postgresql.pp @@ -16,20 +16,30 @@ # (Optional) User to connect to the database. # Defaults to 'cinder'. # +# [*encoding*] +# (Optional) The charset to use for the database. +# Default to undef. +# +# [*privileges*] +# (Optional) Privileges given to the database user. +# Default to 'ALL' +# class cinder::db::postgresql( $password, - $dbname = 'cinder', - $user = 'cinder' + $dbname = 'cinder', + $user = 'cinder', + $encoding = undef, + $privileges = 'ALL', ) { - require postgresql::python - - Postgresql::Db[$dbname] ~> Exec<| title == 'cinder-manage db_sync' |> - Package['python-psycopg2'] -> Exec<| title == 'cinder-manage db_sync' |> - - postgresql::db { $dbname: - user => $user, - password => $password, + ::openstacklib::db::postgresql { 'cinder': + password_hash => postgresql_password($user, $password), + dbname => $dbname, + user => $user, + encoding => $encoding, + privileges => $privileges, } + ::Openstacklib::Db::Postgresql['cinder'] ~> Exec<| title == 'cinder-manage db_sync' |> + } diff --git a/spec/classes/cinder_db_postgresql_spec.rb b/spec/classes/cinder_db_postgresql_spec.rb index 93296ae1..c56d1cdc 100644 --- a/spec/classes/cinder_db_postgresql_spec.rb +++ b/spec/classes/cinder_db_postgresql_spec.rb @@ -3,24 +3,56 @@ require 'spec_helper' describe 'cinder::db::postgresql' do let :req_params do - {:password => 'pw'} + { :password => 'pw' } end - let :facts do - { - :postgres_default_version => '8.4', - :osfamily => 'RedHat', - } + let :pre_condition do + 'include postgresql::server' end - describe 'with only required params' do - let :params do - req_params + context 'on a RedHat osfamily' do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '7.0', + :concat_basedir => '/var/lib/puppet/concat' + } end - it { should contain_postgresql__db('cinder').with( - :user => 'cinder', - :password => 'pw' - ) } + + context 'with only required parameters' do + let :params do + req_params + end + + it { should contain_postgresql__server__db('cinder').with( + :user => 'cinder', + :password => 'md506736c3030793e09882cc536063d433f' + )} + 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('cinder').with( + :user => 'cinder', + :password => 'md506736c3030793e09882cc536063d433f' + )} + end + end end