-
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.
- Loading branch information
1 parent
b62dc32
commit 8e430d0
Showing
6 changed files
with
140 additions
and
40 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
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,7 +0,0 @@ | ||
|
||
[k8s-masters] | ||
ec2-52-52-180-22.us-west-1.compute.amazonaws.com ansible_ssh_host=52.52.180.22 ansible_ssh_port=22 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=/Users/aguda/Downloads/AWS/awstest.pem ansible_ssh_extra_args='-o StrictHostKeyChecking=no' | ||
|
||
[k8s-workers] | ||
ec2-13-57-111-53.us-west-1.compute.amazonaws.com ansible_ssh_host=13.57.111.53 ansible_ssh_port=22 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=/Users/aguda/Downloads/AWS/awstest.pem ansible_ssh_extra_args='-o StrictHostKeyChecking=no' | ||
ec2-13-57-45-138.us-west-1.compute.amazonaws.com ansible_ssh_host=13.57.45.138 ansible_ssh_port=22 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=/Users/aguda/Downloads/AWS/awstest.pem ansible_ssh_extra_args='-o StrictHostKeyChecking=no' | ||
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,15 +1,111 @@ | ||
|
||
cd terraform | ||
terraform init | ||
terraform plan | ||
terraform apply -auto-approve | ||
terraform output inventory > ../ansible/inventory | ||
azurecli() { | ||
systype=$(uname -s) | ||
|
||
echo "Please wait for a while to bring aws instances up" | ||
if [[ $systype == "Linux" ]]; then | ||
echo "Installing Azure CLI for Azure Authentication" | ||
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | ||
elif [[ $systype == "Darwin" ]]; then | ||
echo "Installing Azure CLI for Azure Authentication" | ||
brew update && brew install azure-cli | ||
else | ||
echo "System should be either Mac or Linux" | ||
exit 0 | ||
fi | ||
} | ||
|
||
sleep 60 | ||
cd ../ansible | ||
ansible -m ping -i inventory all | ||
ansible-playbook -i inventory prerequisites.yaml | ||
ansible-playbook -i inventory k8s.yaml | ||
terraforminstall() { | ||
systype=$(uname -s) | ||
|
||
if [[ $systype == "Linux" ]]; then | ||
echo "Installing Terraform" | ||
curl -sL https://raw.github.com/robertpeteuil/terraform-installer/master/terraform-install.sh > terraform-install.sh | ||
chmod +x terraform-install.sh | ||
./terraform-install.sh | ||
rm -rf terraform-install.sh | ||
elif [[ $systype == "Darwin" ]]; then | ||
echo "Installing Terraform" | ||
brew tap hashicorp/tap | ||
brew install hashicorp/tap/terraform | ||
else | ||
echo "System should be either Mac or Linux" | ||
exit 0 | ||
fi | ||
} | ||
|
||
installansible() { | ||
systype=$(uname -s) | ||
if [[ $systype == "Linux" ]]; then | ||
echo "Installing Ansible" | ||
os=$(cat /etc/os-release | grep -iw ID | awk -F'=' '{print $2}') | ||
version=$(cat /etc/os-release | grep -i VERSION_CODENAME | awk -F'=' '{print $2}') | ||
if [[ $os == "ubuntu" && $version != "focal" ]]; then | ||
echo "Installing Ansible" | ||
sudo apt-add-repository ppa:ansible/ansible -y | ||
sudo apt update | ||
sudo apt install ansible -y | ||
elif [[ $os == "ubuntu" && $version == "focal" ]]; then | ||
echo "Installing Ansible" | ||
sudo apt update | ||
sudo apt install ansible -y | ||
elif [ $os == "rhel*" ]; then | ||
version=$(cat /etc/os-release | grep VERSION_ID | awk -F'=' '{print $2}') | ||
if [ $version == "*7.*" ]; then | ||
sudo subscription-manager repos --enable rhel-7-server-ansible-2.9-rpms | ||
sudo yum install ansible -y | ||
elif [ $version == "*8.*" ]; then | ||
sudo subscription-manager repos --enable ansible-2.9-for-rhel-8-x86_64-rpms | ||
sudo yum install ansible -y | ||
fi | ||
fi | ||
elif [[ $systype == "Darwin" ]]; then | ||
echo "Installing Ansible" | ||
brew install ansible | ||
else | ||
echo "System should be either Mac or Linux" | ||
exit 0 | ||
fi | ||
} | ||
|
||
if [[ $1 == "azure" ]]; then | ||
installansible | ||
azurecli | ||
echo "Login to Azure Account using your browser" | ||
az login | ||
echo "Login Successfull" | ||
terraforminstall | ||
cd terraform/azure | ||
terraform init | ||
terraform plan | ||
terraform apply -auto-approve | ||
terraform output inventory > ../../ansible/inventory | ||
rm -rf azure.pem | ||
terraform ouput tls_private_key > azure.pem | ||
chmod 400 azure.pem | ||
|
||
echo "Please wait for a while to bring azure vm's are up" | ||
|
||
sleep 60 | ||
cd ../../ansible | ||
ansible -m ping -i inventory all | ||
ansible-playbook -i inventory prerequisites.yaml | ||
ansible-playbook -i inventory k8s.yaml | ||
elif [[ $1 == "aws" ]]; then | ||
installansible | ||
terraforminstall | ||
cd terraform/aws | ||
terraform init | ||
terraform plan | ||
terraform apply -auto-approve | ||
terraform output inventory > ../../ansible/inventory | ||
|
||
echo "Please wait for a while to bring aws instances up" | ||
|
||
sleep 60 | ||
cd ../../ansible | ||
ansible -m ping -i inventory all | ||
ansible-playbook -i inventory prerequisites.yaml | ||
ansible-playbook -i inventory k8s.yaml | ||
else | ||
echo -e "Usage\n\nAvailable Options:\n\n aws: To Provision Kubernetes Cluster on AWS\n azure: To Provision Kubernetes Cluster on Azure\n" | ||
fi |
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
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
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