Skip to content

Instantly share code, notes, and snippets.

@jbielick
Created February 23, 2021 00:24
Show Gist options
  • Save jbielick/cee131ac5300490df41adce7ffbf4607 to your computer and use it in GitHub Desktop.
Save jbielick/cee131ac5300490df41adce7ffbf4607 to your computer and use it in GitHub Desktop.
build {
sources = ["sources.googlecompute.sftp"]
provisioner "file" {
source = "files/hostkeys.tar.gz"
destination = "/tmp/hostkeys.tar.gz"
}
# https://github.com/GoogleCloudPlatform/guest-agent#configuration
# guest-agent overwrites our hostkeys, so we turn that off
provisioner "file" {
source = "files/instance_configs.cfg"
destination = "/tmp/instance_configs.cfg"
}
provisioner "shell" {
execute_command = "echo 'packer' | sudo -S env {{ .Vars }} {{ .Path }}"
inline = [
"mv /tmp/instance_configs.cfg /etc/default/instance_configs.cfg",
"tar -zxpf /tmp/hostkeys.tar.gz --directory /etc/ssh/",
"chown -R root:root /etc/ssh/"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment