Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianLempa committed Sep 5, 2023
1 parent 9d0eb09 commit fc87b5b
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
**/terraform.tfstate
**/terraform.tfstate.backup
**/*.auto.tfvars

**/*.auto.pkrvars.hcl
packer-*.log
packer_cache/
*.iso
*.box
*.ova
41 changes: 41 additions & 0 deletions proxmox/prx-prod-2/packer/pkr-ubuntu-jammy/build.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
build {

name = "pkr-ubuntu-jammy"
sources = [
"source.proxmox-iso.eval-1",
"source.proxmox-iso.prod-1"
]

# Waiting for Cloud-Init to finish
provisioner "shell" {
inline = ["cloud-init status --wait"]
}

# Provisioning the VM Template for Cloud-Init Integration in Proxmox #1
provisioner "shell" {
execute_command = "echo -e '<user>' | sudo -S -E bash '{{ .Path }}'"
inline = [
"echo 'Starting Stage: Provisioning the VM Template for Cloud-Init Integration in Proxmox'",
"sudo rm /etc/ssh/ssh_host_*",
"sudo truncate -s 0 /etc/machine-id",
"sudo apt -y autoremove --purge",
"sudo apt -y clean",
"sudo apt -y autoclean",
"sudo cloud-init clean",
"sudo rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg",
"sudo rm -f /etc/netplan/00-installer-config.yaml",
"sudo sync",
"echo 'Done Stage: Provisioning the VM Template for Cloud-Init Integration in Proxmox'"
]
}

# Provisioning the VM Template for Cloud-Init Integration in Proxmox #2
provisioner "file" {
source = "pkr-ubuntu-jammy/files/99-pve.cfg"
destination = "/tmp/99-pve.cfg"
}
provisioner "shell" {
inline = ["sudo cp /tmp/99-pve.cfg /etc/cloud/cloud.cfg.d/99-pve.cfg"]
}

}
29 changes: 29 additions & 0 deletions proxmox/prx-prod-2/packer/pkr-ubuntu-jammy/config.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
packer {
required_plugins {
proxmox = {
version = ">= 1.1.3"
source = "github.com/hashicorp/proxmox"
}
}
}

variable "proxmox_api_url" {
type = string
}

variable "proxmox_api_token_id" {
type = string
}

variable "proxmox_api_token_secret" {
type = string
sensitive = true
}

variable "ssh_username" {
type = string
}

