terraform-provider-rancher icon indicating copy to clipboard operation
terraform-provider-rancher copied to clipboard

rendered_docker_compose differs from original one

Open M1strall opened this issue 6 years ago • 2 comments

Hi there, It seems I've caught an issue with some interpolation of docker-compose that is done by rancher provider. I'm getting docker-compose.yml row: tag: "{{.ImageName}}/{{.Name}}/{{.ID}}" replaced with: tag: <no value>/<no value>/<no value>

To comment, this expression is not supposed to be interpolated, but preserved "as is", since this is a Splunk-driver expression.

Terraform Version

Terraform v0.11.14

Affected Resource(s)

docker-compose.yml

Terraform Configuration Files

resource "rancher_stack" "my-api" {
  name = "my-api"
  description = "API Stack"
  environment_id = "${var.rancher_environment_id}"
  start_on_create = "true"
  finish_upgrade = "true"
  docker_compose = "${file("${path.module}/docker-compose-api.yml")}"
  rancher_compose = "${file("${path.module}/rancher-compose-api.yml")}"
  scope = "user"

docker-compose.yml

version: '2'
services:
  my-api:
   #part of compose ommited for breavity
     logging:
       driver: splunk
       options:
        #some splunk env variables
         splunk-token: ${TOKEN_SPLUNK}
         splunk-url: 'https://input.mysplunk.com'
         tag: "{{.ImageName}}/{{.Name}}/{{.ID}}"

Expected Behavior

Docker-compose.yml should've been applied "as specified" for Rancher stack

Actual Behavior

Actually applied docker compose (showing up in rendered_docker_compose: "" => "" in diff) looks like this:

version: '2'
services:
  my-api:
   #part of compose ommited for breavity
     logging:
       driver: splunk
       options:
        #some splunk env variables
         splunk-token: ${TOKEN_SPLUNK}
         splunk-url: 'https://input.mysplunk.com'
         tag: <no value>/<no value>/<no value>

Steps to Reproduce

  1. terraform apply

M1strall avatar Dec 06 '19 22:12 M1strall

I don't see why that would happen, as we do not interpolate this string. Is it the Rancher export action that causes it to be interpreted maybe?

raphink avatar Jan 14 '20 09:01 raphink

Try to use go template's raw string:

tag: "{{`{{.ImageName}}`}}/{{`{{.Name}}`}}/{{`{{.ID}}`}}"

greenu avatar Mar 20 '20 12:03 greenu