0

I am passing a Terraform variable as list to an Ansible invcocation.

Here is my variable declaration

variable "jenkins_plugins_list" {
  description = "The list of jenkins' plugins to be installed"
  type = "list"
  default = ["kubernetes:1.21.2", "workflow-job:2.36", "workflow-aggregator:2.6", "credentials-binding:1.20", "git:4.0.0"]
}

And here is my Ansible invocation:

  provisioner "local-exec" {
    command = "ansible-playbook -vvv ${path.module}/playbooks/playbook.yaml -i ./playbooks/hosts --extra-vars \"{ \"k8s_cluster_name\": \"${local.k8s_name}\", \"zonename\": \"${var.zone}\", \"env_name\": \"${var.env_name}\", \"google_project_name\": \"${var.project_id}\", \"jenkins_master_image_tag\": \"${var.jenkins_master_image_tag}\", \"jenkins_agent_image_tag\": \"${var.jenkins_agent_image_tag}\", \"jenkins_plugins_list\": \"${jsonencode(var.jenkins_plugins_list)}\" }\""
  }
}

The latest is being rendered as follows:

helm upgrade --force --tls --install --set master.installPlugins=[u'kubernetes:1.21.2', u'workflow-job:2.36', u'workflow-aggregator:2.6', u'credentials-binding:1.20', u'git:4.0.0'] --set master.tag=lts --set agent.tag=3.27-1 -f /org_files/tmp/kerkyra-jenkins/jenkins-values.yaml jenkins-myenv --namespace jenkins stable/jenkins

Is there a way to remove u from each list element in the interpolated jenkins_plugins_list variable?

pkaramol
  • 16,451
  • 43
  • 149
  • 324
  • How are you getting that rendered output? That looks like Ansible using Python2 showing that each element of the list is a unicode object but shouldn't impact the result of calling Helm. – ydaetskcoR Jan 21 '20 at 07:50
  • [Here](https://stackoverflow.com/questions/59821641/passing-variable-of-type-list-from-terraform-to-ansible) is the story behind how I am getting the rendered output. – pkaramol Jan 21 '20 at 07:51
  • The `u` s do not indeed impact `helm`, however for some reason `helm` [invocation](https://stackoverflow.com/questions/59835925/helm-upgrade-command-fails-for-no-apparent-reason) [fails](https://github.com/helm/helm/issues/1987#issuecomment-576554399). – pkaramol Jan 21 '20 at 07:52

0 Answers0