summaryrefslogtreecommitdiff
diff options
-rw-r--r--config.yaml5
-rwxr-xr-xhooks/database-relation-joined2
-rwxr-xr-xhooks/install17
-rwxr-xr-xhooks/replica-set-relation-changed2
-rwxr-xr-xhooks/replica-set-relation-joined4
5 files changed, 14 insertions, 16 deletions
diff --git a/config.yaml b/config.yaml
new file mode 100644
index 0000000..8c5787d
--- /dev/null
+++ b/config.yaml
@@ -0,0 +1,5 @@
+options:
+ replicaset:
+ default: myset
+ type: string
+ description: Name of the replica set
diff --git a/hooks/database-relation-joined b/hooks/database-relation-joined
index 8556c0a..d9d2c87 100755
--- a/hooks/database-relation-joined
+++ b/hooks/database-relation-joined
@@ -5,6 +5,6 @@
set -ux
-relation-set hostname=`hostname -f` replset=`facter replset-name`
+relation-set hostname=`hostname -f` replset=`config-get replicaset`
echo $JUJU_REMOTE_UNIT joined
diff --git a/hooks/install b/hooks/install
index abd0d34..3f25527 100755
--- a/hooks/install
+++ b/hooks/install
@@ -7,23 +7,15 @@ set -ux
############################################################################################################
# Install some utility packages needed for installation
############################################################################################################
-rm -f /etc/apt/sources.list.d/facter-plugins-ppa-oneiric.list
-echo deb http://ppa.launchpad.net/facter-plugins/ppa/ubuntu oneiric main >> /etc/apt/sources.list.d/facter-plugins-ppa-oneiric.list
-echo deb-src http://ppa.launchpad.net/facter-plugins/ppa/ubuntu oneiric main >> /etc/apt/sources.list.d/facter-plugins-ppa-oneiric.list
-apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B696B50DD8914A9290A4923D6383E098F7D4BE4B
-
-#apt-add-repository ppa:facter-plugins/ppa
-apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y install facter facter-customfacts-plugin
############################################################################################################
# Set some variables that we'll need for later
############################################################################################################
-DEFAULT_REPLSET_NAME="myset"
+DEFAULT_REPLSET_NAME=`config-get replicaset`
HOSTNAME=`hostname -f`
EPOCH=`date +%s`
-fact-add replset-name ${DEFAULT_REPLSET_NAME}
fact-add install-time ${EPOCH}
@@ -47,7 +39,7 @@ sed -e "s/#master = true/master = true/" -e "s/bind_ip/#bind_ip/" -i /etc/mongod
# Replica sets can only talk to each other if they all belong to the same
# set. In our case, we have defaulted to "myset".
############################################################################################################
-#sed -i -e "s/ -- / -- --replSet ${DEFAULT_REPLSET_NAME} /" /etc/init/mongodb.conf
+sed -i -e "s/ -- / -- --replSet ${DEFAULT_REPLSET_NAME} /" /etc/init/mongodb.conf
############################################################################################################
@@ -62,8 +54,9 @@ service mongodb start
############################################################################################################
# Initialize the replicaset
############################################################################################################
-#sleep 5
-#mongo --eval "rs.initiate()"
+sleep 5
+mongo --eval "rs.initiate()"
+sleep 5
############################################################################################################
diff --git a/hooks/replica-set-relation-changed b/hooks/replica-set-relation-changed
index e9ba184..e813d2f 100755
--- a/hooks/replica-set-relation-changed
+++ b/hooks/replica-set-relation-changed
@@ -12,7 +12,7 @@ set -ux
# Set some global variables
############################################################################################################
MY_HOSTNAME=`hostname -f`
-MY_REPLSET=`facter replset-name`
+MY_REPLSET=`config-get replicaset`
MY_INSTALL_TIME=`facter install-time`
MASTER_HOSTNAME=${MY_HOSTNAME}
diff --git a/hooks/replica-set-relation-joined b/hooks/replica-set-relation-joined
index c098fc5..6285ac4 100755
--- a/hooks/replica-set-relation-joined
+++ b/hooks/replica-set-relation-joined
@@ -5,7 +5,7 @@
set -ux
-DEFAULT_REPLSET_NAME=`facter replset-name`
+DEFAULT_REPLSET_NAME=`config-get replicaset`
############################################################################################################
# Reconfigure the upstart script to include the replica-set option.
@@ -20,6 +20,6 @@ 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`
+relation-set hostname=`hostname -f` replset=${DEFAULT_REPLSET_NAME} install-time=`facter install-time`
echo $JUJU_REMOTE_UNIT joined