Skip to content

Commit 2971745

Browse files
committed
fixup! Users should be created before the database
1 parent d1f5d8b commit 2971745

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/puppet/type/mongodb_database.rb

-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@
2626
autorequire(:service) do
2727
%w[mongodb mongod]
2828
end
29-
30-
autorequire(:mongodb_database) do
31-
self[:user]
32-
end
3329
end

lib/puppet/type/mongodb_user.rb

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def insync?(_is)
117117
%w[mongodb mongod]
118118
end
119119

120+
autobefore(:mongodb_database) do
121+
self[:database]
122+
end
123+
120124
validate do
121125
if self[:password_hash].nil? && self[:password].nil? && provider.password.nil? && provider.password_hash.nil?
122126
err("Either 'password_hash' or 'password' should be provided")

spec/defines/db_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
is_expected.to contain_mongodb_user('User testuser on db testdb'). \
2626
with_username('testuser'). \
2727
with_database('testdb'). \
28-
that_requires('Mongodb_database[testdb]')
28+
that_comes_before('Mongodb_database[testdb]')
2929
end
3030

3131
it 'contains mongodb_user with proper roles' do
@@ -65,7 +65,7 @@
6565
is_expected.to contain_mongodb_user('User testuser on db testdb'). \
6666
with_username('testuser'). \
6767
with_database('testdb'). \
68-
that_requires('Mongodb_database[testdb]')
68+
that_comes_before('Mongodb_database[testdb]')
6969
end
7070

7171
it 'contains mongodb_user with proper roles' do

0 commit comments

Comments
 (0)