Fix: Force SCP mode for file transfer with bastion 90/73890/1 v0.17.3
authorAnil Belur <abelur@linuxfoundation.org>
Thu, 13 Nov 2025 13:35:16 +0000 (23:35 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Thu, 13 Nov 2025 13:42:20 +0000 (23:42 +1000)
commitd02b15305d8e8ba15a8f2601bc7c207c06feb9d4
treeb6361dd9499452e35027837dd9781312fe0f10b6
parentde07429afe42fe5cceff96b9d4cf82f0af54fcd2
Fix: Force SCP mode for file transfer with bastion

Force SCP mode for Ansible file transfers with bastion.
Add ANSIBLE_SCP_IF_SSH=True environment variable when
local_build=true to force Ansible to use SCP instead of SFTP
for file transfers.

Root cause: Ansible defaults to SFTP for file transfers, which causes
failures when connecting through bastion/jump hosts that don't have
sftp-server installed. The existing --scp-extra-args '-O' flag was
being ignored because Ansible was using SFTP, not SCP.

Error without this fix:
  failed to transfer file to /home/ubuntu/.ansible/tmp/...
  bash: line 1: /usr/lib/sftp-server: No such file or directory
  scp: Connection closed

Solution: Set ANSIBLE_SCP_IF_SSH=True to force Ansible to use SCP mode
when local_build=true (builds through bastion). Once SCP is being used,
the --scp-extra-args '-O' flag applies, forcing legacy SCP protocol
which works correctly through the bastion.

Changes:
- Added local.ansible_env_vars conditional in all templates
- When local_build=true: includes ANSIBLE_SCP_IF_SSH=True
- When local_build=false: standard Ansible environment (Jenkins builds)
- Updated provisioner blocks to use local.ansible_env_vars

Templates updated:
- builder.pkr.hcl
- docker.pkr.hcl
- devstack.pkr.hcl
- devstack-pre-pip-yoga.pkr.hcl
- windows-builder.pkr.hcl

Backward compatibility: Existing Jenkins builds continue to work
unchanged since local_build defaults to false. Only affects builds
with local_build=true (packer-build-action through bastion).

Change-Id: Iae0d6f2284fb2cdefa827c951bd11b51a5a56e19
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
releasenotes/notes/fix-ansible-scp-sftp-bastion-391c386d9e4f8a21.yaml [new file with mode: 0644]
templates/builder.pkr.hcl
templates/devstack-pre-pip-yoga.pkr.hcl
templates/devstack.pkr.hcl
templates/docker.pkr.hcl
templates/windows-builder.pkr.hcl