Skip to content

Commit 040655a

Browse files
committed
feat: Add Tailscale SSH bastion/jump host support
Add native SSH bastion support to all OpenStack builder templates, enabling Packer builds through jump hosts for environments where direct access to OpenStack networks is not available. Changes: - Add ssh_bastion_* variables to templates with OpenStack sources: * ssh_bastion_host - Bastion IP/hostname * ssh_bastion_username - Bastion authentication username * ssh_bastion_port - Bastion SSH port (default: 22) * ssh_bastion_agent_auth - Use SSH agent auth (default: true) * ssh_bastion_private_key_file - Path to private key file * ssh_bastion_password - Password authentication (not recommended) - Update OpenStack source blocks in all templates to include bastion configuration with conditional null handling for backwards compatibility - Maintain legacy ssh_proxy_host support for existing deployments Templates updated: - templates/builder.pkr.hcl - templates/devstack.pkr.hcl - templates/devstack-pre-pip-yoga.pkr.hcl - templates/docker.pkr.hcl - templates/windows-builder.pkr.hcl - templates/variables.auto.pkr.hcl All bastion variables are optional with empty string defaults, ensuring backward compatibility with existing builds that don't require bastion access. Variables convert to null when empty, so Packer ignores them. This enables CI/CD environments (GitHub Actions, Jenkins) to build OpenStack images via ephemeral bastion hosts like Tailscale SSH or traditional jump servers. Issue: RELENG-5850 Change-Id: If2b18067e491346b26d03da38b0ae1957c78aca1 Signed-off-by: Anil Belur <[email protected]>
1 parent 3d7cc9a commit 040655a

File tree

7 files changed

+300
-0
lines changed

7 files changed

+300
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
features:
3+
- |
4+
Add SSH bastion/jump host support for OpenStack builder template.
5+
The following new variables are now available for configuring SSH
6+
bastion connections:
7+
8+
- ``ssh_bastion_host`` - IP address or hostname of the bastion host
9+
- ``ssh_bastion_username`` - Username for bastion authentication
10+
- ``ssh_bastion_port`` - SSH port on bastion (default: 22)
11+
- ``ssh_bastion_agent_auth`` - Use SSH agent for authentication (default: true)
12+
- ``ssh_bastion_private_key_file`` - Path to SSH private key file
13+
- ``ssh_bastion_password`` - Password for bastion authentication (not recommended)
14+
15+
All bastion variables are optional with empty string defaults, making them
16+
backward compatible with existing builds that don't require bastion access.
17+
18+
Example usage:
19+
20+
.. code-block:: bash
21+
22+
packer build \\
23+
-var=ssh_bastion_host=100.64.183.39 \\
24+
-var=ssh_bastion_username=root \\
25+
-var-file=vars/ubuntu-22.04.pkrvars.hcl \\
26+
templates/builder.pkr.hcl
27+
28+
This enables Packer builds to access OpenStack instances through a
29+
bastion/jump host, which is required when direct access to OpenStack
30+
networks is not available (e.g., in CI/CD environments using Tailscale
31+
or other ephemeral bastion solutions).
32+
33+
Reference:
34+
https://developer.hashicorp.com/packer/integrations/hashicorp/openstack/latest/components/builder/openstack
35+
upgrade:
36+
- |
37+
Existing builds using ``ssh_proxy_host`` will continue to work without
38+
changes. The legacy proxy support is maintained for backward compatibility.
39+
New deployments should use the SSH bastion variables for native jump host
40+
support instead of proxy-based SSH tunneling.

templates/builder.pkr.hcl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,43 @@ variable "ssh_proxy_host" {
9393
default = ""
9494
}
9595

