Skip to content
DevOps-Kv-116Public

About

terraform config DevOps-Kv-116

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

To begin with

install gcloud for your OS

gcloud auth login yourlogin@gmail.com

To check which account is logged in run

gcloud auth list

install python3 & pip for your OS install ansible with pip install terraform for your OS

Bootstrap

cd /opt
sudo git clone https://github.com/DevOps-Kv-116/terra.git
sudo chown yourusername /opt/terra -R
cd /terra

bootstrap.sh script is interactive

./bootstrap.sh

The script will create new project, enable API's, service account, transfers variables to terraform & other cool stuff, strongly advise You to read it before executing, it is self-explanatory. Script will create envvars.sh & sa-private-key.json files

source envvars.sh

Terraform

Repo lacks start.tpl file as it is stateful, after adding it to repo folder you are good to go.

terraform init
terraform plan
terraform apply --auto-approve
terraform destroy --auto-approve
terraform destroy -target  google_compute_instance.vm_instance --auto-approve

Magic

Terraform creates vpc & subnet with static external IP address, e2-medium google compute instance(can be changed in vars.tfvars) & generates docker-compose.yaml from template using variables provided & vm's IP. Finally, terraform will run ansible playbook with vm's IP & google credentials. Ansible playbook tasks:

  • add docker repo
  • install docker
  • dnf update
  • docker start & enable
  • curl docker-compose
  • symlink docker-compose /usr/bin/
  • Chmod docker-compose +x
  • Install git
  • git clone 5 repos
  • run docker-compose with file generated by startup script

About

terraform config DevOps-Kv-116

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages