Skip to content

Commit b244101

Browse files
committed
Merge pull request #228 from dprince/revert_auth_enabled
Revert "Initiate replica set creation from
2 parents e2383ef + 31ce292 commit b244101

2 files changed

Lines changed: 6 additions & 27 deletions

File tree

lib/puppet/provider/mongodb_replset/mongo.rb

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ def rs_add_arbiter(host, master)
9494
mongo_command("rs.addArb(\"#{host}\")", master)
9595
end
9696

97-
def auth_enabled
98-
@resource[:auth_enabled]
99-
end
100-
10197
def master_host(hosts)
10298
hosts.each do |host|
10399
status = db_ismaster(host)
@@ -139,36 +135,31 @@ def self.get_replset_properties
139135
end
140136

141137
def alive_members(hosts)
142-
alive = []
143138
hosts.select do |host|
144139
begin
145140
Puppet.debug "Checking replicaset member #{host} ..."
146141
status = rs_status(host)
147142
if status.has_key?('errmsg') and status['errmsg'] == 'not running with --replSet'
148143
raise Puppet::Error, "Can't configure replicaset #{self.name}, host #{host} is not supposed to be part of a replicaset."
149144
end
150-
151-
if auth_enabled and status.has_key?('errmsg') and (status['errmsg'].include? "unauthorized" or status['errmsg'].include? "not authorized")
152-
Puppet.warning "Host #{host} is available, but you are unauthorized because of authentication is enabled: #{auth_enabled}"
153-
alive.push(host)
154-
end
155-
156145
if status.has_key?('set')
157146
if status['set'] != self.name
158147
raise Puppet::Error, "Can't configure replicaset #{self.name}, host #{host} is already part of another replicaset."
159148
end
160149

161150
# This node is alive and supposed to be a member of our set
162151
Puppet.debug "Host #{host} is available for replset #{status['set']}"
163-
alive.push(host)
152+
true
164153
elsif status.has_key?('info')
165154
Puppet.debug "Host #{host} is alive but unconfigured: #{status['info']}"
155+
true
166156
end
167157
rescue Puppet::ExecutionFailure
168158
Puppet.warning "Can't connect to replicaset member #{host}."
159+
160+
false
169161
end
170162
end
171-
return alive
172163
end
173164

174165
def set_members
@@ -234,17 +225,10 @@ def set_members
234225
end
235226

236227
def mongo_command(command, host, retries=4)
237-
self.class.mongo_command(command,host,retries,auth_enabled)
228+
self.class.mongo_command(command,host,retries)
238229
end
239230

240-
def self.mongo_command(command, host=nil, retries=4, auth_enabled=false)
241-
if auth_enabled and command =~ 'rs.initiate'
242-
# We can't setup replica from any hosts except localhost
243-
# if authentication is enabled
244-
# User can't be created before replica set initialization
245-
# So we can't use user credentials for auth
246-
host = '127.0.0.1'
247-
end
231+
def self.mongo_command(command, host=nil, retries=4)
248232
# Allow waiting for mongod to become ready
249233
# Wait for 2 seconds initially and double the delay at each retry
250234
wait = 2

lib/puppet/type/mongodb_replset.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
desc "The name of the replicaSet"
1818
end
1919

20-
newparam(:auth_enabled) do
21-
desc "Check authentication enabled"
22-
defaultto false
23-
end
24-
2520
newparam(:arbiter) do
2621
desc "The replicaSet arbiter"
2722
end

0 commit comments

Comments
 (0)