I'm using Packer to build new AWS AMIs using Ansible. Everything seems to go along fine until Ansible finishes with an error. Packer then panics with this type of output:
2019/08/07 18:09:55 packer: 2019/08/07 18:09:55 [ERROR] Remote command exited with '2': cd /tmp/packer-provisioner-ansible-local/5d4b13b5-6ce3-9522-e94e-7fe1a9ebcdad && ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 ansible-playbook /tmp/packer-provisioner-ansible-local/5d4b13b5-6ce3-9522-e94e-7fe1a9ebcdad/packer.yml --extra-vars "packer_build_name=amazon-ebs packer_builder_type=amazon-ebs packer_http_addr= -o IdentitiesOnly=yes" -e build_id=450539e8e6f6 -vv -c local -i /tmp/packer-provisioner-ansible-local/5d4b13b5-6ce3-9522-e94e-7fe1a9ebcdad/packer-provisioner-ansible-local255794741
2019/08/07 18:09:55 packer: 2019/08/07 18:09:55 [INFO] RPC endpoint: Communicator ended with: 2
2019/08/07 18:09:55 [INFO] 17368 bytes written for 'stdout'
2019/08/07 18:09:55 [INFO] 96 bytes written for 'stderr'
2019/08/07 18:09:55 [INFO] RPC client: Communicator ended with: 2
2019/08/07 18:09:55 [INFO] RPC endpoint: Communicator ended with: 2
2019/08/07 18:09:55 packer: 2019/08/07 18:09:55 [INFO] 17368 bytes written for 'stdout'
2019/08/07 18:09:55 packer: 2019/08/07 18:09:55 [INFO] 96 bytes written for 'stderr'
2019/08/07 18:09:55 packer: 2019/08/07 18:09:55 [INFO] RPC client: Communicator ended with: 2
2019/08/07 18:09:55 [INFO] (telemetry) ending ansible-local
2019/08/07 18:09:55 ui error: [1;31m==> amazon-ebs: Error executing Ansible: Non-zero exit status: 2[0m
2019/08/07 18:09:55 ui: [1;32m==> amazon-ebs: Step "StepProvision" failed[0m
2019/08/07 18:09:55 ui: ask: [1;32m==> amazon-ebs: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?[0m
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x2270426]
goroutine 302 [running]:
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(*TTY).output(...)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty_unix.go:101
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(*TTY).Output(0x0, 0x258b280)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty.go:46 +0x6
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(*TTY).ReadString(0x0, 0x0, 0x0, 0x0, 0x0)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty.go:90 +0x3c
github.com/hashicorp/packer/packer.(*BasicUi).Ask.func1(0xc000082e40, 0xc00030ff80)
/Users/mmarsh/go/src/github.com/hashicorp/packer/packer/ui.go:212 +0x40
created by github.com/hashicorp/packer/packer.(*BasicUi).Ask
/Users/mmarsh/go/src/github.com/hashicorp/packer/packer/ui.go:211 +0x238
I know we had some TTY bugs in the 1.4.0 and 1.4.1 releases; can you give this a try with 1.4.2 and see if it's still an issue for you?
Was this solved by the v1.4.2 release, or is this still an issue?
Closing since we haven't heard back and I think there's a good chance this was solved in recent releases.
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.
Most helpful comment
I know we had some TTY bugs in the 1.4.0 and 1.4.1 releases; can you give this a try with 1.4.2 and see if it's still an issue for you?