forked from hortonworks/ansible-hortonworks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify scripts (DRY: Don’t repeat yourself)
- By sourcing the CLOUD_TO_USE check from a single file (set_cloud.sh)
- Loading branch information
Showing
7 changed files
with
60 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,5 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$CLOUD_TO_USE" ]; then | ||
echo "CLOUD_TO_USE environment variable must be set to one of the following: aws, azure, gce, openstack, static" | ||
exit 1 | ||
fi | ||
source "${BASH_SOURCE%/*}/set_cloud.sh" | ||
|
||
cloud_to_use=$(echo "$CLOUD_TO_USE" | tr '[:upper:]' '[:lower:]') | ||
case $cloud_to_use in | ||
aws|amazon) | ||
cloud_to_use=aws | ||
message="Cloud to be used is AWS.\nMake sure you've set the AWS authentication variables." | ||
;; | ||
azure|microsoft) | ||
cloud_to_use=azure | ||
message="Cloud to be used is Microsoft Azure.\nMake sure $HOME/.azure/credentials exists and it's correct." | ||
;; | ||
gce|google|gcp) | ||
cloud_to_use=gce | ||
message="Cloud to be used is Google Compute Engine.\nMake sure you've set the GCE authentication variables and JSON credentials file." | ||
;; | ||
openstack) | ||
message="Cloud to be used is OpenStack.\nMake sure you've sourced the OpenStack RC file." | ||
;; | ||
static) | ||
message="The static inventory will be used." | ||
;; | ||
*) | ||
message="CLOUD_TO_USE environment variable was set to \"$CLOUD_TO_USE\" but must be set to one of the following: aws, azure, gce, openstack, static" | ||
echo -e $message | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo -e $message | ||
ansible-playbook -i inventory/$cloud_to_use -e "cloud_name=$cloud_to_use" playbooks/apply_blueprint.yml | ||
ansible-playbook -i "inventory/${cloud_to_use}" -e "cloud_name=${cloud_to_use}" playbooks/apply_blueprint.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,16 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$CLOUD_TO_USE" ]; then | ||
echo "CLOUD_TO_USE environment variable must be set to one of the following: aws, azure, gce, openstack" | ||
exit 1 | ||
fi | ||
source "${BASH_SOURCE%/*}/set_cloud.sh" | ||
|
||
cloud_to_use=$(echo "$CLOUD_TO_USE" | tr '[:upper:]' '[:lower:]') | ||
case $cloud_to_use in | ||
aws|amazon) | ||
cloud_to_use=aws | ||
message="Cloud to be used is AWS.\nMake sure you've set the AWS authentication variables." | ||
;; | ||
azure|microsoft) | ||
cloud_to_use=azure | ||
message="Cloud to be used is Microsoft Azure.\nMake sure $HOME/.azure/credentials exists and it's correct." | ||
;; | ||
gce|google|gcp) | ||
cloud_to_use=gce | ||
message="Cloud to be used is Google Compute Engine.\nMake sure you've set the GCE authentication variables and JSON credentials file." | ||
;; | ||
openstack) | ||
message="Cloud to be used is OpenStack.\nMake sure you've sourced the OpenStack RC file." | ||
aws|azure|gce|openstack) | ||
;; | ||
*) | ||
message="CLOUD_TO_USE environment variable was set to \"$CLOUD_TO_USE\" but must be set to one of the following: aws, azure, openstack" | ||
message="CLOUD_TO_USE environment variable was set to \"$CLOUD_TO_USE\" but must be set to one of the following: aws, azure, gce, openstack" | ||
echo -e $message | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo -e $message | ||
ansible-playbook -i inventory/localhost playbooks/clouds/build_$cloud_to_use.yml --connection=local | ||
ansible-playbook -i inventory/localhost "playbooks/clouds/build_${cloud_to_use}.yml" --connection=local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,5 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$CLOUD_TO_USE" ]; then | ||
echo "CLOUD_TO_USE environment variable must be set to one of the following: aws, azure, gce, openstack, static" | ||
exit 1 | ||
fi | ||
source "${BASH_SOURCE%/*}/set_cloud.sh" | ||
|
||
cloud_to_use=$(echo "$CLOUD_TO_USE" | tr '[:upper:]' '[:lower:]') | ||
case $cloud_to_use in | ||
aws|amazon) | ||
cloud_to_use=aws | ||
message="Cloud to be used is AWS.\nMake sure you've set the AWS authentication variables." | ||
;; | ||
azure|microsoft) | ||
cloud_to_use=azure | ||
message="Cloud to be used is Microsoft Azure.\nMake sure $HOME/.azure/credentials exists and it's correct." | ||
;; | ||
gce|google|gcp) | ||
cloud_to_use=gce | ||
message="Cloud to be used is Google Compute Engine.\nMake sure you've set the GCE authentication variables and JSON credentials file." | ||
;; | ||
openstack) | ||
message="Cloud to be used is OpenStack.\nMake sure you've sourced the OpenStack RC file." | ||
;; | ||
static) | ||
message="The static inventory will be used." | ||
;; | ||
*) | ||
message="CLOUD_TO_USE environment variable was set to \"$CLOUD_TO_USE\" but must be set to one of the following: aws, azure, gce, openstack, static" | ||
echo -e $message | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo -e $message | ||
ansible-playbook -i inventory/$cloud_to_use -e "cloud_name=$cloud_to_use" playbooks/configure_ambari.yml | ||
ansible-playbook -i "inventory/${cloud_to_use}" -e "cloud_name=${cloud_to_use}" playbooks/configure_ambari.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,5 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$CLOUD_TO_USE" ]; then | ||
echo "CLOUD_TO_USE environment variable must be set to one of the following: aws, azure, gce, openstack, static" | ||
exit 1 | ||
fi | ||
source "${BASH_SOURCE%/*}/set_cloud.sh" | ||
|
||
cloud_to_use=$(echo "$CLOUD_TO_USE" | tr '[:upper:]' '[:lower:]') | ||
case $cloud_to_use in | ||
aws|amazon) | ||
cloud_to_use=aws | ||
message="Cloud to be used is AWS.\nMake sure you've set the AWS authentication variables." | ||
;; | ||
azure|microsoft) | ||
cloud_to_use=azure | ||
message="Cloud to be used is Microsoft Azure.\nMake sure $HOME/.azure/credentials exists and it's correct." | ||
;; | ||
gce|google|gcp) | ||
cloud_to_use=gce | ||
message="Cloud to be used is Google Compute Engine.\nMake sure you've set the GCE authentication variables and JSON credentials file." | ||
;; | ||
openstack) | ||
message="Cloud to be used is OpenStack.\nMake sure you've sourced the OpenStack RC file." | ||
;; | ||
static) | ||
message="The static inventory will be used." | ||
;; | ||
*) | ||
message="CLOUD_TO_USE environment variable was set to \"$CLOUD_TO_USE\" but must be set to one of the following: aws, azure, gce, openstack, static" | ||
echo -e $message | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo -e $message | ||
ansible-playbook -i inventory/$cloud_to_use -e "cloud_name=$cloud_to_use" playbooks/install_ambari.yml | ||
ansible-playbook -i "inventory/${cloud_to_use}" -e "cloud_name=${cloud_to_use}" playbooks/install_ambari.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,5 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$CLOUD_TO_USE" ]; then | ||
echo "CLOUD_TO_USE environment variable must be set to one of the following: aws, azure, gce, openstack, static" | ||
exit 1 | ||
fi | ||
source "${BASH_SOURCE%/*}/set_cloud.sh" | ||
|
||
cloud_to_use=$(echo "$CLOUD_TO_USE" | tr '[:upper:]' '[:lower:]') | ||
case $cloud_to_use in | ||
aws|amazon) | ||
cloud_to_use=aws | ||
message="Cloud to be used is AWS.\nMake sure you've set the AWS authentication variables." | ||
;; | ||
azure|microsoft) | ||
cloud_to_use=azure | ||
message="Cloud to be used is Microsoft Azure.\nMake sure $HOME/.azure/credentials exists and it's correct." | ||
;; | ||
gce|google|gcp) | ||
cloud_to_use=gce | ||
message="Cloud to be used is Google Compute Engine.\nMake sure you've set the GCE authentication variables and JSON credentials file." | ||
;; | ||
openstack) | ||
message="Cloud to be used is OpenStack.\nMake sure you've sourced the OpenStack RC file." | ||
;; | ||
static) | ||
message="The static inventory will be used." | ||
;; | ||
*) | ||
message="CLOUD_TO_USE environment variable was set to \"$CLOUD_TO_USE\" but must be set to one of the following: aws, azure, gce, openstack, static" | ||
echo -e $message | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo -e $message | ||
ansible-playbook -i inventory/$cloud_to_use -e "cloud_name=$cloud_to_use" playbooks/install_cluster.yml | ||
ansible-playbook -i "inventory/${cloud_to_use}" -e "cloud_name=${cloud_to_use}" playbooks/install_cluster.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,5 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$CLOUD_TO_USE" ]; then | ||
echo "CLOUD_TO_USE environment variable must be set to one of the following: aws, azure, gce, openstack, static" | ||
exit 1 | ||
fi | ||
source "${BASH_SOURCE%/*}/set_cloud.sh" | ||
|
||
cloud_to_use=$(echo "$CLOUD_TO_USE" | tr '[:upper:]' '[:lower:]') | ||
case $cloud_to_use in | ||
aws|amazon) | ||
cloud_to_use=aws | ||
message="Cloud to be used is AWS.\nMake sure you've set the AWS authentication variables." | ||
;; | ||
azure|microsoft) | ||
cloud_to_use=azure | ||
message="Cloud to be used is Microsoft Azure.\nMake sure $HOME/.azure/credentials exists and it's correct." | ||
;; | ||
gce|google|gcp) | ||
cloud_to_use=gce | ||
message="Cloud to be used is Google Compute Engine.\nMake sure you've set the GCE authentication variables and JSON credentials file." | ||
;; | ||
openstack) | ||
message="Cloud to be used is OpenStack.\nMake sure you've sourced the OpenStack RC file." | ||
;; | ||
static) | ||
message="The static inventory will be used." | ||
;; | ||
*) | ||
message="CLOUD_TO_USE environment variable was set to \"$CLOUD_TO_USE\" but must be set to one of the following: aws, azure, gce, openstack, static" | ||
echo -e $message | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo -e $message | ||
ansible-playbook -i inventory/$cloud_to_use -e "cloud_name=$cloud_to_use" playbooks/prepare_nodes.yml | ||
ansible-playbook -i "inventory/${cloud_to_use}" -e "cloud_name=${cloud_to_use}" playbooks/prepare_nodes.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$CLOUD_TO_USE" ]; then | ||
echo "CLOUD_TO_USE environment variable must be set to one of the following: aws, azure, gce, openstack, static" | ||
exit 1 | ||
fi | ||
|
||
cloud_to_use=$(echo "$CLOUD_TO_USE" | tr '[:upper:]' '[:lower:]') | ||
case $cloud_to_use in | ||
aws|amazon) | ||
cloud_to_use=aws | ||
message="Cloud to be used is AWS.\nMake sure you've set the AWS authentication variables." | ||
;; | ||
azure|microsoft) | ||
cloud_to_use=azure | ||
message="Cloud to be used is Microsoft Azure.\nMake sure $HOME/.azure/credentials exists and it's correct." | ||
;; | ||
gce|google|gcp) | ||
cloud_to_use=gce | ||
message="Cloud to be used is Google Compute Engine.\nMake sure you've set the GCE authentication variables and JSON credentials file." | ||
;; | ||
openstack) | ||
message="Cloud to be used is OpenStack.\nMake sure you've sourced the OpenStack RC file." | ||
;; | ||
static) | ||
message="The static inventory will be used." | ||
;; | ||
terraform) | ||
message="The terraform inventory will be used." | ||
;; | ||
*) | ||
message="CLOUD_TO_USE environment variable was set to \"$CLOUD_TO_USE\" but must be set to one of the following: aws, azure, gce, openstack, static, terraform" | ||
echo -e $message | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo -e "${message}" | ||
|