init
This commit is contained in:
91
packer/proxmox/debian13/debian13.pkr.hcl
Normal file
91
packer/proxmox/debian13/debian13.pkr.hcl
Normal file
@@ -0,0 +1,91 @@
|
||||
packer {
|
||||
required_plugins {
|
||||
proxmox = {
|
||||
source = "github.com/hashicorp/proxmox"
|
||||
version = ">= 1.2.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
source "proxmox-iso" "debian13" {
|
||||
proxmox_url = "https://192.168.0.126:8006/api2/json"
|
||||
username = "root@pam!packer"
|
||||
token = "7f3cd12a-c98e-4aec-abca-8d7fd1005fd7"
|
||||
insecure_skip_tls_verify = true
|
||||
|
||||
node = "proxmox-main-kyiv-01"
|
||||
vm_id = 300
|
||||
vm_name = "dev-kyiv01-template-packer-main-01"
|
||||
template_name = "dev-kyiv01-template-packer-main-01"
|
||||
tags = "debian-13"
|
||||
|
||||
os = "l26"
|
||||
bios = "seabios"
|
||||
machine = "q35"
|
||||
cpu_type = "qemu64"
|
||||
cores = 1
|
||||
sockets = 1
|
||||
memory = 1024
|
||||
|
||||
qemu_agent = true
|
||||
|
||||
scsi_controller = "virtio-scsi-single"
|
||||
|
||||
network_adapters {
|
||||
model = "virtio"
|
||||
bridge = "vmbr0"
|
||||
firewall = false
|
||||
mac_address = "repeatable"
|
||||
}
|
||||
|
||||
disks {
|
||||
type = "scsi"
|
||||
storage_pool = "local-lvm"
|
||||
disk_size = "4G"
|
||||
io_thread = true
|
||||
discard = true
|
||||
ssd = true
|
||||
}
|
||||
|
||||
boot_iso {
|
||||
type = "scsi"
|
||||
iso_file = "local:iso/debian-13.2.0-amd64-netinst.iso"
|
||||
unmount = true
|
||||
}
|
||||
|
||||
# ===== HTTP preseed =====
|
||||
http_directory = "${path.root}/http"
|
||||
http_bind_address = "192.168.0.200"
|
||||
http_port_min = 8870
|
||||
http_port_max = 8870
|
||||
boot_wait = "10s"
|
||||
boot_key_interval = "25ms"
|
||||
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto auto=true priority=critical ",
|
||||
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
|
||||
"debian-installer=en_US ",
|
||||
"fb=false ",
|
||||
"<enter>"
|
||||
]
|
||||
|
||||
# ===== SSH =====
|
||||
ssh_username = "packer"
|
||||
ssh_password = "14881488"
|
||||
ssh_timeout = "35m"
|
||||
|
||||
cloud_init = false
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.proxmox-iso.debian13"]
|
||||
|
||||
provisioner "shell" {
|
||||
execute_command = "sudo -S -E bash '{{ .Path }}'"
|
||||
scripts = [
|
||||
"scripts/10-base.sh",
|
||||
"scripts/90-cleanup.sh"
|
||||
]
|
||||
}
|
||||
}
|
||||
100
packer/proxmox/debian13/http/preseed.cfg
Normal file
100
packer/proxmox/debian13/http/preseed.cfg
Normal file
@@ -0,0 +1,100 @@
|
||||
### Locale / Keyboard
|
||||
d-i debian-installer/locale string en_US.UTF-8
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
### Network (DHCP)
|
||||
d-i netcfg/choose_interface select auto
|
||||
d-i netcfg/get_hostname string debian
|
||||
d-i netcfg/get_domain string local
|
||||
|
||||
### Mirror
|
||||
d-i mirror/country string manual
|
||||
d-i mirror/http/hostname string deb.debian.org
|
||||
d-i mirror/http/directory string /debian
|
||||
d-i mirror/http/proxy string
|
||||
|
||||
### User
|
||||
d-i passwd/root-login boolean false
|
||||
# d-i passwd/root-password password 14881488
|
||||
# d-i passwd/root-password-again password 14881488
|
||||
d-i passwd/user-fullname string Packer User
|
||||
d-i passwd/username string packer
|
||||
d-i passwd/user-password password 14881488
|
||||
d-i passwd/user-password-again password 14881488
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
|
||||
### Time
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i time/zone string UTC
|
||||
|
||||
### Partitioning (LVM expert: /boot + VG vg0 + LV swap + LV root=rest)
|
||||
d-i partman-auto/disk string /dev/sda
|
||||
d-i partman-auto/method string lvm
|
||||
|
||||
# если на диске были старые LVM/RAID — снести без вопросов
|
||||
d-i partman-lvm/device_remove_lvm boolean true
|
||||
d-i partman-md/device_remove_md boolean true
|
||||
d-i partman-md/confirm boolean true
|
||||
d-i partman-md/confirm_nooverwrite boolean true
|
||||
|
||||
# имя VG фиксируем
|
||||
d-i partman-auto-lvm/new_vg_name string vg0
|
||||
d-i partman-auto-lvm/guided_size string max
|
||||
|
||||
# рецепт разметки
|
||||
d-i partman-auto/choose_recipe select boot-root-lvm-swap
|
||||
d-i partman-auto/expert_recipe string \
|
||||
boot-root-lvm-swap :: \
|
||||
512 512 1024 ext4 \
|
||||
$primary{ } $bootable{ } \
|
||||
method{ format } format{ } \
|
||||
use_filesystem{ } filesystem{ ext4 } \
|
||||
mountpoint{ /boot } \
|
||||
. \
|
||||
1024 1024 -1 lvm \
|
||||
$primary{ } \
|
||||
method{ lvm } device{ /dev/sda } \
|
||||
vg_name{ vg0 } \
|
||||
. \
|
||||
2048 2048 2048 linux-swap \
|
||||
$lvmok{ } \
|
||||
in_vg{ vg0 } lv_name{ swap } \
|
||||
method{ swap } format{ } \
|
||||
. \
|
||||
4096 4096 -1 ext4 \
|
||||
$lvmok{ } \
|
||||
in_vg{ vg0 } lv_name{ root } \
|
||||
method{ format } format{ } \
|
||||
use_filesystem{ } filesystem{ ext4 } \
|
||||
mountpoint{ / } \
|
||||
.
|
||||
|
||||
# подтверждения без интерактива
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm_write_new_label boolean true
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
|
||||
### Packages
|
||||
tasksel tasksel/first multiselect standard, ssh-server
|
||||
d-i pkgsel/include string sudo openssh-server cloud-init qemu-guest-agent ca-certificates curl
|
||||
popularity-contest popularity-contest/participate boolean false
|
||||
|
||||
### Bootloader
|
||||
d-i grub-installer/only_debian boolean true
|
||||
d-i grub-installer/bootdev string /dev/sda
|
||||
|
||||
# debconf for grub-pc package (this is the screen you see)
|
||||
d-i grub-pc/install_devices multiselect /dev/sda
|
||||
d-i grub-pc/install_devices_empty boolean false
|
||||
|
||||
### Late command (самое важное)
|
||||
d-i preseed/late_command string \
|
||||
in-target usermod -aG sudo packer; \
|
||||
echo 'packer ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/packer; \
|
||||
chmod 440 /target/etc/sudoers.d/packer;
|
||||
|
||||
### Finish
|
||||
d-i finish-install/reboot_in_progress note
|
||||
16
packer/proxmox/debian13/readme.md
Normal file
16
packer/proxmox/debian13/readme.md
Normal file
@@ -0,0 +1,16 @@
|
||||
```bash
|
||||
set -a
|
||||
source ./.env
|
||||
set +a
|
||||
|
||||
packer init .
|
||||
packer fmt -recursive .
|
||||
packer validate .
|
||||
PACKER_LOG=1 packer build -on-error=ask -timestamp-ui .
|
||||
```
|
||||
|
||||
```bash
|
||||
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
|
||||
sudo fdisk -l /dev/sda | sed -n '1,120p'
|
||||
cloud-init status --long
|
||||
```
|
||||
10
packer/proxmox/debian13/scripts/10-base.sh
Normal file
10
packer/proxmox/debian13/scripts/10-base.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update
|
||||
apt-get -y dist-upgrade
|
||||
|
||||
apt-get -y install qemu-guest-agent sudo
|
||||
|
||||
systemctl enable --now qemu-guest-agent || true
|
||||
22
packer/proxmox/debian13/scripts/90-cleanup.sh
Normal file
22
packer/proxmox/debian13/scripts/90-cleanup.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# cloud-init: очистить состояние
|
||||
cloud-init clean --logs || true
|
||||
|
||||
# machine-id: должен быть уникальный на каждом клоне
|
||||
truncate -s 0 /etc/machine-id || true
|
||||
rm -f /var/lib/dbus/machine-id || true
|
||||
ln -sf /etc/machine-id /var/lib/dbus/machine-id || true
|
||||
|
||||
# ssh host keys: перегенерятся на клоне
|
||||
rm -f /etc/ssh/ssh_host_* || true
|
||||
|
||||
# чистка кешей/листов
|
||||
apt-get -y autoremove --purge
|
||||
apt-get -y clean
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
find /var/log -type f -exec truncate -s 0 {} \; || true
|
||||
|
||||
sync
|
||||
Reference in New Issue
Block a user