Allow MongoDB to set up cluster when in recovery state
Also cleaned up 'exec' statements, spacing, quoting. MongoDB sometimes deploys into REC (recovery) state, but it does not block deployment. Also running mongostat with '-n1' option so that it does not print many lines and waste time during deployment. Change-Id: I4d6cb861e5f40fd2e4f74742d51aa40212b8f030 Closes-Bug: #1381826
This commit is contained in:
parent
5f5b4cafc9
commit
22c094a817
@ -4,6 +4,11 @@ class mongodb::replset::install (
|
||||
)
|
||||
|
||||
{
|
||||
Exec{
|
||||
logoutput => true,
|
||||
path => '/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin',
|
||||
}
|
||||
|
||||
notify { 'Create ReplicaSet ': }
|
||||
|
||||
define add_replset_members() {
|
||||
@ -11,37 +16,30 @@ class mongodb::replset::install (
|
||||
notify { "Member ${node_hostname}":; }
|
||||
exec { "add ${node_hostname}":
|
||||
command => "/bin/echo \"rs.add(\\\"${node_hostname}\\\")\"| /usr/bin/mongo",
|
||||
logoutput => true,
|
||||
}
|
||||
}
|
||||
|
||||
# Workaround: wait for server
|
||||
exec { 'wait_for_server':
|
||||
path => '/bin:/usr/bin',
|
||||
command => 'echo \'TRY_NUMBER=1; for i in {1..10}; do echo "Connecting to mongo... $TRY_NUMBER"; (mongostat | grep ok) && break; sleep 1; ((TRY_NUMBER++)); done\' | bash',
|
||||
command => 'echo \'TRY_NUMBER=1; for i in {1..10}; do echo "Connecting to mongo... $TRY_NUMBER"; (mongostat -n1 | egrep "(ok|REC)" ) && break; sleep 1; ((TRY_NUMBER++)); done\' | bash',
|
||||
tries => 10,
|
||||
try_sleep => 1,
|
||||
logoutput => true,
|
||||
try_sleep => 1,
|
||||
} ->
|
||||
|
||||
exec { 'rs.initiate':
|
||||
command => '/bin/echo \"rs.initiate()\"| /usr/bin/mongo',
|
||||
logoutput => true,
|
||||
command => '/bin/echo "rs.initiate()"| /usr/bin/mongo',
|
||||
} ->
|
||||
|
||||
exec { 'do_pause_1':
|
||||
command => '/bin/sleep 5',
|
||||
logoutput => true,
|
||||
} ->
|
||||
|
||||
exec { 'rs.conf':
|
||||
command => '/bin/echo \"rs.conf()\"| /usr/bin/mongo',
|
||||
logoutput => true,
|
||||
command => '/bin/echo "rs.conf()"| /usr/bin/mongo',
|
||||
} ->
|
||||
|
||||
exec { 'do_pause_2':
|
||||
command => '/bin/sleep 5',
|
||||
logoutput => true,
|
||||
} ->
|
||||
add_replset_members{ $replset_members:; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user