Terraform Automating NSF Jetstream
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:
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:
- Do once:
- See a plan with defaults:
terraform plan -var 'keypair-path=mykeyname.pub'
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.tfbut don't change those
example.tfvarsand edit the values you want
terraform plan -var-file=example.tfvars
terraform apply -var-file=example.tfvars
terraform destroy -var-file=example.tfvars
Q: What are the
A: Don't delete them, Terraform remembers your state, if you change a value
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.