summaryrefslogtreecommitdiff
path: root/hooks/replica-set-relation-joined
diff options
authorJuan L. Negron <juan.negron@canonical.com>2011-08-16 14:34:13 -0700
committerJuan L. Negron <juan.negron@canonical.com>2011-08-16 14:34:13 -0700
commit5c123822e3501eeb8c302cc5171e4a8eaabf4adb (patch)
tree773e288f901ba3cca41b5e3d8a949282cf7fe0f6 /hooks/replica-set-relation-joined
parent1b0c23c4a909ca2683f43442168737181a067734 (diff)
Fixed single-node and replica set configurations
Diffstat (limited to 'hooks/replica-set-relation-joined')
-rwxr-xr-xhooks/replica-set-relation-joined15
1 files changed, 15 insertions, 0 deletions
diff --git a/hooks/replica-set-relation-joined b/hooks/replica-set-relation-joined
index 9431704..14568f9 100755
--- a/hooks/replica-set-relation-joined
+++ b/hooks/replica-set-relation-joined
@@ -5,6 +5,21 @@
set -ux
+DEFAULT_REPLSET_NAME=`facter replset-name`
+
+############################################################################################################
+# Reconfigure the upstart script to include the replica-set option.
+# We'll need this so, when we add nodes, they can all talk to each other.
+# Replica sets can only talk to each other if they all belong to the same
+# set. In our case, we have defaulted to "myset".
+############################################################################################################
+
+grep "${DEFAULT_REPLSET_NAME}" /etc/init/mongodb.conf || sed -i -e "s/ -- / -- --replSet ${DEFAULT_REPLSET_NAME} /" /etc/init/mongodb.conf
+
+service mongodb stop
+rm -f /var/lib/mongodb/mongod.lock
+service mongodb start
+
relation-set hostname=`hostname -f` replset=`facter replset-name` install-time=`facter install-time`
echo $ENSEMBLE_REMOTE_UNIT joined