96+
variable "ssh_bastion_host" {
97+
type = string
98+
default = ""
99+
description = "Bastion/jump host for SSH access to OpenStack instances"
100+
}
101+
102+
variable "ssh_bastion_username" {
103+
type = string
104+
default = ""
105+
description = "Username for bastion host authentication"
106+
}
107+
108+
variable "ssh_bastion_port" {
109+
type = number
110+
default = 22
111+
description = "SSH port on bastion host"
112+
}
113+
114+
variable "ssh_bastion_agent_auth" {
115+
type = bool
116+
default = true
117+
description = "Use SSH agent for bastion authentication"
118+
}
119+
120+
variable "ssh_bastion_private_key_file" {
121+
type = string
122+
default = ""
123+
description = "Path to SSH private key file for bastion authentication"
124+
}
125+
126+
variable "ssh_bastion_password" {
127+
type = string
128+
default = ""
129+
sensitive = true
130+
description = "Password for bastion host authentication (not recommended)"
131+
}
132+
96133
variable "ssh_user" {
97134
type = string
98135
}
@@ -140,7 +177,18 @@ source "openstack" "builder" {
140177
networks = ["${var.cloud_network}"]
141178
region = "${var.cloud_region}"
142179
source_image_name = "${var.base_image}"
180+
181+
# Legacy proxy support (kept for backwards compatibility)
143182
ssh_proxy_host = "${var.ssh_proxy_host}"
183+
184+
# Bastion/Jump host support
185+
ssh_bastion_host = var.ssh_bastion_host != "" ? var.ssh_bastion_host : null
186+
ssh_bastion_username = var.ssh_bastion_username != "" ? var.ssh_bastion_username : null
187+
ssh_bastion_port = var.ssh_bastion_port
188+
ssh_bastion_agent_auth = var.ssh_bastion_agent_auth
189+
ssh_bastion_private_key_file = var.ssh_bastion_private_key_file != "" ? var.ssh_bastion_private_key_file : null
190+
ssh_bastion_password = var.ssh_bastion_password != "" ? var.ssh_bastion_password : null
191+
144192
ssh_username = "${var.ssh_user}"
145193
use_blockstorage_volume = "${var.vm_use_block_storage}"
146194
user_data_file = "${var.cloud_user_data}"

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,43 @@ variable "ssh_proxy_host" {
8080
default = ""
8181
}
8282

83+
variable "ssh_bastion_host" {
84+
type = string
85+
default = ""
86+
description = "Bastion/jump host for SSH access to OpenStack instances"
87+
}
88+
89+
variable "ssh_bastion_username" {
90+
type = string
91+
default = ""
92+
description = "Username for bastion host authentication"
93+
}
94+
95+
variable "ssh_bastion_port" {
96+
type = number
97+
default = 22
98+
description = "SSH port on bastion host"
99+
}
100+
101+
variable "ssh_bastion_agent_auth" {
102+
type = bool
103+
default = true
104+
description = "Use SSH agent for bastion authentication"
105+
}
106+
107+
variable "ssh_bastion_private_key_file" {
108+
type = string
109+
default = ""
110+
description = "Path to SSH private key file for bastion authentication"
111+
}
112+
113+
variable "ssh_bastion_password" {
114+
type = string
115+
default = ""
116+
sensitive = true
117+
description = "Password for bastion host authentication (not recommended)"
118+
}
119+
83120
variable "source_ami_filter_name" {
84121
type = string
85122
default = null
@@ -145,7 +182,18 @@ source "openstack" "devstack-pre-pip-yoga" {
145182
networks = ["${var.cloud_network}"]
146183
region = "${var.cloud_region}"
147184
source_image_name = "${var.base_image}"
185+
186+
# Legacy proxy support (kept for backwards compatibility)
148187
ssh_proxy_host = "${var.ssh_proxy_host}"
188+
189+
# Bastion/Jump host support
190+
ssh_bastion_host = var.ssh_bastion_host != "" ? var.ssh_bastion_host : null
191+
ssh_bastion_username = var.ssh_bastion_username != "" ? var.ssh_bastion_username : null
192+
ssh_bastion_port = var.ssh_bastion_port
193+
ssh_bastion_agent_auth = var.ssh_bastion_agent_auth
194+
ssh_bastion_private_key_file = var.ssh_bastion_private_key_file != "" ? var.ssh_bastion_private_key_file : null
195+
ssh_bastion_password = var.ssh_bastion_password != "" ? var.ssh_bastion_password : null
196+
149197
ssh_username = "${var.ssh_user}"
150198
use_blockstorage_volume = "${var.vm_use_block_storage}"
151199
user_data_file = "${var.cloud_user_data}"

templates/devstack.pkr.hcl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,43 @@ variable "ssh_proxy_host" {
8383
default = ""
8484
}
8585

86+
variable "ssh_bastion_host" {
87+
type = string
88+
default = ""
89+
description = "Bastion/jump host for SSH access to OpenStack instances"
90+
}
91+
92+
variable "ssh_bastion_username" {
93+
type = string
94+
default = ""
95+
description = "Username for bastion host authentication"
96+
}
97+
98+
variable "ssh_bastion_port" {
99+
type = number
100+
default = 22
101+
description = "SSH port on bastion host"
102+
}
103+
104+
variable "ssh_bastion_agent_auth" {
105+
type = bool
106+
default = true
107+
description = "Use SSH agent for bastion authentication"
108+
}
109+
110+
variable "ssh_bastion_private_key_file" {
111+
type = string
112+
default = ""
113+
description = "Path to SSH private key file for bastion authentication"
114+
}
115+
116+
variable "ssh_bastion_password" {
117+
type = string
118+
default = ""
119+
sensitive = true
120+
description = "Password for bastion host authentication (not recommended)"
121+
}
122+
86123
variable "source_ami_filter_name" {
87124
type = string
88125
default = null
@@ -147,7 +184,18 @@ source "openstack" "devstack" {
147184
networks = ["${var.cloud_network}"]
148185
region = "${var.cloud_region}"
149186
source_image_name = "${var.base_image}"
187+
188+
# Legacy proxy support (kept for backwards compatibility)
150189
ssh_proxy_host = "${var.ssh_proxy_host}"
190+
191+
# Bastion/Jump host support
192+
ssh_bastion_host = var.ssh_bastion_host != "" ? var.ssh_bastion_host : null
193+
ssh_bastion_username = var.ssh_bastion_username != "" ? var.ssh_bastion_username : null
194+
ssh_bastion_port = var.ssh_bastion_port
195+
ssh_bastion_agent_auth = var.ssh_bastion_agent_auth
196+
ssh_bastion_private_key_file = var.ssh_bastion_private_key_file != "" ? var.ssh_bastion_private_key_file : null
197+
ssh_bastion_password = var.ssh_bastion_password != "" ? var.ssh_bastion_password : null
198+
151199
ssh_username = "${var.ssh_user}"
152200
use_blockstorage_volume = "${var.vm_use_block_storage}"
153201
user_data_file = "${var.cloud_user_data}"

templates/docker.pkr.hcl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,43 @@ variable "ssh_proxy_host" {
9898
default = ""
9999
}
100100

101+
variable "ssh_bastion_host" {
102+
type = string
103+
default = ""
104+
description = "Bastion/jump host for SSH access to OpenStack instances"
105+
}
106+
107+
variable "ssh_bastion_username" {
108+
type = string
109+
default = ""
110+
description = "Username for bastion host authentication"
111+
}
112+
113+
variable "ssh_bastion_port" {
114+
type = number
115+
default = 22
116+
description = "SSH port on bastion host"
117+
}
118+
119+
variable "ssh_bastion_agent_auth" {
120+
type = bool
121+
default = true
122+
description = "Use SSH agent for bastion authentication"
123+
}
124+
125+
variable "ssh_bastion_private_key_file" {
126+
type = string
127+
default = ""
128+
description = "Path to SSH private key file for bastion authentication"
129+
}
130+
131+
variable "ssh_bastion_password" {
132+
type = string
133+
default = ""
134+
sensitive = true
135+
description = "Password for bastion host authentication (not recommended)"
136+
}
137+
101138
variable "ssh_user" {
102139
type = string
103140
default = null
@@ -146,7 +183,18 @@ source "openstack" "docker" {
146183
networks = ["${var.cloud_network}"]
147184
region = "${var.cloud_region}"
148185
source_image_name = "${var.base_image}"
186+
187+
# Legacy proxy support (kept for backwards compatibility)
149188
ssh_proxy_host = "${var.ssh_proxy_host}"
189+
190+
# Bastion/Jump host support
191+
ssh_bastion_host = var.ssh_bastion_host != "" ? var.ssh_bastion_host : null
192+
ssh_bastion_username = var.ssh_bastion_username != "" ? var.ssh_bastion_username : null
193+
ssh_bastion_port = var.ssh_bastion_port
194+
ssh_bastion_agent_auth = var.ssh_bastion_agent_auth
195+
ssh_bastion_private_key_file = var.ssh_bastion_private_key_file != "" ? var.ssh_bastion_private_key_file : null
196+
ssh_bastion_password = var.ssh_bastion_password != "" ? var.ssh_bastion_password : null
197+
150198
ssh_username = "${var.ssh_user}"
151199
use_blockstorage_volume = "${var.vm_use_block_storage}"
152200
user_data_file = "${var.cloud_user_data}"

templates/variables.auto.pkr.hcl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,37 @@ variable "ssh_proxy_host" {
108108
default = ""
109109
}
110110

111+
variable "ssh_bastion_host" {
112+
type = string
113+
default = ""
114+
}
115+
116+
variable "ssh_bastion_username" {
117+
type = string
118+
default = ""
119+
}
120+
121+
variable "ssh_bastion_port" {
122+
type = number
123+
default = 22
124+
}
125+
126+
variable "ssh_bastion_agent_auth" {
127+
type = bool
128+
default = true
129+
}
130+
131+
variable "ssh_bastion_private_key_file" {
132+
type = string
133+
default = ""
134+
}
135+
136+
variable "ssh_bastion_password" {
137+
type = string
138+
default = ""
139+
sensitive = true
140+
}
141+
111142
variable "ssh_user" {
112143
type = string
113144
default = null

templates/windows-builder.pkr.hcl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,43 @@ variable "ssh_proxy_host" {
8383
default = null
8484
}
8585

86+
variable "ssh_bastion_host" {
87+
type = string
88+
default = ""
89+
description = "Bastion/jump host for SSH access to OpenStack instances"
90+
}
91+
92+
variable "ssh_bastion_username" {
93+
type = string
94+
default = ""
95+
description = "Username for bastion host authentication"
96+
}
97+
98+
variable "ssh_bastion_port" {
99+
type = number
100+
default = 22
101+
description = "SSH port on bastion host"
102+
}
103+
104+
variable "ssh_bastion_agent_auth" {
105+
type = bool
106+
default = true
107+
description = "Use SSH agent for bastion authentication"
108+
}
109+
110+
variable "ssh_bastion_private_key_file" {
111+
type = string
112+
default = ""
113+
description = "Path to SSH private key file for bastion authentication"
114+
}
115+
116+
variable "ssh_bastion_password" {
117+
type = string
118+
default = ""
119+
sensitive = true
120+
description = "Password for bastion host authentication (not recommended)"
121+
}
122+
86123
variable "ssh_user" {
87124
type = string
88125
default = null

0 commit comments

Comments
 (0)