#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.nuo" { 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", ] } source "virtualbox-iso.nuo" { output_directory = "${var.output_dir}/${var.version}/base" vm_name = "${local.output_name}-${var.version}.img" disk_size = 10240 iso_url = "${local.source_iso}" iso_checksum = "${var.iso_cd_checksum}" guest_os_type = "Linux_64" cd_label = "cidata" cd_content = { "meta-data" = jsonencode(local.instance_data) "user-data" = templatefile("${local.locations.templates}/conf/cloud-init/user-data", { user = local.ssh_user, password = local.ssh_password, root_password = local.ssh_password, runcmd = [] ssh_keys = [ data.sshkey.install.public_key ] files = [ { path = "/root/install.conf" owner = "root" group = "root" permissions = "600" content = [ "KEYMAPOPTS=\"fr fr\"", "HOSTNAMEOPTS=\"-n nuo\"", "INTERFACESOPTS=\"auto lo", "iface lo inet loopback", "auto eth0", "iface eth0 inet dhcp", " hostname nuo\"", "DNSOPTS=\"\"", "TIMEZONEOPTS=\"-z Europe/Paris\"", "PROXYOPTS=\"none\"", "APKREPOSOPTS=\"-r -c\"", "SSHDOPTS=\"-c openssh -k /root/.ssh/authorized_keys\"", "NTPOPTS=\"-c openntpd\"", "DISKOPTS=\"-L -m sys /dev/sda\""] } ] } ) } boot_command = [] } 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}" ] } }