Skip to content

Commit d8b0b3b

Browse files
committed
Allow SSH host/port override
1 parent 3151cf3 commit d8b0b3b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ No modules.
6767
| <a name="input_ssh_admin"></a> [ssh\_admin](#input\_ssh\_admin) | Admin user with ssh access | `string` | `"ssh-admin"` | no |
6868
| <a name="input_ssh_keys"></a> [ssh\_keys](#input\_ssh\_keys) | List of public ssh keys | `list(string)` | `[]` | no |
6969
| <a name="input_ssh_private_key"></a> [ssh\_private\_key](#input\_ssh\_private\_key) | Private key for SSH connection test | `any` | `null` | no |
70+
| <a name="input_ssh_host_override"></a> [ssh\_host\_override](#input\_ssh\_private\_key) | Host override for SSH connection test | `string` | `null` | no |
71+
| <a name="input_ssh_port_override"></a> [ssh\_port\_override](#input\_ssh\_private\_key) | Port override for SSH connection test | `string` | `"22"` | no |
7072
| <a name="input_system_volume"></a> [system\_volume](#input\_system\_volume) | System Volume size (GB) | `number` | `10` | no |
7173
| <a name="input_time_zone"></a> [time\_zone](#input\_time\_zone) | Time Zone | `string` | `"UTC"` | no |
7274
| <a name="input_vcpu"></a> [vcpu](#input\_vcpu) | Number of vCPUs | `number` | `1` | no |

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ resource "libvirt_domain" "virt-machine" {
7878
connection {
7979
type = "ssh"
8080
user = var.ssh_admin
81-
host = self.network_interface.0.addresses.0
81+
host = var.ssh_host_override != null ? var.ssh_host_override : self.network_interface.0.addresses.0
82+
port = var.ssh_port_override
8283
private_key = var.ssh_private_key != null ? file(var.ssh_private_key) : null
8384
timeout = "2m"
8485
}

variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ variable "ssh_private_key" {
167167
default = null
168168
}
169169

170+
variable "ssh_host_override" {
171+
description = "Host for SSH connection test"
172+
default = null
173+
}
174+
175+
variable "ssh_port_override" {
176+
description = "Port for SSH connection test"
177+
default = 22
178+
}
179+
180+
170181
variable "runcmd" {
171182
description = "Extra commands to be run with cloud init"
172183
type = list(string)

0 commit comments

Comments
 (0)