README.md 2.7 KB
Newer Older
Ryan Randles Jones's avatar
Ryan Randles Jones committed
1
# Terraform Openstack
Ryan Randles Jones's avatar
Ryan Randles Jones committed
2

3
### This will create:
Ryan Randles Jones's avatar
Ryan Randles Jones committed
4

5
- dmznet and dmzsubnet
Ryan Randles Jones's avatar
Ryan Randles Jones committed
6

7
- borderrouter that connects dmznet to bright-external-flat-externalnet
Ryan Randles Jones's avatar
Ryan Randles Jones committed
8

9
- a floating ip address, and an instance coming off of dmznet
Ryan Randles Jones's avatar
Ryan Randles Jones committed
10

11
- clusternet off of dmznet instance
Ryan Randles Jones's avatar
Ryan Randles Jones committed
12

13
14
- clustersubnet
will connect instance to ood through ohpc and download software
Ryan Randles Jones's avatar
Ryan Randles Jones committed
15

16
### Make a new directory for Terraform:
Ryan Randles Jones's avatar
Ryan Randles Jones committed
17

18
- `$mkdir terraform-first-instance`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
19

20
### Install Terraform:
Ryan Randles Jones's avatar
Ryan Randles Jones committed
21

22
23
24
25
26
27
Install terraform from your systems package manager or [directly from HashiCorp](https://learn.hashicorp.com/terraform/getting-started/install.html).
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):

28
- `$brew install terraform`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
29

30
31
32
33
34
35
36
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
```

37
### Unzip the file and make a path to your new directory using:
Ryan Randles Jones's avatar
Ryan Randles Jones committed
38

39
- `$export TERRAFORM_DIR="$(pwd)/terraform-first-instance`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
40

41
- `$cp $HOME/Downloads/terraform_0.6.16_linux_amd64/terraform $TERRAFORM_DIR`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
42

43
### Create a new application credintial in Openstack:
44

45
- In Openstack, go to **Identity** -> **Application Credentials**
46

47
- Click "**Create Application Credential**"
48

Ishan Patel's avatar
Ishan Patel committed
49
- 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.)
50

Ishan Patel's avatar
Ishan Patel committed
51
- Download the credentials as an RC file.
52

Ryan Randles Jones's avatar
Ryan Randles Jones committed
53
- Save credentials RC file in your terraform-first-instance directory.
Ryan Randles Jones's avatar
Ryan Randles Jones committed
54

Ryan Randles Jones's avatar
Ryan Randles Jones committed
55

Ryan Randles Jones's avatar
Ryan Randles Jones committed
56
### Clone this repo into your terraform-first-instance directory using:
Ryan Randles Jones's avatar
Ryan Randles Jones committed
57

Ryan Randles Jones's avatar
Ryan Randles Jones committed
58
- `$git clone --recursive https://gitlab.rc.uab.edu/rrand11/terraform-openstack.git`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
59

Ryan Randles Jones's avatar
Ryan Randles Jones committed
60
### Source the RC file and initialize terraform:
Ryan Randles Jones's avatar
Ryan Randles Jones committed
61

62
- `$source CREDENTIALRCFILENAME`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
63

64
- `$cd terraform-openstack`
Ryan Jones's avatar
Ryan Jones committed
65

66
- `$terraform init`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
67

68
### Write Terraform Plan to your terraform-first-instance directory and run that plan:
Ryan Randles Jones's avatar
Ryan Randles Jones committed
69

70
- `$terraform plan -out $HOME/terraform-first-instance/terraform-plan.tf`
Ryan Jones's avatar
Ryan Jones committed
71

72
**_(Note)_** `$terraform plan -out` writes the plan to a file and then `terraform apply` runs that plan.
Ryan Randles Jones's avatar
Ryan Randles Jones committed
73

74
- `$terraform apply "$HOME/terraform-first-instance/terraform-plan.tf"`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
75
76


77
### 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:
Ryan Randles Jones's avatar
Ryan Randles Jones committed
78

79
80
81
82
83
- `$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`
Ryan Randles Jones's avatar
Ryan Randles Jones committed
84

Ryan Jones's avatar
Ryan Jones committed
85

86
### Destroy Terraform Instance:
Ryan Jones's avatar
Ryan Jones committed
87

88
- `$terraform destroy`