Skip to content

Commit 5717ae3

Browse files
committed
Allow specifying a bastion host for remote-exec provider
1 parent 6f30eee commit 5717ae3

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

main.tf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,15 @@ resource "libvirt_domain" "virt-machine" {
7676
"date"
7777
]
7878
connection {
79-
type = "ssh"
80-
user = var.ssh_admin
81-
host = var.ssh_host_override != null ? var.ssh_host_override : self.network_interface.0.addresses.0
82-
port = var.ssh_port_override
83-
private_key = var.ssh_private_key != null ? file(var.ssh_private_key) : null
79+
type = "ssh"
80+
user = var.ssh_admin
81+
host = var.ssh_host_override != null ? var.ssh_host_override : self.network_interface.0.addresses.0
82+
port = var.ssh_port_override
83+
private_key = var.ssh_private_key != null ? file(var.ssh_private_key) : null
84+
bastion_host = try(var.ssh_bastion_connect["host"], "") != "" ? var.ssh_bastion_connect["host"] : null
85+
bastion_user = try(var.ssh_bastion_connect["user"], "") != "" ? var.ssh_bastion_connect["user"] : null
86+
bastion_port = try(var.ssh_bastion_connect["port"], "") != "" ? var.ssh_bastion_connect["port"] : null
87+
bastion_private_key = try(var.ssh_bastion_connect["privkey"], null) != null ? var.ssh_bastion_connect["privkey"] : null
8488
timeout = "2m"
8589
}
8690
}

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ variable "ssh_port_override" {
177177
default = 22
178178
}
179179

180+
variable "ssh_bastion_connect" {
181+
description = "Use a bastion host to connect through"
182+
default = {
183+
host = ""
184+
port = "22"
185+
user = "root"
186+
passwd = ""
187+
privkey = null
188+
}
189+
}
180190

181191
variable "runcmd" {
182192
description = "Extra commands to be run with cloud init"

0 commit comments

Comments
 (0)