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

ansible-local provisioner cannot set packer_http_addr properly when the variable is not implemented #173

Open
126ium opened this issue Sep 13, 2023 · 0 comments · May be fixed by #174
Open
Labels

Comments

@126ium
Copy link

126ium commented Sep 13, 2023

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

  1. Navigate to the source directory of Ansible-local.
  2. 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.

@126ium 126ium added the bug label Sep 13, 2023
@126ium 126ium changed the title ansible-local provisioner cannot set packer_http_addr properly when that variable is not implemented ansible-local provisioner cannot set packer_http_addr properly when the variable is not implemented Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant