Skip to content

Commit 5e21678

Browse files
committed
Connect to localhost in provider when possible
The provider previously used the external IP to connect instead of the loopback. When using the loopback, the option `enableLocalhostAuthBypass` (true by default) allows to bypass authentication when a user doesn't yet exists. Which is exactly what would prevent us from executing administrative tasks (like setting up the replicaset) when auth is enabled, but not yet set up. We can only connect to localhost when MongoDB is listening on either the 'bind all' address (0.0.0.0 or ::0) or the local loopback address (127.0.0.1 or ::1).
1 parent 0a03dbf commit 5e21678

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/puppet/provider/mongodb.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ def self.conn_string
111111
first_ip_in_list = bindip.split(',').first
112112
ip_real = case first_ip_in_list
113113
when '0.0.0.0'
114-
Facter.value(:fqdn)
114+
'127.0.0.1'
115115
when %r{\[?::0\]?}
116-
Facter.value(:fqdn)
116+
'::1'
117117
else
118118
first_ip_in_list
119119
end

0 commit comments

Comments
 (0)