Terraform and OpenStack
Terraform: Use Infrastructure as Code to provision and manage any cloud, infrastructure, or service
OpenStack: cloud operating system open source for creating public and private instances.
Requirements
- An OpenStack user
- OpenStack environment variables
- SSH key: generate your key pair
- Terraform executable
- wget https://releases.hashicorp.com/terraform/0.12.9/terraform_0.12.9_linux_amd64.zip
- unzip terraform_0.12.9_linux_amd64.zip
- sudo mv terraform /usr/local/bin/terraform
- terraform -v
- OpenStack executables
- sudo apt install python-openstackclient
Virtual Environment
- python3 -m venv venv
- source venv/bin/activate
Create an Terraform environment
- terraform env new test_terrafor
Run file with OpenStack environment variables
- .terraform-openrc.sh
complete this file with information about openstack (you can obtain this in your private account at openstack)
Create an instance
- pip install python-novaclient
- pip install python-glanceclient
- To find all flavor names, or instances types: nova flavor-list
- To find all image name: glance image-list
- Create file simple_instance.tf
Run
- terraform apply
Run in a new session
- .terraform-openrc.sh
- nova flavor-list