You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#if e.message =~ %r{command replSetGetConfig requires authentication} || e.message =~ %r{not authorized on admin to execute command} || e.message =~ %r{no replset config has been received}
139
147
ife.message =~ %r{command replSetGetConfig requires authentication} || e.message =~ %r{not authorized on admin to execute command}
140
-
Puppet.debug('XXXXXXXXX in replset_properties rescue part')
141
148
output=mongo_command('rs.status()',conn_string)
142
149
ifoutput['members']
143
150
memb=[]
144
151
output['members'].eachdo |m|
145
152
memb << {'host'=>m['name']}
146
153
end
147
-
{
154
+
return{
148
155
name: output['set'],
149
156
ensure: :present,
150
157
members: memb,
151
-
#settings: @resource[:settings],
152
158
provider: :mongo
153
159
}
154
160
end
155
-
else
156
161
nil
157
162
end
158
163
end
159
-
ifoutput['members']
160
-
return{
161
-
name: output['_id'],# replica set name
162
-
ensure: :present,
163
-
members: output['members'],
164
-
settings: output['settings'],
165
-
provider: :mongo
166
-
}
167
-
end
168
-
nil
169
164
end
170
165
171
166
defget_hosts_status(members)
172
167
alive=[]
173
168
members.selectdo |member|
174
169
host=member['host']
175
-
Puppet.debug"Checking replicaset member #{host} ..."
176
170
begin
177
171
status=rs_status(host)
178
-
Puppet.debug('XXXXXXXXXXXXXX should not get here since I dont have a replicaset')
179
172
raisePuppet::Error,"Can't configure replicaset #{name}, host #{host} is not supposed to be part of a replicaset."ifstatus.key?('errmsg') && status['errmsg'] == 'not running with --replSet'
180
173
181
174
ifstatus.key?('set')
182
175
raisePuppet::Error,"Can't configure replicaset #{name}, host #{host} is already part of another replicaset."ifstatus['set'] != name
183
176
184
177
# This node is alive and supposed to be a member of our set
185
-
Puppet.debug"Host #{host} is available for replset #{status['set']}"
186
178
alive.push(member)
187
179
elsifstatus.key?('info')
188
-
Puppet.debug"Host #{host} is alive but unconfigured: #{status['info']}"
189
180
alive.push(member)
190
181
end
191
182
rescuePuppet::ExecutionFailure=>e
192
-
Puppet.debug('XXXXXXXXXXXX in rescue checking connection mebers')
193
183
ifauth_enabled
194
184
casee.message
195
185
when%r{no replset config has been received}
@@ -258,26 +248,27 @@ def set_members
258
248
return
259
249
end
260
250
261
-
Puppet.debug'Checking for dead and alive members'
251
+
# When no replicaset is initiated yet, and authenticatoin is anabled,
252
+
# mongo_eval still adds the mongorcsh.js. This gives an 'MongoServerError: Authentication failed.' error.
253
+
# In this stage, we only can connect to localhost, and only rs.status() and rs.initiate() is possible.
254
+
# All other commands generate 'MongoServerError: not authorized on admin to execute command' error
255
+
# So we need to check first if the replicaset is already available, then the admin user can be created, and after that
256
+
# authentication should be working.
257
+
#
262
258
if !@property_flush[:members].nil? && !@property_flush[:members].empty?
263
259
# Find the alive members so we don't try to add dead members to the replset using new config
0 commit comments