74 lines
2.5 KiB
HCL
74 lines
2.5 KiB
HCL
|
#Flavour base
|
||
|
build {
|
||
|
name = "quid"
|
||
|
description = <<EOF
|
||
|
This builder builds a QEMU image from a Debian cloud image.
|
||
|
EOF
|
||
|
source "vmware-vmx.debian" {
|
||
|
output_directory = "${var.output_dir}/${var.version}/quid"
|
||
|
vm_name = "quid-${local.output_name}-${var.version}"
|
||
|
source_path = "${var.output_dir}/${var.version}/base/${local.output_name}-${var.version}.vmx"
|
||
|
boot_command = [ "<enter><enter><wait>" ]
|
||
|
ssh_clear_authorized_keys = true
|
||
|
disk_additional_size = [ 102400 ]
|
||
|
vmx_data = {
|
||
|
"scsi1.pcislotnumber" = "16"
|
||
|
"scsi1.present" = "TRUE"
|
||
|
"scsi1.virtualdev" = "lsilogic"
|
||
|
"scsi1:0.filename" = "disk-1.vmdk"
|
||
|
"scsi1:0.present" = "TRUE"
|
||
|
"scsi1:0.redo" = ""
|
||
|
}
|
||
|
vmx_data_post = {
|
||
|
"memsize" = "4096",
|
||
|
"numvcpus" = "2",
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Extend root logical volume with additional disk space
|
||
|
provisioner "shell" {
|
||
|
inline = [
|
||
|
"pvcreate /dev/sdb",
|
||
|
"vgextend debian-vg /dev/sdb",
|
||
|
"lvextend -l +100%FREE /dev/debian-vg/root",
|
||
|
"resize2fs /dev/debian-vg/root"
|
||
|
]
|
||
|
}
|
||
|
|
||
|
// Store temporarily ansible vault password in local file
|
||
|
provisioner "shell-local" {
|
||
|
inline = ["echo '${var.quid_ansible_vault_passphrase}' > '${local.locations.provisionning}/quid/.ansible_vault_passphrase'"]
|
||
|
}
|
||
|
|
||
|
// Clone quid-ansible repository
|
||
|
provisioner "ansible" {
|
||
|
playbook_file = "${local.locations.provisionning}/quid/clone-quid-ansible.yml"
|
||
|
// Manjaro/Arch OpenSSH version compatibility mode
|
||
|
// See https://github.com/hashicorp/packer/issues/11783
|
||
|
extra_arguments = [ "--scp-extra-args", "'-O'", "-v" ]
|
||
|
}
|
||
|
|
||
|
// Run quid-ansible playbook from cloned repository
|
||
|
provisioner "ansible" {
|
||
|
playbook_file = "${local.locations.provisionning}/quid/run-quid-ansible.yml"
|
||
|
groups = ["quid_server"]
|
||
|
// Manjaro/Arch OpenSSH version compatibility mode
|
||
|
// See https://github.com/hashicorp/packer/issues/11783
|
||
|
extra_arguments = [ "--scp-extra-args", "'-O'", "-v", "--vault-password-file=${local.locations.provisionning}/quid/.ansible_vault_passphrase", "--extra-vars=@${local.locations.provisionning}/quid/ansible-vars.yml" ]
|
||
|
}
|
||
|
|
||
|
// Remove ansible vault password file
|
||
|
provisioner "shell-local" {
|
||
|
inline = ["rm -f '${local.locations.provisionning}/quid/.ansible_vault_passphrase'"]
|
||
|
}
|
||
|
|
||
|
post-processor "shell-local" {
|
||
|
inline = [
|
||
|
"/bin/sh ${path.cwd}/post-processors/sparsify.sh ${var.output_dir}/${var.version}/quid ${var.image_version}",
|
||
|
]
|
||
|
}
|
||
|
|
||
|
post-processor "manifest" {
|
||
|
keep_input_artifact = true
|
||
|
}
|
||
|
}
|