I have a computer that is sitting on my network, its running Ubuntu and I can connect with SSH. I would like to use Packers null
builder and define the communicator to provision the server but it is hung up on waiting for the SSH connection.
Here is the local.pkr.hcl
file:
source "null" "remote" {
ssh_host = "192.168.7.191"
ssh_username = "ubuntu"
ssh_password = "ubuntu"
communicator = "ssh"
}
build {
sources = ["sources.null.remote"]
provisioner "shell" {
inline = ["echo whoami"]
}
provisioner "shell-local" {
inline = ["echo whoami"]
}
}
Is this supported and is there a way to tell the communicator to use my local SSH key?
I don’t think its well documented, but here is the working version with variables:
variable "host" {
type = string
}
variable "private_key" {
type = string
default = "~/.ssh/id_rsa"
}
source "null" "remote" {
ssh_host = var.host
ssh_username = "ubuntu"
ssh_private_key_file = var.private_key
communicator = "ssh"
}
build {
sources = ["sources.null.remote"]
provisioner "shell" {
inline = ["whoami"]
}
provisioner "shell-local" {
inline = ["whoami"]
}
}
lists
May 25, 2022, 12:12pm
3
Thanks for sharing, unfortunately that didn’t work for me today.
I was more successful by setting “ssh_agent_auth” in my source-def:
source "null" "remote" {
ssh_host = "172.31.91.12"
ssh_username = "vagrant"
ssh_agent_auth = "true"
communicator = "ssh"
}