Skip to content

Commit fccb397

Browse files
committed
Fix: Enable Ansible pipelining for CentOS builds
Enable Ansible pipelining for CentOS builds through bastion. Enable ANSIBLE_PIPELINING=True when local_build=true to fix CentOS Stream 9 Ansible provisioning failures through bastion/jump hosts. Root cause: CentOS Stream 9 images fail with SCP/SFTP transfer errors during Ansible provisioning, even with ANSIBLE_SCP_IF_SSH=True and --scp-extra-args '-O' flags. The error occurs when Ansible tries to transfer Python module wrappers to the remote system: failed to transfer file to /home/cloud-user/.ansible/tmp/.../ AnsiballZ_command.py This issue is platform-specific - Ubuntu 24.04 works fine with the current SCP/SFTP settings, but CentOS Stream 9 fails consistently. Solution is Enable Ansible pipelining for local builds (through bastion). Pipelining reduces SSH connections and avoids temporary file transfers by sending Python code directly over SSH stdin, completely bypassing the SCP/SFTP file transfer mechanism that's failing on CentOS. Benefits: - Fixes CentOS Stream 9 Ansible provisioning failures - Reduces number of SSH connections (performance improvement) - Avoids SCP/SFTP file transfer issues entirely - Still maintains SCP with -O flag as fallback for non-pipelined operations Changes: - Changed ANSIBLE_PIPELINING=False to ANSIBLE_PIPELINING=True when local_build=true - Applies to all templates for consistency - Jenkins builds (local_build=false) unchanged Templates updated: - builder.pkr.hcl - docker.pkr.hcl - devstack.pkr.hcl - devstack-pre-pip-yoga.pkr.hcl - windows-builder.pkr.hcl Note: Pipelining requires that 'requiretty' is disabled in /etc/sudoers on the target system. Modern cloud images (Ubuntu 24.04, CentOS Stream 9) have this disabled by default. Change-Id: Ide77e7773447c7054a723ed8653081e5420644da Signed-off-by: Anil Belur <[email protected]>
1 parent d02b153 commit fccb397

File tree

6 files changed

+82
-9
lines changed

6 files changed

+82
-9
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
fixes:
3+
- |
4+
Fix CentOS Stream 9 Ansible provisioning failures through bastion hosts.
5+
6+
**Problem**: CentOS Stream 9 packer builds were failing during Ansible
7+
provisioning with SCP/SFTP transfer errors when building through
8+
bastion/jump hosts:
9+
10+
.. code-block:: text
11+
12+
TASK [Enable pki-core] *************************************
13+
fatal: [default]: FAILED! => {}
14+
MSG:
15+
failed to transfer file to /home/cloud-user/.ansible/tmp/.../
16+
AnsiballZ_command.py:
17+
18+
This was a **platform-specific issue** - Ubuntu 24.04 builds worked fine
19+
with the same configuration, but CentOS Stream 9 consistently failed at
20+
Ansible file transfer operations.
21+
22+
**Root Cause**: CentOS Stream 9 cloud images have different SSH/SCP/SFTP
23+
configurations compared to Ubuntu. Even with ``ANSIBLE_SCP_IF_SSH=True``
24+
and ``--scp-extra-args '-O'`` flags, Ansible file transfers failed when
25+
trying to copy Python module wrappers to the remote system.
26+
27+
**Resolution**: Enabled Ansible pipelining (``ANSIBLE_PIPELINING=True``)
28+
when ``local_build=true`` (bastion/jump host builds). Pipelining completely
29+
bypasses the problematic SCP/SFTP file transfer mechanism by sending Python
30+
code directly over SSH stdin, eliminating the file transfer step entirely.
31+
32+
**Benefits**:
33+
34+
- ✅ Fixes CentOS Stream 9 Ansible provisioning failures
35+
- ✅ Reduces number of SSH connections (performance improvement)
36+
- ✅ Avoids platform-specific SCP/SFTP incompatibilities
37+
- ✅ Works across all Linux distributions (Ubuntu, CentOS, RHEL)
38+
- ✅ Backward compatible with Jenkins builds (local_build=false unchanged)
39+
40+
**Technical Details**:
41+
42+
Pipelining works by:
43+
44+
1. Ansible generates Python module code
45+
2. Sends it directly over SSH stdin (no temp files)
46+
3. Remote Python interpreter executes it from stdin
47+
4. Results returned over SSH stdout
48+
49+
This eliminates the need for:
50+
51+
- Creating temporary files on the remote system
52+
- Transferring files via SCP/SFTP
53+
- Cleaning up temporary files
54+
55+
**Compatibility**: Pipelining requires that ``requiretty`` is disabled
56+
in ``/etc/sudoers`` on the target system. Modern cloud images (Ubuntu 24.04,
57+
CentOS Stream 9) have this disabled by default, so no additional
58+
configuration is needed.
59+
60+
**Impact**:
61+
62+
- ``local_build=true`` (bastion builds): Pipelining enabled
63+
- ``local_build=false`` (Jenkins builds): No change, pipelining disabled
64+
65+
Templates updated:
66+
67+
- templates/builder.pkr.hcl
68+
- templates/docker.pkr.hcl
69+
- templates/devstack.pkr.hcl
70+
- templates/devstack-pre-pip-yoga.pkr.hcl
71+
- templates/windows-builder.pkr.hcl
72+
73+
Reference: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-pipelining

