Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provisioner/chef: Error parsing vault_json: json: cannot unmarshal array into Go value of type string #9105

Closed
jmccann opened this issue Sep 28, 2016 · 3 comments · Fixed by #9114

Comments

@jmccann
Copy link

jmccann commented Sep 28, 2016

Terraform Version

Terraform v0.7.4

Affected Resource(s)

  • chef

Debug Output

Errors:

  * openstack_compute_instance_v2.test: Error parsing vault_json: json: cannot unmarshal array into Go value of type string
Error!
exit status 1
[info] build failed (exit code 1)

Expected Behavior

It should have worked with no errors.

Actual Behavior

It returned the error above

Steps to Reproduce

Run terraform with chef provisioner that has vault_json that contains an array.

Example:

  provisioner "chef" {
    attributes_json = <<-EOF
    {
      "rsyslog": {
        "server_ip": "192.168.1.23"
      }
    }
    EOF
    environment = "test"
    node_name = "test-server"
    recreate_client = true
    run_list = ["role[test]"]
    server_url = "https://test.company.com/organizations/test"
    ssl_verify_mode = "verify_none"
    user_name = "test-validator"
    user_key = "${base64decode(var.test_key)}"
    vault_json = <<-EOF
    {
      "test": [
        "test"
      ]
    }
    EOF
  }

Important Factoids

vault_json was recently added to chef provisioner.

I think the bad line of code causing this issue is @ https://github.com/hashicorp/terraform/blob/master/builtin/provisioners/chef/resource_provisioner.go#L355 ... specifically the string at the end of the line should be interface{} like it is for attributes_json @ https://github.com/hashicorp/terraform/blob/master/builtin/provisioners/chef/resource_provisioner.go#L347

References

vault_json argument added as part of #8577

@svanharmelen What are your thoughts on this?

@svanharmelen
Copy link
Contributor

@jmccann yes, I didn't know the value could be both a string and an array of strings. Will indeed need to update that line, but a few others as well. Will put in a fix later today... Thx for the report!

@svanharmelen
Copy link
Contributor

@jmccann the fix is in PR #9114 Again it would be great if you can give it a test run to verify my work! If you are able to do so, then please also check if the user key is deleted before the Chef run is started... Thx!

svanharmelen pushed a commit that referenced this issue Sep 30, 2016
Fixes #9105 by allowing the `vault_json` to contain either slices or strings.

And fixes #8932 by changing to way we cleanup the user key.
@ghost
Copy link

ghost commented Apr 21, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants