Mongo MMS Instance

by josh-d
36 deployments · 17 still active · last rev. 1 year ago

Compatible with: Ubuntu 14.04 LTS
						#!/bin/bash
#
# <UDF name="maintenance_user" Label="Name of maintenance user" />
# <UDF name="maintenance_password" Label="Password for maintenance user" />
# <UDF name="maintenance_pubkey" Label="Public Key for maintenance user" />
# <UDF name="new_hostname" Label="Server's hostname" />
# <UDF name="mms_group_id" Label="MMS Group ID" />
# <UDF name="mms_api_key" Label="MMS API Key" />

source <ssinclude StackScriptID=1>

system_update

user_add_sudo $MAINTENANCE_USER $MAINTENANCE_PASSWORD
user_add_pubkey $MAINTENANCE_USER $MAINTENANCE_PUBKEY

dpkg-reconfigure locales
update-locale LANG=en_US.UTF-8

ssh_disable_root
sed -i 's/LoginGraceTime 120/LoginGraceTime 10/' /etc/ssh/sshd_config
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config

system_set_hostname $NEW_HOSTNAME
system_add_host_entry 127.0.0.1 $NEW_HOSTNAME

ufw logging on
ufw default deny
ufw allow 22/tcp
ufw enable

apt-get install -y python-setuptools build-essential python-dev
easy_install pymongo

curl -OL https://mms.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_2.0.4.1140-1_amd64.deb
sudo dpkg -i mongodb-mms-automation-agent-manager_2.0.4.1140-1_amd64.deb
rm mongodb-mms-automation-agent-manager_2.0.4.1140-1_amd64.deb

sed -i.bak s/@GROUP_ID@/$MMS_GROUP_ID/g /etc/mongodb-mms/automation-agent.config
sed -i.bak s/@API_KEY@/$MMS_API_KEY/g /etc/mongodb-mms/automation-agent.config

mkdir -p /data
chown mongodb:mongodb /data

start mongodb-mms-automation-agent

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
apt-get update
apt-get install -y mongodb-org-tools mongodb-org-shell

apt-get install -y htop glances munin-node

ln -s /usr/share/munin/plugins/iostat /etc/munin/plugins/iostat
ln -s /usr/share/munin/plugins/iostat_ios /etc/munin/plugins/iostat_ios
service munin-node restart

restartServices