Giter VIP home page Giter VIP logo

terraform-openstack-manual's Introduction

Terraform for OpenStack

Request resumed:

  • 3 VMs for controller instances
  • 2 VMs for compute instances
  • 2 VMs for storage instances
  • 1 VM for access, in this case, VPN instance
  • One keypair to acess all VMs
  • One floating IP for VPN instance
  • Two security groups, for SSH access (TCP 22) and VPN connection (UDP 1194)
  • One Object Storage
  • Storage intances needs one additional blank volume (each one)
  • Two netowrks, internal and external, for the VPN instance, controller instances and compute instances
  • One IP reserved in internal network
  • Two networks, main and replica, for the storage intances
  • One router for all networks
  • Compute instances and VPN instance needs access to the Storage's main network
  • Controller instances needs access to the Storage's main network and replica network

Terraform commands to execute:

OBS: the flag "-var-file" it's for the stored variables in a file

  • Set the variable "external_remote_ip" with your public IP
/usr/bin/sed -i "s/external_remote_ip\s*=.*/external_remote_ip = \"$(curl -s ifconfig.io)\/32\"/" openstack_variables-sample.tfvars && terraform fmt
  • Initiate directory for Terraform:
terraform init -var-file=openstack_variables.auto.tfvars
  • Format/Linting
terraform fmt
  • Validate configurations files (*.tf) in the current directory:
terraform validate
  • Plan the code to execute:
terraform plan -var-file=openstack_variables.auto.tfvars
  • Execute the code:
terraform apply -auto-approve -var-file=openstack_variables.auto.tfvars
  • Undo everything you did in the command "apply"
terraform destroy -auto-approve -var-file=openstack_variables.auto.tfvars

Openstack Command line

  • Loading credentials/Exporting to the terminal environment
source ./app-cred-cli-project-name-terraform-openrc.sh
  • Add new public IP to security group to allow ssh access
openstack security group rule create openstack-security-group-access --ingress --protocol tcp --dst-port 22 --remote-ip $(curl -s ifconfig.io)
  • Login/SSH
openstack server ssh -i openstack.key -l rocky <vm-name>
  • Attaching floating IP
openstack floating ip list
openstack server add floating ip <server-name-or-id> <floating-ip>

Structure

$ tree
.
├── ansible.key
├── ansible.key.pub
├── app-cred-cli-project-name-terraform-openrc.sh
├── cloud-config.yaml
├── LICENSE
├── main.tf
├── openstack.key
├── openstack.key.pub
├── openstack_variables.auto.tfvars
├── openstack_variables-sample.tfvars
├── README.md
├── terraform.tfstate
└── terraform.tfstate.backup

terraform-openstack-manual's People

Contributors

dimas-prates avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.