summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host_vars/proxmox-iso.local.ymlbin0 -> 756 bytes
-rw-r--r--host_vars/proxmox-iso.local.yml.example34
-rw-r--r--inventory/hosts.yml2
-rw-r--r--proxmox.md29
-rw-r--r--roles/bootstrap/defaults/main.yml2
-rw-r--r--roles/bootstrap/meta/argument_specs.yml10
-rw-r--r--roles/bootstrap/tasks/install-proxmox.yml100
-rw-r--r--roles/bootstrap/tasks/main.yml6
-rw-r--r--roles/bootstrap/templates/refind_proxmox.conf.j219
-rw-r--r--roles/bootstrap/vars/proxmox.yml21
10 files changed, 222 insertions, 1 deletions
diff --git a/host_vars/proxmox-iso.local.yml b/host_vars/proxmox-iso.local.yml
new file mode 100644
index 0000000..d8744a3
--- /dev/null
+++ b/host_vars/proxmox-iso.local.yml
Binary files differ
diff --git a/host_vars/proxmox-iso.local.yml.example b/host_vars/proxmox-iso.local.yml.example
new file mode 100644
index 0000000..2775848
--- /dev/null
+++ b/host_vars/proxmox-iso.local.yml.example
@@ -0,0 +1,34 @@
+---
+hostname: "pve.local"
+bootstrap_proxmox: true
+partition_disk: "/dev/sda"
+partition_wipe: true
+partition_boot:
+ num: 1
+ name: "boot"
+ flags: [boot, esp]
+ part_start: "0%"
+ part_end: "1.0GiB"
+ fstype: "vfat"
+ fstype_opts: "-F 32"
+ dev: "{{ partition_disk }}1"
+ mount_path: "/mnt/boot/efi"
+ fstab_opts: "defaults,nodev,nosuid,noexec,umask=0077"
+partition_swap:
+ num: 2
+ name: "swap"
+ flags: [swap]
+ part_start: "1.0GiB"
+ part_end: "9.0GiB"
+ fstype: "ext4"
+ dev: "{{ partition_disk }}2"
+ mount_path: "none"
+partition_root:
+ num: 3
+ name: "pve-root"
+ part_start: "9.0GiB"
+ part_end: "100%"
+ fstype: "ext4"
+ dev: "{{ partition_disk }}3"
+ mount_path: "/mnt"
+configure_playbook_dir: "../ansible-distro-configure"
diff --git a/inventory/hosts.yml b/inventory/hosts.yml
index 5c0e002..435b07c 100644
--- a/inventory/hosts.yml
+++ b/inventory/hosts.yml
@@ -18,3 +18,5 @@ live_environments:
ansible_user: ubuntu
rpi5-iso.local:
ansible_user: pi
+ proxmox-iso.local:
+ ansible_user: user
diff --git a/proxmox.md b/proxmox.md
new file mode 100644
index 0000000..b4a08e4
--- /dev/null
+++ b/proxmox.md
@@ -0,0 +1,29 @@
+# Install Proxmox
+
+- Download [Debian Standard Live ISO](https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/)
+- Format a USB
+- Unmount disk (on MacOS ex. `diskutil unmountDisk /dev/diskX`)
+- Create bootable image from iso `sudo dd if=/path/to/image.iso of=/dev/diskX bs=4M status=progress`
+- Boot the `Debian Live ISO` live image from a bootable USB
+- Connect to wireless network (if not connected via LAN)
+- Set root password (which will be asked to run the install playbook)
+- Set the host name `proxmox-iso.local`
+- Install and configure ssh
+- `cp host_vars/proxmox-iso.local.example host_vars/proxmox-iso.local`
+- Update the `host_vars/proxmox-iso.local` file
+- Run the playbook on the ansible controller
+
+**Example:**
+
+```bash
+sudo hostnamectl set-hostname proxmox-iso
+sudo passwd user
+nmcli dev wifi connect <SSID> password <PASSPHRASE>
+sudo apt update
+sudo apt install -y openssh-server
+sudo systemctl restart ssh avahi-daemon
+```
+
+**Mac Example:**
+
+TBD
diff --git a/roles/bootstrap/defaults/main.yml b/roles/bootstrap/defaults/main.yml
index bf3753f..8f3e4fe 100644
--- a/roles/bootstrap/defaults/main.yml
+++ b/roles/bootstrap/defaults/main.yml
@@ -1,3 +1,5 @@
---
bootstrap_mac: false
bootstrap_mac_boot_args: "acpi_osi=Darwin i915.modeset=1 acpi_mask_gpe=0x06"
+bootstrap_pi: false
+bootstrap_proxmox: false
diff --git a/roles/bootstrap/meta/argument_specs.yml b/roles/bootstrap/meta/argument_specs.yml
index 1744925..b758378 100644
--- a/roles/bootstrap/meta/argument_specs.yml
+++ b/roles/bootstrap/meta/argument_specs.yml
@@ -24,3 +24,13 @@ argument_specs:
required: false
default: "acpi_osi=Darwin i915.modeset=1 acpi_mask_gpe=0x06"
description: "Extra kernel boot arguments appended to rEFInd boot entries when bootstrap_mac is true"
+ bootstrap_pi:
+ type: "bool"
+ required: false
+ default: false
+ description: "Install Raspberry PI OS (Raspberry ISO reports as Debian)"
+ bootstrap_proxmox:
+ type: "bool"
+ required: false
+ default: false
+ description: "Install Proxmox VE (Using Debian Live ISO since Proxmox ISO lacks automation)"
diff --git a/roles/bootstrap/tasks/install-proxmox.yml b/roles/bootstrap/tasks/install-proxmox.yml
new file mode 100644
index 0000000..7a3b92a
--- /dev/null
+++ b/roles/bootstrap/tasks/install-proxmox.yml
@@ -0,0 +1,100 @@
+---
+- name: "Include distribution vars"
+ ansible.builtin.include_vars: "proxmox.yml"
+
+- name: "Ensure install dependencies are installed on live environment"
+ ansible.builtin.apt:
+ state: "present"
+ update_cache: true
+ pkg:
+ - "debootstrap"
+ - "arch-install-scripts"
+ - "bash"
+
+- name: "Run debootstrap"
+ ansible.builtin.command:
+ cmd: "debootstrap
+ {{ bootstrap_opts }}
+ {{ bootstrap_distro.name }}
+ {{ mnt_root_path }}
+ {{ bootstrap_distro.mirror_url }}"
+ changed_when: true
+
+- name: "Generate fstab"
+ ansible.builtin.shell:
+ cmd: "genfstab -t PARTLABEL {{ mnt_root_path }} > {{ mnt_root_path }}/etc/fstab"
+ changed_when: true
+
+- name: "Download Proxmox repo signing key"
+ ansible.builtin.get_url:
+ url: "https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg"
+ dest: "{{ mnt_root_path }}/etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg"
+ mode: "0644"
+
+- name: "Configure apt in chroot"
+ ansible.builtin.copy:
+ dest: "{{ item.dest }}"
+ mode: "0640"
+ content: "{{ item.content }}"
+ loop:
+ - dest: "{{ mnt_root_path }}/etc/apt/preferences.d/ignored-package"
+ content: "{{ bootstrap_apt_ignored_preferences }}"
+ - dest: "{{ mnt_root_path }}/etc/apt/sources.list"
+ content: "{{ bootstrap_apt_sources }}"
+ - dest: "{{ mnt_root_path }}/etc/apt/sources.list.d/pve-no-subscription.list"
+ content: "{{ bootstrap_proxmox_apt_sources }}"
+
+- name: "Configure system in chroot"
+ ansible.builtin.command:
+ cmd: "arch-chroot {{ mnt_root_path }} {{ item }}"
+ changed_when: true
+ loop:
+ - "apt-get update"
+ - "apt-get install -y {{ bootstrap_distro.packages | join(' ') }}"
+
+- name: "Ensure rEFInd package installed"
+ ansible.builtin.command:
+ cmd: "arch-chroot {{ mnt_root_path }} apt-get install -y refind"
+ changed_when: true
+
+- name: "Install rEFInd to EFI partition"
+ ansible.builtin.command:
+ cmd: "arch-chroot {{ mnt_root_path }} refind-install"
+ changed_when: true
+
+- name: "Ensure proxmox EFI boot directory exists"
+ ansible.builtin.file:
+ path: "{{ mnt_boot_path }}/EFI/proxmox"
+ state: directory
+ mode: "0755"
+
+- name: "Copy kernel to EFI partition"
+ ansible.builtin.shell:
+ cmd: |
+ cp {{ mnt_root_path }}/boot/vmlinuz-*-pve {{ mnt_boot_path }}/EFI/proxmox/vmlinuz
+ cp {{ mnt_root_path }}/boot/initrd.img-*-pve {{ mnt_boot_path }}/EFI/proxmox/initrd.img
+ changed_when: true
+
+- name: "Configure rEFInd"
+ ansible.builtin.template:
+ src: "refind_proxmox.conf.j2"
+ dest: "{{ mnt_boot_path }}/EFI/BOOT/refind.conf"
+ mode: "0644"
+ # NOTE: this is skipped because the docker test doesn't have proper EFI/refind directory created
+ # NOTE: Debian's refind-install falls back to EFI/BOOT/ when NVRAM entries can't be registered in chroot
+ tags: ["molecule-notest"]
+
+- name: "Ensure kernel post-install hook directory exists"
+ ansible.builtin.file:
+ path: "{{ mnt_root_path }}/etc/kernel/postinst.d"
+ state: directory
+ mode: "0755"
+
+- name: "Install kernel sync script for EFI partition"
+ ansible.builtin.copy:
+ dest: "{{ mnt_root_path }}/etc/kernel/postinst.d/refind-sync-kernel"
+ mode: "0755"
+ content: |
+ #!/bin/sh
+ cp $(ls -t /boot/vmlinuz-*-pve | head -1) /boot/efi/EFI/proxmox/vmlinuz
+ cp $(ls -t /boot/initrd.img-*-pve | head -1) /boot/efi/EFI/proxmox/initrd.img
diff --git a/roles/bootstrap/tasks/main.yml b/roles/bootstrap/tasks/main.yml
index 50e2ce2..41ec0eb 100644
--- a/roles/bootstrap/tasks/main.yml
+++ b/roles/bootstrap/tasks/main.yml
@@ -26,7 +26,11 @@
- name: "Install raspberry"
ansible.builtin.include_tasks: "install-raspberry.yml"
- when: ansible_facts['distribution'] == "Debian" and ansible_facts['architecture'] == "aarch64"
+ when: ansible_facts['distribution'] == "Debian" and bootstrap_pi
+
+ - name: "Install proxmox"
+ ansible.builtin.include_tasks: "install-proxmox.yml"
+ when: ansible_facts['distribution'] == "Debian" and bootstrap_proxmox
- name: "Ensure ansible dependencies are installed in chroot"
ansible.builtin.command:
diff --git a/roles/bootstrap/templates/refind_proxmox.conf.j2 b/roles/bootstrap/templates/refind_proxmox.conf.j2
new file mode 100644
index 0000000..e38c223
--- /dev/null
+++ b/roles/bootstrap/templates/refind_proxmox.conf.j2
@@ -0,0 +1,19 @@
+timeout 5
+textonly true
+scan_all_linux_kernels false
+dont_scan_files vmlinuz,vmlinuz-linux,initrd.img,initramfs-linux.img
+hideui hints
+
+menuentry "Proxmox VE" {
+ volume "boot"
+ loader \EFI\proxmox\vmlinuz
+ initrd \EFI\proxmox\initrd.img
+ options "root=PARTLABEL={{ partition_root.name }} rw rootwait console=tty1{% if bootstrap_mac %} {{ bootstrap_mac_boot_args }}{% endif %}"
+}
+
+menuentry "Proxmox VE (terminal)" {
+ volume "boot"
+ loader \EFI\proxmox\vmlinuz
+ initrd \EFI\proxmox\initrd.img
+ options "root=PARTLABEL={{ partition_root.name }} rw rootwait console=tty1 systemd.unit=multi-user.target{% if bootstrap_mac %} {{ bootstrap_mac_boot_args }}{% endif %}"
+}
diff --git a/roles/bootstrap/vars/proxmox.yml b/roles/bootstrap/vars/proxmox.yml
new file mode 100644
index 0000000..9833ad3
--- /dev/null
+++ b/roles/bootstrap/vars/proxmox.yml
@@ -0,0 +1,21 @@
+---
+bootstrap_distro:
+ name: "bookworm" # => Proxmox VE 8.x (Debian 12)
+ mirror_url: "http://deb.debian.org/debian"
+ packages:
+ - "proxmox-default-kernel"
+
+bootstrap_opts: ""
+
+bootstrap_apt_ignored_preferences: |
+ Package: grub-common grub2-common grub-pc grub-pc-bin
+ Pin: release *
+ Pin-Priority: -1
+
+bootstrap_apt_sources: |
+ deb http://deb.debian.org/debian bookworm main contrib
+ deb http://deb.debian.org/debian bookworm-updates main contrib
+ deb http://security.debian.org/debian-security bookworm-security main contrib
+
+bootstrap_proxmox_apt_sources: |
+ deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription