radekg / terraform-provisioner-ansible

Ansible with Terraform 0.14.x
Apache License 2.0
572 stars 100 forks source link

support complex variables #101

Open sjwl opened 5 years ago

sjwl commented 5 years ago

Currently it seems extra_vars only supports map to string variables, but need more complex variable types than just string.

This example is attempting to use a list type, which fails.

            extra_vars = {
                ansible_user = "ubuntu"
                nameservers = ["10.1.1.1"]
            }

This has more to do with the limitation of hcl, and perhaps hcl2 will help. Until then, could perhaps something like the chef provisioner with its attributes_json.

  provisioner "chef" {
    attributes_json = <<-EOF
      {
        "key": "value",
        "app": {
          "cluster1": {
            "nodes": [
              "webserver1",
              "webserver2"
            ]
          }
        }
      }
    EOF
  }