From 57d175d7949e52170f8ffd15cb836370e6bcc6ef Mon Sep 17 00:00:00 2001 From: Nemo Date: Fri, 30 Mar 2018 10:29:26 +0530 Subject: [PATCH] Attempt at migrating to a second entrypoint --- main.tf | 8 ++++++-- timemachine/entrypoint.sh.tpl | 8 ++++++++ timemachine/main.tf | 21 +++++++++++++++++++++ timemachine/variables.tf | 5 +++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100755 timemachine/entrypoint.sh.tpl diff --git a/main.tf b/main.tf index a246b37..0e393e1 100644 --- a/main.tf +++ b/main.tf @@ -26,8 +26,12 @@ module "docker" { } module "timemachine" { - source = "timemachine" - ips = "${var.ips}" + source = "timemachine" + ips = "${var.ips}" + username-1 = "vikalp" + password-1 = "vikalp" + username-2 = "rishav" + password-2 = "vikalp" } module "gitea" { diff --git a/timemachine/entrypoint.sh.tpl b/timemachine/entrypoint.sh.tpl new file mode 100755 index 0000000..5dbb002 --- /dev/null +++ b/timemachine/entrypoint.sh.tpl @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +add-account ${username-1} ${password-1} "${username-1}-timemachine" "/timemachine/${username-1}-timemachine" 3000 +add-account ${username-2} ${password-2} "${username-2}-timemachine" "/timemachine/${username-2}-timemachine" 3000 + +/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf diff --git a/timemachine/main.tf b/timemachine/main.tf index f707054..3d7cdab 100644 --- a/timemachine/main.tf +++ b/timemachine/main.tf @@ -28,7 +28,28 @@ resource docker_container "timemachine" { ip = "${var.ips["eth0"]}" } + upload { + content = "${data.template_file.timemachine-entrypoint.rendered}" + file = "/entrypoint-custom.sh" + } + + entrypoint = [ + "/entrypoint-custom.sh", + ] + restart = "unless-stopped" destroy_grace_seconds = 10 must_run = true } + +data "template_file" "timemachine-entrypoint" { + template = "${file("${path.module}/entrypoint.sh.tpl")}" + + vars { + username-1 = "${var.username-1}" + password-1 = "${var.password-1}" + + username-2 = "${var.username-2}" + password-2 = "${var.password-2}" + } +} diff --git a/timemachine/variables.tf b/timemachine/variables.tf index f7b7a99..c998ce4 100644 --- a/timemachine/variables.tf +++ b/timemachine/variables.tf @@ -1,3 +1,8 @@ variable "ips" { type = "map" } + +variable "username-1" {} +variable "username-2" {} +variable "password-2" {} +variable "password-1" {}