packer-plugin-ansible icon indicating copy to clipboard operation
packer-plugin-ansible copied to clipboard

[ansible-local] Add support for List Variable Type

Open hc-github-team-packer opened this issue 3 years ago • 0 comments

This issue was originally opened by @lmayorga1980 in https://github.com/hashicorp/packer/issues/11412 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

Allow variable type list to be added to extra_arguments in the ansible-local provisioner

Reproduction Steps

variable "packages" {
  type = list(string)
  description = "List of Packages"
  default = ["vim","net-tools"]
}

source "googlecompute" "ubuntu-ansible" {
  project_id = var.project_id
  source_image_project_id = ["ubuntu-os-pro-cloud"]
  source_image_family = "ubuntu-pro-1804-lts"
  ssh_username = "ubuntu"
  machine_type = "g1-small"
  zone = "us-east4-b"
  image_name = "ubuntu-custom-2"
  image_description = "custom ubuntu image"
  disk_size = 10
  preemptible = true
  tags = ["packer","image"]
  image_labels = {
    built_by = "packer"
  }
  account_file = var.account_file_path
}

build {
  name = "ubuntu-custom-2"
  sources = [
    "sources.googlecompute.ubuntu-ansible"
  ]

  provisioner "ansible-local" {
    playbook_file = "./playbooks/playbook.yml"
    extra_arguments = ["--extra-vars","packages=${var.packages}"]
  }
 }


Packer version

1.7.8

Operating system and Environment details

OS, Architecture, and any other information you can provide about the environment.

Log Fragments and crash.log files

Error: Failed preparing provisioner-block "ansible-local" ""

  on gcp-ubuntu-ansible.pkr.hcl line 34:
  (source code not available)

gcp-ubuntu-ansible.pkr.hcl:36,51-63: Invalid template interpolation value;
Cannot include the given value in a string template: string required.

hc-github-team-packer avatar Nov 29 '21 13:11 hc-github-team-packer