Overview of the Issue
It appears that SDK's SSH proxy adapter (used, for example, by the Ansible plugin) does not handle spaces in filenames correctly resulting in exit code 1 from scp during the transfer. The build runs fine if the proxy is disabled.
Reproduction Steps
- Create a directory with
build.sh with following contents:
#!/bin/bash
# cleanup previous run output
rm -f \
example_file_with_no_spaces \
'example file with spaces' \
ssh_key \
ssh_key.pub \
meta-data \
user-data \
cidata.iso \
playbook.yaml \
repro.pkr.hcl
rm -rf output
# create files for the build
touch example_file_with_no_spaces
touch 'example file with spaces'
ssh-keygen -t rsa -q -f ssh_key -N '' -C 'packer'
echo '{}' > meta-data
echo "#cloud-config
users:
- name: packer
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- $(cat ssh_key.pub)
" > user-data
genisoimage -output cidata.iso -input-charset utf-8 -volid cidata -rational-rock -joliet user-data meta-data
echo '- hosts: all
tasks:
- ansible.builtin.copy:
src: example_file_with_no_spaces
dest: /tmp/example1
- ansible.builtin.copy:
src: example file with spaces
dest: /tmp/example2
' > playbook.yaml
echo 'packer {
required_plugins {
qemu = {
version = "1.1.0"
source = "github.com/hashicorp/qemu"
}
ansible = {
version = "1.1.1"
source = "github.com/hashicorp/ansible"
}
}
}
source "qemu" "ubuntu" {
format = "qcow2"
disk_image = true
disk_size = "10G"
headless = true
iso_checksum = "file:https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS"
iso_url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
qemuargs = [["-cdrom", "cidata.iso"]]
ssh_username = "packer"
ssh_private_key_file = "ssh_key"
vm_name = "build.qcow2"
output_directory = "output"
}
build {
sources = ["source.qemu.ubuntu"]
provisioner "ansible" {
playbook_file = "playbook.yaml"
ansible_env_vars = ["ANSIBLE_VERBOSITY=5", "ANSIBLE_DISPLAY_ARGS_TO_STDOUT=True"]
}
}
' > repro.pkr.hcl
# run Packer
packer init repro.pkr.hcl
packer build repro.pkr.hcl
- Run the following commands:
chmod +x build.sh
./build.sh
- See the failure.
Note that as described, adding use_proxy = false to the Ansible provisioner results in a successful build.
Packer Plugin SDK version
0.5.1 (the version that the Packer Ansible plugin uses)
Operating system and Environment details
Packer ran from OS: Ubuntu Desktop 22.04.4 LTS x86_64
OS ran in Packer: Ubuntu Server 22.04.4 LTS x86_64
Log Fragments and crash.log files
https://gist.github.com/Jackenmen/bb97795a3e69709a1d7dda6cab75e07f
Overview of the Issue
It appears that SDK's SSH proxy adapter (used, for example, by the Ansible plugin) does not handle spaces in filenames correctly resulting in exit code 1 from
scpduring the transfer. The build runs fine if the proxy is disabled.Reproduction Steps
build.shwith following contents:Note that as described, adding
use_proxy = falseto the Ansible provisioner results in a successful build.Packer Plugin SDK version
0.5.1 (the version that the Packer Ansible plugin uses)
Operating system and Environment details
Packer ran from OS: Ubuntu Desktop 22.04.4 LTS x86_64
OS ran in Packer: Ubuntu Server 22.04.4 LTS x86_64
Log Fragments and crash.log files
https://gist.github.com/Jackenmen/bb97795a3e69709a1d7dda6cab75e07f