07 draft L1

Template OPNsense 26 — build Packer

OS Cible
Progression 0% 0 / 9

Contexte

Build du template Proxmox OPNsense 26.1 via Packer avec stratégie inline (boot_command VNC). Produit template-opnsense26 (VM 9200) prêt à cloner par Terraform.

Actions

9
  • Contexte 1 cmd
    $ Commandes
    $ 1. Packer crée VM 9200 vide sur coruscant (proxmox-iso plugin) 2. Boot OPNsense live ISO (jedha-data:iso/OPNsense-26.1.6-dvd-amd64.iso) 3. boot_command VNC : login root → menu OPNsense → option 8 Shell 4. gpart destroy/create GPT sur da0 (20 GB scsi) 5. gpart add freebsd-boot 512k + swap 4G + ufs (reste) 6. newfs -j /dev/da0p3 + mount /mnt 7. tar -cpf - / | tar -xpf - -C /mnt (copie live → disque ~30s) 8. fstab + rc.conf + sshd_config + root password 9. Injecte clé SSH minfra dans /root/.ssh/authorized_keys du LIVE 10. ifconfig vtnet1 10.0.1.250 → Packer SSH se connecte via bastion coruscant 11. provisioner shell : post_install.sh écrit config.xml prod dans /mnt 12. Shutdown VM + conversion en template Proxmox (template-opnsense26)
  • Précheck — vérifier tous les prérequis 3 cmd 2 verify
    $ Commandes
    PS> cd D:\git\minfra-v2 wsl bash dev/bash/opnsense_precheck.sh
    PS> task -- packer:iso:upload ISO_BZ2="\\jedha\data\iso\OPNsense-26.1.6-dvd-amd64.iso.bz2"
    PS> task -- packer:secrets:init TOKEN_SECRET=<token-pam-packer>
    ✓ Vérifications
    bash dev/bash/opnsense_precheck.sh ; echo $?
    ls infra/packer/secrets/proxmox.yaml
  • Init plugin Packer (1×) 1 cmd 1 verify
    $ Commandes
    PS> cd D:\git\minfra-v2 task -- packer:init
    ✓ Vérifications
    wsl bash -c "ls ~/.packer.d/plugins/github.com/hashicorp/proxmox/"
  • Valider la syntaxe HCL (sans build) 1 cmd 1 verify
    $ Commandes
    PS> task -- packer:build:opnsense:check
    ✓ Vérifications
    echo $LASTEXITCODE # doit être 0
  • Lancer le build 1 cmd 1 verify
    $ Commandes
    PS> task opnsense:template:deploy
    ✓ Vérifications
    ssh -i ~/.ssh/id_ed25519_minfra root@10.0.1.30 'qm list | grep 9200'
  • Si le build plante en cours 1 cmd 1 verify
    $ Commandes
    PS> task opnsense:template:destroy
    ✓ Vérifications
    ssh root@10.0.1.30 'qm status 9200 2>&1' # doit retourner "Configuration file does not exist"
  • Vérifier le template post-build 2 cmd 1 verify
    $ Commandes
    PS> # SSH coruscant + qm list filtrer template wsl bash -c "ssh -i ~/.ssh/id_ed25519_minfra root@10.0.1.30 'qm config 9200 | grep -E \"^(name|template|memory|cores|net0|net1):\"'"
    $ name: template-opnsense26 template: 1 memory: 4096 cores: 2 net0: virtio,bridge=vmbr0,tag=999 net1: virtio,bridge=vmbr0
    ✓ Vérifications
    ssh root@10.0.1.30 'qm config 9200 | grep -q template:.1'
  • Cloner pour créer la VM OPNsense prod 1 cmd 1 verify
    $ Commandes
    PS> task opnsense:vm:deploy
    ✓ Vérifications
    ssh -i ~/.ssh/id_ed25519_minfra root@10.0.1.1 'uname -a'
  • Configurer OPNsense via Ansible 1 cmd 1 verify
    $ Commandes
    PS> task opnsense:config
    ✓ Vérifications
    task opnsense:postcheck