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

Inventory crashes when panic cookie is defined #126

Open
timurb opened this issue Sep 6, 2019 · 0 comments
Open

Inventory crashes when panic cookie is defined #126

timurb opened this issue Sep 6, 2019 · 0 comments

Comments

@timurb
Copy link

timurb commented Sep 6, 2019

When ansible using this inventory plugin is kicked by terraform it crashes with weird error (see example below).
At the same time when you run exactly the same command from CLI you see no error.
This is caused by environment variable "panic cookie" set by Terraform, apparently it produces extra debug output and this affects parsing of JSON.

Probably unsetting this environment variable will fix the issue.

Steps to reproduce
This works fine:

$ TF_STATE=./ terraform-inventory --inventory | head
overwriting already existing individual key XXXXX, old: [18.130.128.80], new: 18.130.128.80overwriting already existing individual key XXXXX, old: [3.10.63.11], new: 3.10.63.11overwriting already existing individual key XXXXX, old: [3.10.64.3], new: 3.10.64.3[all]
18.130.128.80
18.130.200.251
.....

This crashes:

$ cccf35992f8f3cd8d1d28f0109dd953e26664531="7c28215aca87789f95b406b8dd91aa5198406750" TF_STATE=./ ./terraform-inventory --inventory | head
Error reading Terraform state: 0.12 format error: invalid character 'o' looking for beginning of value; pre-0.12 format error: invalid character 'o' looking for beginning of value (nil error means no content/modules found in the respective format)

Output of terraform state pull with panic cookie enabled:

$ cccf35992f8f3cd8d1d28f0109dd953e26664531="7c28215aca87789f95b406b8dd91aa5198406750" terraform state pull | head
2019/09/06 19:34:08 [INFO] Terraform version: 0.12.6
2019/09/06 19:34:08 [INFO] Go runtime version: go1.12.7
2019/09/06 19:34:08 [INFO] CLI args: []string{"terraform", "state", "pull"}
2019/09/06 19:34:08 [INFO] CLI command args: []string{"state", "pull"}
2019/09/06 19:34:08 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2019/09/06 19:34:08 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2019/09/06 19:34:08 [DEBUG] New state was assigned lineage "a43f3371-a47c-9629-e2cd-8cca70912403"
2019/09/06 19:34:08 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2019/09/06 19:34:08 [TRACE] Meta.Backend: instantiated backend of type <nil>
2019/09/06 19:34:08 [DEBUG] checking for provider in "."
2019/09/06 19:34:08 [DEBUG] checking for provider in "/usr/local/bin"
2019/09/06 19:34:08 [DEBUG] checking for provider in ".terraform/plugins/darwin_amd64"
2019/09/06 19:34:08 [DEBUG] found provider "terraform-provider-aws_v2.25.0_x4"
2019/09/06 19:34:08 [DEBUG] found provider "terraform-provider-template_v2.1.2_x4"
2019/09/06 19:34:08 [DEBUG] checking for provisioner in "."
2019/09/06 19:34:08 [DEBUG] checking for provisioner in "/usr/local/bin"
2019/09/06 19:34:08 [DEBUG] checking for provisioner in ".terraform/plugins/darwin_amd64"
2019/09/06 19:34:08 [TRACE] Meta.Backend: backend <nil> does not support operations, so wrapping it in a local backend
2019/09/06 19:34:08 [TRACE] backend/local: state manager for workspace "default" will:
 - read initial snapshot from terraform.tfstate
 - write new snapshots to terraform.tfstate
 - create any backup at terraform.tfstate.backup
2019/09/06 19:34:08 [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate
2019/09/06 19:34:08 [TRACE] statemgr.Filesystem: read snapshot with lineage "68688936-c608-6e3d-41d7-e0dbdde6deb2" serial 66
o:{
  "version": 4,
  "terraform_version": "0.12.6",
  "serial": 66,
  "lineage": "68688936-c608-6e3d-41d7-e0dbdde6deb2",
  "outputs": {
    "XXXXX": {
      "value": [
        "18.130.128.80",
        "3.10.63.11",
@timurb timurb changed the title Inventory crashes when magic cookie is defined Inventory crashes when panic cookie is defined Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant