#Flavour base build { name = "base" description = <root", "", "setup-interfaces", "ifup eth0", "mkdir -p .ssh", "wget http://{{.HTTPIP}}:{{.HTTPPort}}/ssh-packer-pub.key -O .ssh/authorized_keys", "chmod 600 .ssh/authorized_keys", "wget http://{{.HTTPIP}}:{{.HTTPPort}}/install.conf", "setup-sshd -c openssh -k .ssh/authorized_keys", ] } source "qemu.alpine" { output_directory = "${var.output_dir}/${var.version}/base" vm_name = "${local.output_name}-${var.version}.img" disk_size = 8000 iso_url = "${local.source_iso}" iso_checksum = "${var.iso_cd_checksum}" http_content = { "/ssh-packer-pub.key" = data.sshkey.install.public_key "/install.conf" = templatefile("${local.locations.templates}/conf/install/awnsers.pktpl.hcl", local.installOpts) } boot_command = [ "root", "", "setup-interfaces", "ifup eth0", "mkdir -p .ssh", "wget http://{{.HTTPIP}}:{{.HTTPPort}}/ssh-packer-pub.key -O .ssh/authorized_keys", "chmod 600 .ssh/authorized_keys", "wget http://{{.HTTPIP}}:{{.HTTPPort}}/install.conf", "setup-sshd -c openssh -k .ssh/authorized_keys", ] } provisioner "shell" { pause_before = "1s" expect_disconnect = true # Because the previous step has rebooted the machine script = "${local.locations.provisionning}/${var.name}-${var.short_version}-install.sh" valid_exit_codes = [ 0, 141 ] } provisioner "shell" { pause_before = "1s" inline = [ "sh -cx 'mkdir -p ${local.builder_config.TemplateDir}'" ] } provisioner "shell" { pause_before = "10s" script = "${local.locations.provisionning}/${var.name}-${var.short_version}-postinstall.sh" } provisioner "shell" { script = "${local.locations.provisionning}/letsencrypt.sh" } provisioner "file" { destination = "/etc/conf.d/chronyd" source = "${local.locations.templates}/conf/conf.d/" } post-processor "manifest" { keep_input_artifact = true } post-processor "shell-local" { inline = [ "/bin/sh ${path.cwd}/post-processors/sparsify.sh ${var.output_dir}/${var.version}/base ${var.image_version}" ] } }