Introduction
This guide runs through the steps for uninstalling Terraform Enterprise, the standalone installation. Terraform Enterprise is managed via the Replicated service, which can be used to uninstall Terraform Enterprise.
Precaution
Prior to uninstalling Terraform Enterprise, it is recommended to export the existing application configuration for reference. Some critical information such as encryption password is required to match the previous installation if reinstallation is needed, otherwise Terraform Enterprise will not be able to retrieve the existing information stored on Postgres database and BLOB storage due to the failure to bootstrap Vault container in which provides encryption and decryption keys for those data. The following command can be used to export application configuration.
replicatedctl app-config export --hidden
Procedure
First, stop the Terraform Enterprise application from the Replicated console on port 8800 or in the command line using the replicatedctl
tool:
replicatedctl app stop
Verify that the Terraform Enterprise application is stopped using the following command:
replicatedctl app status
The output should show the State
as stopped
. Please note, it may take a few minutes. This process stops and removes the Docker containers running the Terraform Enterprise application.
Once Terraform Enterprise is stopped, stop the Replicated services:
# SysVinit
service replicated stop
service replicated-ui stop
service replicated-operator stop
# Systemd
systemctl stop replicated replicated-ui replicated-operator
systemctl disable replicated replicated-ui replicated-operator
Next, stop and remove the Replicated containers:
docker rm -f replicated replicated-ui replicated-operator replicated-premkit replicated-statsd retraced-api retraced-processor retraced-cron retraced-nsqd retraced-postgres
Remove all Replicated files and executable from the host:
rm -rf /etc/default/replicated* /etc/init.d/replicated* /etc/init/replicated* /etc/replicated /etc/replicated.alias /etc/sysconfig/replicated* /etc/systemd/system/multi-user.target.wants/replicated* /etc/systemd/system/replicated* /run/replicated* /usr/local/bin/replicated* /var/lib/replicated* /var/log/upstart/replicated*
# Optionally, run systemd daemon-reload
systemctl daemon-reload
If mounted disk installation, remove the PostgreSQL database:
# The mounted disk path. The `tr` is needed to remove the carriage return.
mounted_disk_path="$(replicatedctl app-config export --template '{{.disk_path.Value}}' | tr -d '\r')"
# Delete the PostgreSQL database
rm -r $mounted_disk_path/aux/ $mounted_disk_path/postgres $mounted_disk_path/postgres-backup
At this point, Terraform Enterprise and the Replicated applications should both be uninstalled. However, there are still Docker resources that need to be cleaned up. If there were no other Docker resources on the host aside from Terraform Enterprise, the images, networks, and volumes can safely be cleaned up with docker system prune
. If there were other resources, please double check all stopped containers and unused images, volumes, build caches, and networks before running the below command:
docker system prune -a --volumes
Alternatively, only the Terraform Enterprise and Replicated resources can be removed with the following commands. It is still recommended to double check before running these commands.
# List the images to be deleted to double check.
docker images | grep -E "quay.io/replicated|registry.replicated.com|terraformenterprise|replicated/sleep|hashicorp/build-worker|^.+:9874\/"
# Remove the images.
docker rmi -f $(docker images | grep -E "quay.io/replicated|registry.replicated.com|terraformenterprise|replicated/sleep|hashicorp/build-worker|^.+:9874\/" | awk '{print $3}')
# Remove Replicated Network
docker network rm replicated_retraced
# Remove all unused volumes
docker volume rm $(docker volume ls -q --filter "dangling=true")