Skip to content
Snippets Groups Projects
Forked from rc / Terraform Openstack
67 commits behind the upstream repository.
John-Paul Robinson's avatar
John-Paul Robinson authored
Collapse compute node and ood ops provisioners into a single
null_resource to avoid a race condition when the ansible tasks
run in parallel.  This lead to inconsistent deploys where
the slurm configuration was not working after deploy.

Putting the provisioners in a single resource ensures they run in
series.  This comes at the cost of a loss of deploy flexibility.
Now ood and compute nodes ops steps will always run on changes rather
than selectively.  Since this feature wasn't fully functional, it's
loss is not significant.
b65cbbeb
History

Terraform Openstack

This will create:

  • dmznet and dmzsubnet

  • borderrouter that connects dmznet to bright-external-flat-externalnet

  • a floating ip address, and an instance coming off of dmznet

  • clusternet off of dmznet instance

  • clustersubnet will connect instance to ood through ohpc and download software

Make a new directory for Terraform:

  • $mkdir terraform-first-instance

Install Terraform:

Install terraform from your systems package manager or directly from HashiCorp. Terraform is a single binary so it's easy to maintain the latest release version from the distributed zip files.

On a Mac (using brew package manager):

  • $brew install terraform

On a linux box (using the upstream package installed to personal ~/bin already in the $PATH):

wget https://releases.hashicorp.com/terraform/0.12.3/terraform_0.12.3_linux_amd64.zip
unzip terraform_0.12.3_linux_amd64.zip -d ~/bin

Unzip the file and make a path to your new directory using:

  • $export TERRAFORM_DIR="$(pwd)/terraform-first-instance

  • $cp $HOME/Downloads/terraform_0.6.16_linux_amd64/terraform $TERRAFORM_DIR

Create a new application credintial in Openstack:

  • In Openstack, go to Identity -> Application Credentials

  • Click "Create Application Credential"

  • Name the credential, add a description, and check the box making it unrestricted (Leave the rest blank. It is important not to add an expiration date.)

  • Download the credentials as an RC file.

  • Save credentials RC file in your terraform-first-instance directory.

Clone this repo into your terraform-first-instance directory using:

  • $git clone --recursive https://gitlab.rc.uab.edu/rrand11/terraform-openstack.git

Source the RC file and initialize terraform:

  • $source CREDENTIALRCFILENAME

  • $cd terraform-openstack

  • $terraform init

Write Terraform Plan to your terraform-first-instance directory and run that plan:

  • $terraform plan -out $HOME/terraform-first-instance/terraform-plan.tf

(Note) $terraform plan -out writes the plan to a file and then terraform apply runs that plan.

  • $terraform apply "$HOME/terraform-first-instance/terraform-plan.tf"

There's a target parameter that will let you specify just one module as defined in the root main file. Run it via plan like so:

  • $terraform plan -out $HOME/terraform-first-instance/name-of-plan.tf -target=module.name-of-module-to-run

(Note) You can also target multiple modules.

  • $terraform plan -out $HOME/terraform-first-instance/name-of-plan.tf -target=module.name-of-module -target=module.name-of-other-module

Destroy Terraform Instance:

  • $terraform destroy