Tutorial using Terraform with IU Jetstream
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
example.tfvars
inputs.tf
main.tf
network.tf

README.md

Terraform Automating NSF Jetstream

Jetstream is an Openstack deployment at IU and TACC. Researchers can request free access to Jetstream by the XSEDE allocation process.

Jetstream mostly looks to support scientific use via atmosphere. Many power users may wish to deploy their own infrastructure on Jetstream using the Openstack API. I (Brock Palen) find the CLI API to be cumbersome and not a joy to automate. Thus I turned to my favorite tool Terraform to see if I could make it work with Jetstream.

This shows how:

Setup

openrc.sh

export OS_PROJECT_DOMAIN_NAME=tacc
export OS_USER_DOMAIN_NAME=tacc
export OS_PROJECT_NAME=<YOUR PROJECT>
export OS_USERNAME=<YOUR USERNAME>
export OS_PASSWORD=<YOUR TACC PASSWORD>
export OS_AUTH_URL=<SENT WITH API ACCESS>
export OS_IDENTITY_API_VERSION=3

Setup SSH Public Key

  • Create an key ssh-keygen -t rsa -f mykeyname

Terraform and project setup

In the directory you cloned this repo into Download Terraform and unzip the single static binary.

The repo will work out of the box with only an SSH Key

  • Source your Jetstream credentials: source openrc.sh
  • Do once: terraform init
  • See a plan with defaults: terraform plan -var 'keypair-path=mykeyname.pub'
  • Deploy: terraform apply -var 'keypair-path=mykeyname.pub'

At this point if all went well in the Horizon UI you should see your sever and terraform should have printed the IP address of your host. You can SSH to your host with:

ssh -i mykeyname -l centos IPADDRESS 
  • Tear it all down: terraform destroy -var 'keypair-path=mykeyname.pub'

Using a config file

  • All inputs are defined in input.tf but don't change those
  • Copy example.tfvars and edit the values you want
  • terraform plan -var-file=example.tfvars
  • terraform apply -var-file=example.tfvars
  • terraform destroy -var-file=example.tfvars

FAQ

Q: What are the tfstate files?

A: Don't delete them, Terraform remembers your state, if you change a value plan and apply will show what changes will be made, but unchanged items will be untouched.

Q: How can I start multiple hosts?

A: Change the quantity variable in your tfvars file, Terraform will then start multiple hosts and not touch the existing ones or networks.

Q: Why do I have to manually make all the network items in network.tf? The Terraform Openstack docs don't show doing that?

A: On Jetstream there are no default public networks etc, so if you don't create your own and attach it to the public network with a floating IP you can't connect to it.

Q: How can I automate more?

A: That is beyond the scope of this, but you could make your own image, or you can look to Terrraforms remote-exec provisioner to run commands on your host after it starts up.