variable "ssh_private_key_file" {
type = string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
datasource_list: [ConfigDrive, NoCloud]
Empty file.
42 changes: 42 additions & 0 deletions proxmox/prx-prod-2/packer/pkr-ubuntu-jammy/http/user-data
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#cloud-config
autoinstall:
version: 1
locale: en_US
refresh-installer:
update: false
keyboard:
layout: de
ssh:
install-server: true
allow-pw: true
disable_root: true
ssh_quiet_keygen: true
allow_public_ssh_keys: true
storage:
layout:
name: direct
swap:
size: 0
network:
network:
version: 2
ethernets:
ens18:
dhcp4: yes
user-data:
package_upgrade: true
timezone: Europe/Berlin
users:
- name: xcad
groups: [adm, sudo]
lock-passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCsYvxYCpI90al2rJiyccPYNrvjHKLhvgTJVDssAL29jAPhl46gQctL98yZ+Rx9E3dLiHhs8SP14X2m50XbxX+QnjEjq2ywCqu359YMiitvaOgWMzKIaeiwnDngHc5NY+eC8t88bhhKmQPjejmdLSApLu7ObJ/9by2fjWptmqrkkhc1WQs58oYwNDenOd9UNaWcXtyPf2AGIIze2r1cFaEwAPyNtTlzCeqj41jKHLYorvU0CU5KUqgcgswXSgOC+moYac4WIUJCZCCU/s354NpKcJMYN/eiEpK1nZR/jhIe/pEsG4oIbCHy7f+PZruNhF6hi8UvhT+MHS0wwID/gj+UQPyg9GVieiQ1hv+NpLImkTdVJKemMf02548jEPhcrgLowuBemvtf4NHJE0FUH3chTu/Ioi66XKiedWdHMGLTBlWIUMuIYzHeFWLzCg8BqpQK0D7H48W7aku6JgWfhBdy5COvaglpRxlTAac8KURNtR1FRjxX9Lh1hHU+i5nLhIc= WSL2/XWIN
packages:
- qemu-guest-agent
- sudo
- vim
- zip
- unzip
65 changes: 65 additions & 0 deletions proxmox/prx-prod-2/packer/pkr-ubuntu-jammy/tpl-eval-1.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
source "proxmox-iso" "eval-1" {
proxmox_url = "${var.proxmox_api_url}"
username = "${var.proxmox_api_token_id}"
token = "${var.proxmox_api_token_secret}"
insecure_skip_tls_verify = false

node = "prx-prod-2"
vm_id = "90001"
vm_name = "pkr-ubuntu-jammy-eval-1"
template_description = "test"

iso_file = "local:iso/ubuntu-22.04.3-live-server-amd64.iso"
iso_storage_pool = "local"
unmount_iso = true
qemu_agent = true

scsi_controller = "virtio-scsi-pci"

cores = "1"
sockets = "1"
memory = "2048"

cloud_init = true
cloud_init_storage_pool = "local-lvm"

vga {
type = "virtio"
}

disks {
disk_size = "20G"
format = "raw"
storage_pool = "local-lvm"
type = "virtio"
}

network_adapters {
model = "virtio"
bridge = "vmbr1"
firewall = "false"
}

boot_command = [
"<esc><wait>",
"e<wait>",
"<down><down><down><end>",
"<bs><bs><bs><bs><wait>",
"autoinstall ds=nocloud-net\\;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ---<wait>",
"<f10><wait>"
]

boot = "c"
boot_wait = "6s"
communicator = "ssh"

http_directory = "pkr-ubuntu-jammy/http"

ssh_username = "${var.ssh_username}"
ssh_private_key_file = "${var.ssh_private_key_file}"

# Raise the timeout, when installation takes longer
ssh_timeout = "30m"
ssh_pty = true
ssh_handshake_attempts = 15
}
65 changes: 65 additions & 0 deletions proxmox/prx-prod-2/packer/pkr-ubuntu-jammy/tpl-prod-1.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
source "proxmox-iso" "prod-1" {
proxmox_url = "${var.proxmox_api_url}"
username = "${var.proxmox_api_token_id}"
token = "${var.proxmox_api_token_secret}"
insecure_skip_tls_verify = false

node = "prx-prod-2"
vm_id = "90002"
vm_name = "pkr-ubuntu-jammy-prod-1"
template_description = "test"

iso_file = "local:iso/ubuntu-22.04.3-live-server-amd64.iso"
iso_storage_pool = "local"
unmount_iso = true
qemu_agent = true

scsi_controller = "virtio-scsi-pci"

cores = "1"
sockets = "1"
memory = "2048"

cloud_init = true
cloud_init_storage_pool = "local-lvm"

vga {
type = "virtio"
}

disks {
disk_size = "20G"
format = "raw"
storage_pool = "local-lvm"
type = "virtio"
}

network_adapters {
model = "virtio"
bridge = "vmbr1"
firewall = "false"
}

boot_command = [
"<esc><wait>",
"e<wait>",
"<down><down><down><end>",
"<bs><bs><bs><bs><wait>",
"autoinstall ds=nocloud-net\\;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ---<wait>",
"<f10><wait>"
]

boot = "c"
boot_wait = "6s"
communicator = "ssh"

http_directory = "pkr-ubuntu-jammy/http"

ssh_username = "${var.ssh_username}"
ssh_private_key_file = "${var.ssh_private_key_file}"

# Raise the timeout, when installation takes longer
ssh_timeout = "30m"
ssh_pty = true
ssh_handshake_attempts = 15
}

0 comments on commit fc87b5b

Please sign in to comment.