Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PVE 8 image builder #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ansible/build-iscsi-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
- storpool.install_sp_python
- storpool.bootstrap_node

- name: Proxmox VE installation
hosts: all
become_method: sudo
roles:
- pve
tags:
- never
- proxmox_ve

- name: Reboot hosts that requite so
hosts: all
become_method: sudo
Expand Down
45 changes: 45 additions & 0 deletions ansible/roles/pve/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
- name: Add PVE signing key
become: true
ansible.builtin.apt_key:
url: "https://enterprise.proxmox.com/debian/proxmox-release-{{ ansible_distribution_release | lower }}.gpg"
state: present

- name: Add PVE repository into sources list
become: true
ansible.builtin.apt_repository:
repo: "deb [arch=amd64] http://download.proxmox.com/debian/pve {{ ansible_distribution_release | lower }} pve-no-subscription"
state: present

- name: Update
become: true
ansible.builtin.apt:
update_cache: true
upgrade: full

- name: Install PVE kernel
become: true
ansible.builtin.apt:
name: pve-kernel-6.2
state: latest

- name: Rebooting host
become: true
ansible.builtin.reboot:
reboot_timeout: 900

- name: Install PVE packages
become: true
ansible.builtin.apt:
name: "{{ pve_packages }}"
state: latest

- name: Remove Debian kernel and os-prober
become: true
ansible.builtin.command:
cmd: apt-get remove -y linux-image-6.1* os-prober

- name: Remove GRUB zero timeout
become: true
ansible.builtin.file:
path: "/etc/default/grub.d/15_timeout.cfg"
state: absent
6 changes: 6 additions & 0 deletions ansible/roles/pve/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pve_packages:
- proxmox-ve
- postfix
- open-iscsi
- chrony

10 changes: 10 additions & 0 deletions cloud-init/network-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
network:
version: 2
ethernets:
ens3:
dhcp4: true
nameservers:
addresses:
- '10.2.1.254'
search:
- lab.storpool.local
54 changes: 54 additions & 0 deletions pve.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
source "qemu" "pve-8-latest" {
iso_url = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2"
iso_checksum = "file:https://cloud.debian.org/images/cloud/bookworm/latest/SHA512SUMS"
format = "raw"
cpus = 4
memory = 2048
disk_image = true
disk_size = "10G"
headless = true
disable_vnc = true
cd_files = ["./cloud-init/meta-data", "./cloud-init/user-data", "./cloud-init/network-config"]
cd_label = "cidata"
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
ssh_username = "debian"
ssh_password = "passw0rd"
qemu_binary = "/usr/libexec/qemu-kvm"
}


build {
source "qemu.pve-8-latest" {
vm_name = "pve-8.raw"
output_directory = "builds/cloud/qemu.pve-8-latest/${formatdate("YYYY-MM-DD-hh", timestamp())}"
}

name = "cloud"

provisioner "ansible" {
playbook_file = "${path.root}/ansible/build-iscsi-image.yml"
extra_arguments = [
"-vv",
"--tags",
"all,proxmox_ve",
"--skip-tags",
"check-requirements,cleanup_ifcfg_files,ironic-iscsi",
"-e",
"sp_inventory_url=http://sp-mgmt.lab.storpool.local",
"-e",
"ansible_ssh_pass=passw0rd",
]
user = "debian"
galaxy_file = "${path.root}/ansible/resources.yml"
roles_path = "${path.root}/ansible/roles/"
}

post-processor "checksum" {
checksum_types = ["md5", "sha256"]
output = "builds/${build.name}/${source.name}/${formatdate("YYYY-MM-DD-hh", timestamp())}/{{.ChecksumType}}.checksum"
}

post-processor "manifest" {
output = "builds/${build.name}/${source.name}/${formatdate("YYYY-MM-DD-hh", timestamp())}/manifest.json"
}
}
2 changes: 1 addition & 1 deletion versions.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ packer {
source = "github.com/hashicorp/qemu"
}
ansible = {
version = ">= 1.0.3"
version = ">= 1.1.0"
source = "github.com/hashicorp/ansible"
}
}
Expand Down