Expected Outcome
Debug Terraform Enterprise Flexible Deployment Options startup issues.
Prerequisites
- Terraform Enterprise Flexible Deployment Options (Docker/Podman)
Use Case
The Terraform Enterprise application fails to start without sufficient details in the logs.
Procedure
Docker
- Edit the
docker-compose.yaml
to add a custom entrypoint, e.g:
---
name: terraform-enterprise
services:
tfe:
image: images.releases.hashicorp.com/hashicorp/terraform-enterprise:<vYYYYMM-#>
## Adding Custom Entrypoint for Troubleshooting Startup Issues
entrypoint: "tail -f /dev/null"
environment:
TFE_LICENSE: "<Hashicorp license>"
... truncated - Optional - To gather logs for Support
# Modify the docker-compose.yaml
read_only: false
tmpfs:
- /tmp:mode=01777
- /run
#- /var/log/terraform-enterprise - Deploy the container after saving the changes
docker compose up -d
- Launch the Terraform Enterprise Startup script
docker exec -it terraform-enterprise-tfe-1 /usr/local/bin/supervisord-run
- Once the Startup script exits proceed to review the logs to identify the root cause(example output)
# From the Docker container
docker exec -it -w /var/log/terraform-enterprise terraform-enterprise-tfe-1 sh -c 'ls -l&&bash'
total 20
-rw-r--r-- 1 terraform-enterprise root 1022 Jul 18 22:27 redis.log
-rw-r--r-- 1 terraform-enterprise root 1197 Jul 18 22:27 supervisord.log
-rw-r--r-- 1 terraform-enterprise root 9941 Jul 18 22:27 terraform-enterprise.log
# From the Linux host root access is required
cd $(docker inspect terraform-enterprise-tfe-1 --format '{{.GraphDriver.Data.MergedDir }}')/var/log/terraform-enterprise && ls -l
total 20
-rw-r--r-- 1 mj root 1022 Jul 18 17:27 redis.log
-rw-r--r-- 1 mj root 1197 Jul 18 17:27 supervisord.log
-rw-r--r-- 1 mj root 9941 Jul 18 17:27 terraform-enterprise.log - Optional - Create a
.tar.gz
file with the Terraform Enterprise logs
# Sudo access is required
sudo tar cvzf /path/to/save/terraform-enterprise.logs.tar.gz $(docker inspect terraform-enterprise-tfe-1 --format '{{.GraphDriver.Data.MergedDir }}')/var/log/terraform-enterprise
Podman
- Edit the
<kube.yaml>
to add a custom entrypoint, eg:---
apiVersion: "v1"
kind: "Pod"
metadata:
labels:
app: "terraform-enterprise"
name: "terraform-enterprise"
spec:
restartPolicy: "Never"
containers:
- env:
- name: "TFE_OPERATIONAL_MODE"
... truncated
image: "images.releases.hashicorp.com/hashicorp/terraform-enterprise:<vYYYYMM-#>"
## Adding Custom Entrypoint for Troubleshooting Startup Issues
command: [ "/bin/bash", "-c", "--" ]
args: [ "while true; do sleep 3600; done;" ]
... truncated - Deploy the pod after saving the changes
podman play kube /path/to/<kube.yaml>
- Launch the Terraform Enterprise Startup script
podman exec -it terraform-enterprise-terraform-enterprise /usr/local/bin/supervisord-run
- Once the Startup script exits proceed to review the logs to identify the root cause(example output)
# From the Podman container
podman exec -it -w /var/log/terraform-enterprise terraform-enterprise-terraform-enterprise sh -c 'ls -l&&bash'
total 24
-rw-r--r--. 1 terraform-enterprise root 1547 Jul 19 15:28 postgres.log
-rw-r--r--. 1 terraform-enterprise root 1022 Jul 19 15:28 redis.log
-rw-r--r--. 1 terraform-enterprise root 1344 Jul 19 15:28 supervisord.log
-rw-r--r--. 1 terraform-enterprise root 9010 Jul 19 15:28 terraform-enterprise.log - Optional - Create a
.tar.gz
file with the Terraform Enterprise logs
# Create the terraform-enterprise.logs.tar.gz file inside the Podman container and copy it to the Linux host filesystem
podman exec -it terraform-enterprise-terraform-enterprise sh -c 'tar cvzf /tmp/terraform-enterprise.logs.tar.gz /var/log/terraform-enterprise/' && podman cp terraform-enterprise-terraform-enterprise:/tmp/terraform-enterprise.logs.tar.gz /path/to/save/file/