diff --git a/README.md b/README.md index 0b73944..38a02a2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # DCOS Toolkit -## Everything related to mesos are listed here. - -1. [Mesos](mesos/README.md) \ No newline at end of file +1. [Scripts](scripts/README.md) +2. [Mesos](mesos/README.md) \ No newline at end of file diff --git a/mesos/01-NodeAttributes.md b/mesos/01-NodeAttributes.md index 206ead7..63efbd7 100644 --- a/mesos/01-NodeAttributes.md +++ b/mesos/01-NodeAttributes.md @@ -41,39 +41,6 @@ or Check DCOS UI Nodes => Select any Node => Details Tab -Automation Script : - -```bash -#!/bin/bash - -tmpScript=$(mktemp "/tmp/mesosNodeAttributes-XXXXXXXX") - -ATTRIBUTES="$1" -NODES_FILE=$2 - -if [ "$#" -ne 2 ]; then - echo "[Error] Wrong usage. Missing required input parameters." - echo "[Error] Usage : $0 <; separated key:value pairs as node attributes> " - echo "[Error] Example : $0 :;: /path/to/nodes/ip/file" - exit 1 -fi - -if [ ! -f $NODES_FILE ]; then - echo "[Error] Input nodes IP file is not valid. Please check. Exiting." - ls -la $NODES_FILE - exit 1 -fi - -cat < ${tmpScript} -echo "MESOS_ATTRIBUTES=${ATTRIBUTES}" | sudo tee /var/lib/dcos/mesos-slave-common -sudo systemctl stop dcos-mesos-slave -sudo rm -f /var/lib/mesos/slave/meta/slaves/latest -sudo systemctl start dcos-mesos-slave -EOF - -for i in `cat $NODES_FILE`; do - echo $i - dcos node ssh --master-proxy --option StrictHostKeyChecking=no --private-ip $i <$tmpScript - sleep 10 -done -``` \ No newline at end of file +## Automation Script + +[addNodeAttributes.sh](../scripts/addNodeAttributes.sh) diff --git a/utils/README.md b/scripts/README.md similarity index 91% rename from utils/README.md rename to scripts/README.md index ac3be5b..db23e8c 100644 --- a/utils/README.md +++ b/scripts/README.md @@ -78,4 +78,20 @@ Please input any one operation from : [ help addAWSKey agentsDetails publicIP sa - runOnAllMasters - Run user command on all dcos master nodes - Usage : `bash dcosUtil.sh runOnAllMasters ""` +``` + +[addNodeAttributes.sh](addNodeAttributes.sh) + +```bash +# Usage : +$ addNodeAttributes.sh <; separated key:value pairs as node attributes> +# Example : +$ addNodeAttributes.sh :;: /path/to/nodes/ip/file + +$ addNodeAttributes.sh "SERVER_TYPE:DB;DB_TYPE:POSTGRES" "/tmp/POSTGRES_NDOES.txt" + +$ cat /tmp/POSTGRES_NDOES.txt +10.0.0.1 +10.0.0.2 +10.0.0.3 ``` \ No newline at end of file diff --git a/scripts/addNodeAttributes.sh b/scripts/addNodeAttributes.sh new file mode 100644 index 0000000..67d10c5 --- /dev/null +++ b/scripts/addNodeAttributes.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +tmpScript=$(mktemp "/tmp/mesosNodeAttributes-XXXXXXXX") + +ATTRIBUTES="$1" +NODES_FILE=$2 + +if [ "$#" -ne 2 ]; then + echo "[Error] Wrong usage. Missing required input parameters." + echo "[Error] Usage : $0 <; separated key:value pairs as node attributes> " + echo "[Error] Example : $0 :;: /path/to/nodes/ip/file" + exit 1 +fi + +if [ ! -f $NODES_FILE ]; then + echo "[Error] Input nodes IP file is not valid. Please check. Exiting." + ls -la $NODES_FILE + exit 1 +fi + +cat < ${tmpScript} +echo "MESOS_ATTRIBUTES=${ATTRIBUTES}" | sudo tee /var/lib/dcos/mesos-slave-common +sudo systemctl stop dcos-mesos-slave +sudo rm -f /var/lib/mesos/slave/meta/slaves/latest +sudo systemctl start dcos-mesos-slave +EOF + +for i in `cat $NODES_FILE`; do + echo $i + dcos node ssh --master-proxy --option StrictHostKeyChecking=no --private-ip $i <$tmpScript + sleep 10 +done \ No newline at end of file diff --git a/utils/dcosUtil.sh b/scripts/dcosUtil.sh similarity index 100% rename from utils/dcosUtil.sh rename to scripts/dcosUtil.sh