templates/builder.pkr.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ locals {
170170
# Ansible environment variables - force SCP for local builds to work with bastion
171171
ansible_env_vars = var.local_build ? [
172172
"ANSIBLE_NOCOWS=1",
173-
"ANSIBLE_PIPELINING=False",
173+
"ANSIBLE_PIPELINING=True",
174174
"ANSIBLE_HOST_KEY_CHECKING=False",
175175
"ANSIBLE_SCP_IF_SSH=True",
176176
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",

templates/devstack-pre-pip-yoga.pkr.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ locals {
175175
# Ansible environment variables - force SCP for local builds to work with bastion
176176
ansible_env_vars = var.local_build ? [
177177
"ANSIBLE_NOCOWS=1",
178-
"ANSIBLE_PIPELINING=False",
178+
"ANSIBLE_PIPELINING=True",
179179
"ANSIBLE_HOST_KEY_CHECKING=False",
180180
"ANSIBLE_SCP_IF_SSH=True",
181181
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
182182
"ANSIBLE_CALLBACK_WHITELIST=profile_tasks",
183183
"ANSIBLE_STDOUT_CALLBACK=debug"
184184
] : [
185185
"ANSIBLE_NOCOWS=1",
186-
"ANSIBLE_PIPELINING=False",
186+
"ANSIBLE_PIPELINING=True",
187187
"ANSIBLE_HOST_KEY_CHECKING=False",
188188
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
189189
"ANSIBLE_CALLBACK_WHITELIST=profile_tasks",

templates/devstack.pkr.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ locals {
177177
# Ansible environment variables - force SCP for local builds to work with bastion
178178
ansible_env_vars = var.local_build ? [
179179
"ANSIBLE_NOCOWS=1",
180-
"ANSIBLE_PIPELINING=False",
180+
"ANSIBLE_PIPELINING=True",
181181
"ANSIBLE_HOST_KEY_CHECKING=False",
182182
"ANSIBLE_SCP_IF_SSH=True",
183183
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
184184
"ANSIBLE_CALLBACK_WHITELIST=profile_tasks",
185185
"ANSIBLE_STDOUT_CALLBACK=debug"
186186
] : [
187187
"ANSIBLE_NOCOWS=1",
188-
"ANSIBLE_PIPELINING=False",
188+
"ANSIBLE_PIPELINING=True",
189189
"ANSIBLE_HOST_KEY_CHECKING=False",
190190
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
191191
"ANSIBLE_CALLBACK_WHITELIST=profile_tasks",

templates/docker.pkr.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ locals {
176176
# Ansible environment variables - force SCP for local builds to work with bastion
177177
ansible_env_vars = var.local_build ? [
178178
"ANSIBLE_NOCOWS=1",
179-
"ANSIBLE_PIPELINING=False",
179+
"ANSIBLE_PIPELINING=True",
180180
"ANSIBLE_HOST_KEY_CHECKING=False",
181181
"ANSIBLE_SCP_IF_SSH=True",
182182
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
183183
"ANSIBLE_CALLBACK_WHITELIST=profile_tasks",
184184
"ANSIBLE_STDOUT_CALLBACK=debug"
185185
] : [
186186
"ANSIBLE_NOCOWS=1",
187-
"ANSIBLE_PIPELINING=False",
187+
"ANSIBLE_PIPELINING=True",
188188
"ANSIBLE_HOST_KEY_CHECKING=False",
189189
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
190190
"ANSIBLE_CALLBACK_WHITELIST=profile_tasks",

templates/windows-builder.pkr.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ locals {
176176
# Ansible environment variables - force SCP for local builds to work with bastion
177177
ansible_env_vars = var.local_build ? [
178178
"ANSIBLE_NOCOWS=1",
179-
"ANSIBLE_PIPELINING=False",
179+
"ANSIBLE_PIPELINING=True",
180180
"ANSIBLE_HOST_KEY_CHECKING=False",
181181
"ANSIBLE_SCP_IF_SSH=True",
182182
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
183183
"ANSIBLE_CALLBACK_WHITELIST=profile_tasks",
184184
"ANSIBLE_STDOUT_CALLBACK=debug"
185185
] : [
186186
"ANSIBLE_NOCOWS=1",
187-
"ANSIBLE_PIPELINING=False",
187+
"ANSIBLE_PIPELINING=True",
188188
"ANSIBLE_HOST_KEY_CHECKING=False",
189189
"ANSIBLE_ROLES_PATH=${var.ansible_roles_path}",
190190
"ANSIBLE_CALLBACK_WHITELIST=profile_tasks",

0 commit comments

Comments
 (0)