71 lines
2.4 KiB
HCL
71 lines
2.4 KiB
HCL
|
#Flavour base
|
||
|
build {
|
||
|
name = "quid"
|
||
|
description = <<EOF
|
||
|
This builder builds a QEMU image from a Debian cloud image.
|
||
|
EOF
|
||
|
|
||
|
source "vmware-iso.debian" {
|
||
|
output_directory = "${var.output_dir}/${var.version}/quid"
|
||
|
vm_name = "quid-${local.output_name}-${var.version}"
|
||
|
disk_size = 10240
|
||
|
iso_url = "${local.source_iso}"
|
||
|
iso_checksum = "${var.iso_cd_checksum}"
|
||
|
guest_os_type = "ubuntu-64"
|
||
|
ssh_password = "quid"
|
||
|
http_content = {
|
||
|
"/ssh-packer-pub.key" = data.sshkey.install.public_key
|
||
|
"/preseed.cfg" = templatefile("${local.locations.provisionning}/${var.name}/http/preseed.cfg.pkrtpl.hcl", { data: data, var: var, local: local })
|
||
|
}
|
||
|
boot_command = [
|
||
|
"<esc><wait>",
|
||
|
"auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<enter><wait10s>",
|
||
|
"<enter>"
|
||
|
]
|
||
|
}
|
||
|
|
||
|
provisioner "shell-local" {
|
||
|
script = "${local.locations.provisionning}/quid/update-playbook.sh"
|
||
|
env = {
|
||
|
"REPO_DEST": "${local.locations.provisionning}/quid/quid-ansible",
|
||
|
"REPO_URL": "ssh://git@forge.cadoles.com:2222/EFS/quid-ansible.git",
|
||
|
"REPO_REF": "master"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
provisioner "shell" {
|
||
|
script = "${local.locations.provisionning}/${var.name}/${var.name}-${var.short_version}-install.sh"
|
||
|
}
|
||
|
|
||
|
provisioner "shell" {
|
||
|
script = "${local.locations.provisionning}/letsencrypt.sh"
|
||
|
}
|
||
|
|
||
|
// 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'"]
|
||
|
}
|
||
|
|
||
|
provisioner "ansible" {
|
||
|
playbook_file = "${local.locations.provisionning}/quid/quid-ansible/deploy.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
|
||
|
}
|
||
|
}
|