GitHub: wesleykirkland/terraform-docker-remote-docker-compose
Designed and originally created to remotely execute docker-compose stacks on unraid via remote ssh. Portainer stack management became unusable and with MacVLAN stack management became impossible.
Depends upon docker-compose being in the path on the remote system.
#Use a local module call to decrypt .env file - MODULE NOT INCLUDED
# module "sample_decrypt" {
# source = "./modules/sops-decrypt"
# stack_name = "dashy"
# env_file = "./envs/dashy.env"
# }
#Call Module to call remote docker-compose
module "sample" {
source = "/Path/to/module/terraform-docker-remote-docker-compose"
docker_host = "docker.example.com"
local_compose_file = "dashy.yaml"
remote_compose_path = "/mnt/disk1/appdata/docker"
env_file = module.sample_decrypt.env_path
source_env_file = "./envs/sample.enc.env"
ssh_key = "~/.ssh/jenkins"
ssh_user = "username"
post_delete_env_file = false
compose_action = "delete"
depends_on = [module.sample_decrypt]
}
#Use a local module call to decrypt .env file - MODULE NOT INCLUDED
# module "sample_delete" {
# source = "./modules/sops-delete"
# stack_name = "dashy"
# env_file = "./envs/dashy.env"
# depends_on = [
# module.test
# ]
# }
Name | Version |
---|---|
terraform | >= 1.9.0 |
null | ~> 3.2 |
Name | Type |
---|---|
null_resource.cleanup | resource |
null_resource.decrypt_and_transfer | resource |
null_resource.post_delete_env_file | resource |
null_resource.remote_docker_compose | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
compose_action | Docker compose action up/down/delete | string |
"up" |
no |
docker_host | FQDN of your docker host to ssh to | string |
n/a | yes |
env_file | Unencrypted ENV file to pass to the docker compose stack | string |
null |
no |
force_pull_image | Docker compose force pull image | bool |
false |
no |
local_compose_file | Path to docker compose file on the local file system | string |
n/a | yes |
post_delete_env_file | Delete the ENV file after stack execution, highly not recommended | bool |
false |
no |
remote_compose_path | Path to docker compose file on the remote file system. We will make a folder with the stack name to store the stack in. | string |
n/a | yes |
source_env_file | Encrypted or unencrypted ENV file to pass to the docker compose stack. This is only used for checksum purposes. | string |
null |
no |
ssh_key | Path to the SSH key | string |
n/a | yes |
ssh_user | ssh user | string |
n/a | yes |
No outputs.
# Test your pre-commit hooks - This will force them to run on all files
pre-commit run --all-files
# Add your pre-commit hooks forever
pre-commit install
Note: Before reading, uncomment the code for the environment that you wish to apply the code to. This goes for both the init-tfvars and apply-tfvars folders.
Note, manual changes to the README will be overwritten when the documentation is updated. To update the documentation, run terraform-docs -c .config/.terraform-docs.yml .