generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
Description
Overview of the Issue
When a builder doesn't set packer_http_addr, the Ansible-local provisioner sets packer_http_addr=%!s(<nil>) in the command during the execution of the Ansible stage. This results in some builders encountering command syntax errors.
Reproduction Steps
- Navigate to the source directory of Ansible-local.
- Run the test cases as follows:
[ansible-local]$ go test
2023/09/13 14:38:27 ui: Provisioning with Ansible...
2023/09/13 14:38:27 ui: Creating Ansible staging directory...
2023/09/13 14:38:27 ui: Creating directory: /tmp/packer-provisioner-ansible-local/65013cc3-a324-8f87-d5b9-404a095af639
2023/09/13 14:38:27 ui: Uploading playbook file: /tmp/468917457
2023/09/13 14:38:27 ui: Creating directory: /tmp/packer-provisioner-ansible-local/65013cc3-a324-8f87-d5b9-404a095af639/tmp
2023/09/13 14:38:27 ui: Uploading playbook file: /tmp/4263333196
2023/09/13 14:38:27 ui: Creating directory: /tmp/packer-provisioner-ansible-local/65013cc3-a324-8f87-d5b9-404a095af639/tmp
2023/09/13 14:38:27 ui: Uploading playbook file: /tmp/2126671814
2023/09/13 14:38:27 ui: Creating directory: /tmp/packer-provisioner-ansible-local/65013cc3-a324-8f87-d5b9-404a095af639/tmp
2023/09/13 14:38:27 ui: Uploading inventory file...
2023/09/13 14:38:27 ui: Executing Ansible: cd /tmp/packer-provisioner-ansible-local/65013cc3-a324-8f87-d5b9-404a095af639 && ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 ansible-playbook /tmp/packer-provisioner-ansible-local/65013cc3-a324-8f87-d5b9-404a095af639/tmp/468917457 --extra-vars "packer_build_name= packer_builder_type= packer_http_addr=%!s(<nil>) -o IdentitiesOnly=yes" -c local -i /tmp/packer-provisioner-ansible-local/65013cc3-a324-8f87-d5b9-404a095af639/packer-provisioner-ansible-local1134823180
The expected command should be:
--extra-vars "packer_build_name= packer_builder_type= packer_http_addr= -o IdentitiesOnly=yes"
The issue arises because packer_http_addr should be set as an empty string when it's nil.
Plugin and Packer version
- Packer 1.9.4
- packer-plugin-ansible 1.1.0
I have made a pretty simple patch to fix this issue.