File tree 6 files changed +97
-2
lines changed 6 files changed +97
-2
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # Terraform install
4
+ wget -q https://releases.hashicorp.com/terraform/1.0.11/terraform_1.0.11_linux_amd64.zip
5
+ unzip -o terraform_1.0.11_linux_amd64.zip -d ~
6
+
7
+ # Use Terraform to create the cluster
8
+ cd terraform/terraform_aws
9
+ ~ /terraform init
10
+ ~ /terraform apply -var=" cluster_size=3" -auto-approve
11
+ ~ /terraform output | grep ' "' | awk -F ' "' ' BEGIN {i=1; print "[cluster]"} {print "node0" i++ " ansible_host="$2}' > ../../terraform/ansible/hosts.ini
12
+ cd ../..
13
+
14
+ # Wait until docker is installed in all the nodes
15
+ echo " Waiting 30s for docker install process in the cluster nodes"
16
+ sleep 30
17
+
18
+ # Ansible configuration
19
+ mkdir ~ /.ssh
20
+
21
+ echo $VAULT_PASS > ~ /vault_passowrd_file.txt
22
+
23
+ ansible-vault decrypt \
24
+ --vault-password-file=~ /vault_passowrd_file.txt terraform/ansible/id_rsa_devops_encrypted \
25
+ --output=~ /.ssh/id_rsa
26
+
27
+ rm ~ /vault_passowrd_file.txt
28
+
29
+ # Use Ansible to configure the cluster
30
+ ansible-playbook -u ubuntu -i terraform/ansible/hosts.ini terraform/ansible/swarm/create_swarm.yml
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # Terraform install
4
+ wget -q https://releases.hashicorp.com/terraform/1.0.11/terraform_1.0.11_linux_amd64.zip
5
+ unzip -o terraform_1.0.11_linux_amd64.zip -d ~
6
+
7
+ # Use Terraform to collect the cluster ips
8
+ cd terraform/pipeline
9
+ ~ /terraform init
10
+ ~ /terraform apply -auto-approve
11
+ ~ /terraform output | grep ' "' | awk -F ' "' ' BEGIN {i=1; print "[cluster]"} {print "node0" i++ " ansible_host="$2}' > ../../terraform/ansible/hosts.ini
12
+ cd ../..
13
+
14
+ # Ansible configuration
15
+ mkdir ~ /.ssh
16
+
17
+ echo $VAULT_PASS > ~ /vault_passowrd_file.txt
18
+
19
+ ansible-vault decrypt \
20
+ --vault-password-file=~ /vault_passowrd_file.txt terraform/ansible/id_rsa_devops_encrypted \
21
+ --output=~ /.ssh/id_rsa
22
+
23
+ rm ~ /vault_passowrd_file.txt
24
+
25
+ # Use Ansible to configure the cluster
26
+ ansible-playbook -u ubuntu -i terraform/ansible/hosts.ini terraform/ansible/swarm/destroy_swarm.yml
27
+
28
+ # Use Terraform to destroy the cluster
29
+ cd terraform/terraform_aws
30
+ ~ /terraform init
31
+ ~ /terraform destroy -auto-approve
Original file line number Diff line number Diff line change
1
+ name : Create the cluster
2
+ on :
3
+ release :
4
+ jobs :
5
+ deploy :
6
+ runs-on : ubuntu-20.04
7
+ steps :
8
+ - name : Check out repository code
9
+ uses : actions/checkout@v2
10
+
11
+ - name : Create the cluster
12
+ run : .github/scripts/create_cluster.sh
13
+ env :
14
+ VAULT_PASS : ${{ secrets.VAULT_PASS }}
15
+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
16
+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
17
+
Original file line number Diff line number Diff line change 1
- name : Execute Ansible scripts
1
+ name : Deploy services to cluster
2
2
on :
3
3
push :
4
4
branches :
Original file line number Diff line number Diff line change
1
+ name : Destroy the cluster
2
+ on :
3
+ release :
4
+ jobs :
5
+ deploy :
6
+ runs-on : ubuntu-20.04
7
+ steps :
8
+ - name : Check out repository code
9
+ uses : actions/checkout@v2
10
+
11
+ - name : Destroy the cluster
12
+ run : .github/scripts/destroy_cluster.sh
13
+ env :
14
+ VAULT_PASS : ${{ secrets.VAULT_PASS }}
15
+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
16
+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
17
+
Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ variable "tag" {
11
11
variable "cluster_size" {
12
12
type = number
13
13
description = " Number of nodes in the cluster"
14
- default = 5
14
+ default = 2
15
15
}
You can’t perform that action at this time.
0 commit comments