You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: operations/automation-script/README.md
+13-3Lines changed: 13 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,18 @@ The script does the following steps:
8
8
1. Packages main.tf into the myconfig.tar.gz file.
9
9
1. Creates the workspace.
10
10
1. Creates a new configuration version.
11
-
1. Uploads the myconfig.tar.gz file as a new configuration. (This step used to trigger an initial run which caused an error because we had not yet set the name variable in the workspace. But we now have configversion.json configured to use auto-queue-runs set to false. So, this run is no longer triggered.)
11
+
1. Uploads the myconfig.tar.gz file as a new configuration. (This step used to trigger an initial run which caused an error because we had not yet set the name variable in the workspace. But we now have configversion.json configured to use auto-queue-runs set to false. So, this run is no longer triggered.)
12
12
1. Adds one Terraform variable called "name" and one Environment variable called "CONFIRM_DESTROY" to the workspace, getting their values from the variables.csv file. You can edit this file to add as many variables as you want.
13
+
1. Determines the number of Sentinel policies.
13
14
1. Starts a new run.
14
15
1. Enters a loop to check the run results periodically.
16
+
- If $run_status is "planned", $is_confirmable is "True", and $override is "no", the script stops. In this case, no Sentinel policies existed or none of them were applicable to this workspace. The script will stop. The user should can apply the run in the Terraform Enterprise UI.
17
+
- If $run_status is "planned", $is_confirmable is "True", and $override is "yes", the script will do an apply. As in the previous case, no Sentinel policies existed or none of them were applicable to this workspace.
15
18
- If $run_status is "policy_checked", it does an Apply. In this case, all Sentinel policies passed.
16
19
- If $run_status is "policy_override" and $override is "yes", it overrides the failed policy checks and does an Apply. In this case, one or more Sentinel policies failed, but they were marked "advisory" or "soft-mandatory" and the script was configured to override the failure.
17
20
- If $run_status is "policy_override" and $override is "no", it prints out a message indicating that some policies failed and are not being overridden.
18
21
- If $run_status is "errored", either the plan failed or a Sentinel policy marked "hard-mandatory" failed. The script terminates.
22
+
- Other values of $run_status cause the loop to repeat after a brief sleep.
19
23
20
24
Note that some json template files are included from which other json files are generated so that they can be passed to the curl commands.
21
25
@@ -36,6 +40,12 @@ Do the following before using this script:
36
40
1.`cd operations/automation-script`
37
41
1. Make sure [python](https://www.python.org/downloads/) is installed on your machine and in your path since the script uses python to parse JSON documents returned by the Terraform Enterprise REST API.
38
42
43
+
## Using with Private Terraform Enteprise Server using private CA
44
+
If you use this script with a Private Terraform Enterprise (PTFE) server that uses a private CA instead of a public CA, you will need to ensure that the curl commands run by the script will trust the private CA. There are several ways to do this. The first is easiest for enabling the automation script to run, but it only affects curl. The second and third are useful for using the Terraform and TFE CLIs against your PTFE server. The third is a permanent solution.
45
+
1.`export CURL_CA_BUNDLE=<path_to_ca_bundle>`
46
+
1. Export the Golang SSL_CERT_FILE and/or SSL_CERT_DIR environment variables. For instance, you could set the first of these to the same CA bundle used in option 1.
47
+
1. Copy your certificate bundle to /etc/pki/ca-trust/source/anchors and then run `update-ca-trust extract`.
48
+
39
49
## Instructions
40
50
Follow these instructions to run the script with the included main.tf and variables.csv files:
41
51
@@ -45,7 +55,7 @@ Follow these instructions to run the script with the included main.tf and variab
45
55
1.`export ATLAS_TOKEN=<owners_token>` where \<owners_token\> is the token generated in the previous step.
46
56
1. If you want, you can also change the name of the workspace that will be created and the sleep_duration variable which controls how often the script checks the status of the triggered run (in seconds).
47
57
1. Edit variables.csv to specify the name you would like to set the name variable to by replacing "Roger" with some other name.
48
-
1. Run `./loadAndRunWorkspace.sh` or `./loadAndRunWorkspace.sh <override>` where \<override\> is "yes" or "no". If you do not specify a value for \<override\>, the script will set it to "no".
58
+
1. Run `./loadAndRunWorkspace.sh` or `./loadAndRunWorkspace.sh <override>` where \<override\> is "yes" or "no". If you do not specify a value for \<override\>, the script will set it to "no". The override variable is used in two ways: a) to automatically do an apply when no Sentinel policies exist or none of them are applicable to the workspace, and b) to override any soft-mandatory Sentinel policies that failed.
49
59
50
60
### Examples
51
61
`./loadAndRunWorkspace` (no override will be done)
@@ -55,7 +65,7 @@ Follow these instructions to run the script with the included main.tf and variab
55
65
`./loadAndRunWorkspace no` (no override will be done)
56
66
57
67
### Running with other Terraform code
58
-
If you would like to load other Terraform code into a workspace with the script, replace main.tf in the config directory with your own Terraform code. All files in the config directory will be uploaded to your TFE server. Also edit variables.csv to remove the first row with the name variable and add rows for any Terraform and Environment variables that are required by your Terraform code.
68
+
If you would like to load other Terraform code into a workspace with the script, replace main.tf in the config directory with your own Terraform code. All files in the config directory will be uploaded to your TFE server. Also edit variables.csv to remove the first row with the name variable and add rows for any Terraform and Environment variables that are required by your Terraform code. If your code has a terraform.tfvars file, please rename it to terraform.auto.tfvars since TFE overwrites any instance of terraform.tfvars with the variables set in the workspace. Adding variables already in a `*.auto.tfvars` file is not strictly necessary, but is recommended so that users looking at the workspace can see the values set on the variables.
59
69
60
70
## Cleaning Up
61
71
If you want to run the script again, delete the workspace from the Settings tab of the workspace in the TFE UI. You do not need to delete or touch any of the files in the directory containing the script and other files.
0 commit comments