Skip to content

Commit a46036b

Browse files
authored
Merge pull request #1276 from ekohl/autorequire-service
(MODULES-8700) Autorequire the service in postgresql_psql
2 parents 34d933a + 79fa355 commit a46036b

File tree

6 files changed

+8
-7
lines changed

6 files changed

+8
-7
lines changed

lib/puppet/type/postgresql_psql.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def matches(value)
131131
newvalues(:true, :false)
132132
end
133133

134-
autorequire(:class) { ['Postgresql::Server::Service'] }
134+
autorequire(:anchor) { ['postgresql::server::service::begin'] }
135+
autorequire(:service) { ['postgresqld'] }
135136

136137
def should_run_sql(refreshing = false)
137138
onlyif_param = @parameters[:onlyif]

spec/unit/defines/server/database_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
end
2525

2626
it { is_expected.to contain_postgresql__server__database('test') }
27-
it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"') }
27+
it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').that_requires('Service[postgresqld]') }
2828

2929
context "with comment set to 'test comment'" do
3030
let(:params) { { comment: 'test comment' } }

spec/unit/defines/server/grant_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class {'postgresql::server':}
213213
it { is_expected.to contain_postgresql__server__role('test') }
214214
it do
215215
is_expected.to contain_postgresql_psql('grant:test') \
216-
.that_requires(['Class[postgresql::server::service]', 'Postgresql::Server::Role[test]'])
216+
.that_requires(['Service[postgresqld]', 'Postgresql::Server::Role[test]'])
217217
end
218218
end
219219

spec/unit/defines/server/reassign_owned_by_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ class {'postgresql::server':}
4242
is_expected.to contain_postgresql_psql('reassign_owned_by:test:REASSIGN OWNED BY "test_old_role" TO "test_new_role"')
4343
.with_command('REASSIGN OWNED BY "test_old_role" TO "test_new_role"')
4444
.with_onlyif(%r{SELECT tablename FROM pg_catalog.pg_tables WHERE\s*schemaname NOT IN \('pg_catalog', 'information_schema'\) AND\s*tableowner = 'test_old_role'.*}m)
45-
.that_requires('Class[Postgresql::Server::Service]')
45+
.that_requires('Service[postgresqld]')
4646
}
4747
end

spec/unit/defines/server/role_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
.with_unless("SELECT 1 FROM pg_roles WHERE rolname = 'test'")
7070
.with_port(5432)
7171
.with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1', 'PGUSER' => 'login-user', 'PGPASSWORD' => 'login-pass')
72-
.that_requires('Class[postgresql::server::service]')
72+
.that_requires('Service[postgresqld]')
7373
end
7474
it 'has alter role for "test" user with password as ****' do
7575
is_expected.to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****')
@@ -142,7 +142,7 @@
142142
end
143143

144144
it 'has drop role for "test" user if ensure absent' do
145-
is_expected.to contain_postgresql_psql('DROP ROLE "test"').that_requires('Class[postgresql::server::service]')
145+
is_expected.to contain_postgresql_psql('DROP ROLE "test"').that_requires('Service[postgresqld]')
146146
end
147147
end
148148

spec/unit/defines/server/tablespace_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
it { is_expected.to contain_file('/srv/data/foo').with_ensure('directory') }
3434
it { is_expected.to contain_postgresql__server__tablespace('test') }
35-
it { is_expected.to contain_postgresql_psql('CREATE TABLESPACE "test"').that_requires('Class[postgresql::server::service]') }
35+
it { is_expected.to contain_postgresql_psql('CREATE TABLESPACE "test"').that_requires('Service[postgresqld]') }
3636

3737
context 'with different owner' do
3838
let :params do

0 commit comments

Comments
 (0)