first commit
This commit is contained in:
commit
f368c1360e
5 changed files with 351 additions and 0 deletions
94
packer/debian12/debian12.pkr.hcl
Normal file
94
packer/debian12/debian12.pkr.hcl
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
packer {
|
||||
required_plugins {
|
||||
xenserver= {
|
||||
version = "= v0.7.3"
|
||||
source = "github.com/ddelnano/xenserver"
|
||||
}
|
||||
}
|
||||
}
|
||||
variable "remote_host" {
|
||||
type = string
|
||||
description = "The ip or fqdn of your XCP-ng. It must be the master"
|
||||
sensitive = true
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
variable "remote_username" {
|
||||
type = string
|
||||
description = "The username used to interact with your XCP-ng"
|
||||
sensitive = true
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
variable "remote_password" {
|
||||
type = string
|
||||
description = "The password used to interact with your XCP-ng"
|
||||
sensitive = true
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
variable "sr_iso_name" {
|
||||
type = string
|
||||
description = "The ISO-SR to packer will use"
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
variable "sr_name" {
|
||||
type = string
|
||||
description = "The name of the SR to packer will use"
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
|
||||
source "xenserver-iso" "debian12" {
|
||||
iso_checksum = "8fde79cfc6b20a696200fc5c15219cf6d721e8feb367e9e0e33a79d1cb68fa83"
|
||||
iso_url = "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.7.0-amd64-netinst.iso"
|
||||
|
||||
sr_iso_name = var.sr_iso_name
|
||||
sr_name = var.sr_name
|
||||
tools_iso_name = ""
|
||||
|
||||
remote_host = var.remote_host
|
||||
remote_password = var.remote_password
|
||||
remote_username = var.remote_username
|
||||
|
||||
http_directory = "http"
|
||||
ip_getter = "tools"
|
||||
|
||||
boot_command = [
|
||||
"<wait><wait><wait><esc><wait><wait><wait>",
|
||||
"/install.amd/vmlinuz ",
|
||||
"initrd=/install.amd/initrd.gz ",
|
||||
"auto=true ",
|
||||
"domain= ",
|
||||
"url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed.cfg ",
|
||||
"hostname=debian ",
|
||||
"interface=auto ",
|
||||
"vga=788 noprompt quiet--- <enter>"
|
||||
]
|
||||
|
||||
# Change this to match the ISO of ubuntu you are using in the iso_url variable
|
||||
clone_template = "Debian Bookworm 12"
|
||||
vm_name = "Debian 12 template test"
|
||||
vm_description = "My first template with packer"
|
||||
vcpus_max = 2
|
||||
vcpus_atstartup = 2
|
||||
vm_memory = 2048 #MB
|
||||
network_names = ["prod_eth2"]
|
||||
disk_size = 20480 #MB
|
||||
disk_name = "debian 12 disk"
|
||||
vm_tags = ["Generated by Packer"]
|
||||
|
||||
ssh_username = "debian"
|
||||
ssh_password = "debian"
|
||||
ssh_wait_timeout = "60000s"
|
||||
ssh_handshake_attempts = 10000
|
||||
|
||||
output_directory = "packer-debian-12"
|
||||
keep_vm = "never"
|
||||
format = "xva_compressed"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["xenserver-iso.debian12"]
|
||||
}
|
||||
76
packer/debian12/http/preseed.cfg
Normal file
76
packer/debian12/http/preseed.cfg
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# Locale Setup
|
||||
d-i debian-installer/language string en
|
||||
d-i debian-installer/country string US
|
||||
d-i debian-installer/locale string en_US.UTF-8
|
||||
|
||||
# Keyboard Setup
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
# Clock Setup
|
||||
d-i time/zone string US/Eastern
|
||||
|
||||
# Configure hardware clock
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i clock-setup/utc-auto boolean true
|
||||
# set above to false if making a bootable USB to run on same system as Windows
|
||||
|
||||
# User Setup
|
||||
d-i passwd/root-login boolean true
|
||||
d-i passwd/root-password-again password debian
|
||||
d-i passwd/root-password password debian
|
||||
d-i passwd/user-fullname string debian
|
||||
d-i passwd/user-uid string 1000
|
||||
d-i passwd/user-password password debian
|
||||
d-i passwd/user-password-again password debian
|
||||
d-i passwd/username string debian
|
||||
|
||||
# Package Setup
|
||||
d-i apt-setup/cdrom/set-first boolean false
|
||||
d-i apt-setup/cdrom/set-next boolean false
|
||||
d-i apt-setup/cdrom/set-failed boolean false
|
||||
|
||||
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
|
||||
tasksel tasksel/first multiselect ssh-server, standard
|
||||
popularity-contest popularity-contest/participate boolean false
|
||||
d-i pkgsel/include string sudo, unattended-upgrades, dpkg, cloud-init, cloud-guest-utils, cloud-initramfs-growroot, cloud-image-utils, cloud-utils
|
||||
# Whether to upgrade packages after debootstrap
|
||||
d-i pkgsel/upgrade select full-upgrade
|
||||
|
||||
# Disk configuration
|
||||
d-i partman-basicfilesystems/choose_label string gpt
|
||||
d-i partman-basicfilesystems/default_label string gpt
|
||||
d-i partman-partitioning/choose_label string gpt
|
||||
d-i partman-partitioning/default_label string gpt
|
||||
d-i partman/choose_label string gpt
|
||||
d-i partman/default_label string gpt
|
||||
partman-partitioning partman-partitioning/choose_label select gpt
|
||||
d-i partman-auto/disk string /dev/xvda
|
||||
d-i partman-auto/method string regular
|
||||
d-i partman-auto/expert_recipe string \
|
||||
root-swap :: \
|
||||
1000 1000 0 linux-swap \
|
||||
$primary{ } \
|
||||
method{ swap } format{ } . \
|
||||
1000 20000 -1 ext4 \
|
||||
$primary{ } \
|
||||
method{ format } format{ } \
|
||||
use_filesystem{ } filesystem{ ext4 } \
|
||||
mountpoint{ / } . \
|
||||
d-i partman-partitioning/confirm_write_new_label boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
|
||||
d-i grub-installer/only_debian boolean true
|
||||
d-i grub-installer/with_other_os boolean true
|
||||
d-i grub-installer/bootdev string /dev/xvda
|
||||
|
||||
# install tools + fix cloudconfig
|
||||
d-i preseed/late_command string \
|
||||
in-target /bin/sh -c "echo 'manage_etc_hosts: true' >> /etc/cloud/cloud.cfg"; \
|
||||
in-target wget https://gitlab.com/xen-project/xen-guest-agent/-/jobs/6041608357/artifacts/raw/target/release/xen-guest-agent_0.4.0_amd64.deb; in-target export RUNLEVEL=1; in-target dpkg -i xen-guest-agent_0.4.0_amd64.deb
|
||||
# Final Setup
|
||||
d-i finish-install/reboot_in_progress note
|
||||
66
packer/rocky9/http/inst.ks
Normal file
66
packer/rocky9/http/inst.ks
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#version=RHEL9
|
||||
# Documentation : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/performing_an_advanced_rhel_9_installation/kickstart-commands-and-options-reference_installing-rhel-as-an-experienced-user
|
||||
|
||||
# Use CDROM installation media
|
||||
cdrom
|
||||
|
||||
# Installation in text mode
|
||||
text
|
||||
|
||||
# Accept the EULA
|
||||
eula --agreed
|
||||
|
||||
# Keyboard layouts
|
||||
keyboard --vckeymap=us --xlayouts='us'
|
||||
|
||||
# System language
|
||||
lang en_US.UTF-8
|
||||
|
||||
# Network information
|
||||
network --bootproto=dhcp --noipv6 --activate
|
||||
network --hostname=localhost.localdomain
|
||||
|
||||
# add epel repo with mirrors
|
||||
repo --name="epel9-everything" --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=epel-9&arch=x86_64"
|
||||
|
||||
# Initial Setup is not started the first time the system boots
|
||||
firstboot --disabled
|
||||
|
||||
# If present, X is not configured on the installed system
|
||||
skipx
|
||||
|
||||
# Partition clearing information
|
||||
clearpart --all --initlabel
|
||||
|
||||
# Disk partitioning information
|
||||
autopart --type=lvm
|
||||
|
||||
# System timezone
|
||||
timezone Europe/Paris --utc
|
||||
|
||||
# Root password
|
||||
rootpw --plaintext --allow-ssh Packer
|
||||
|
||||
# Firewall configuration
|
||||
firewall --enabled
|
||||
|
||||
# State of SELinux
|
||||
selinux --disabled
|
||||
|
||||
# Boot loader
|
||||
bootloader --timeout=1
|
||||
|
||||
# Reboot after the installation is successfully completed
|
||||
reboot --eject
|
||||
|
||||
# Install packages
|
||||
%packages
|
||||
@^minimal-environment
|
||||
xe-guest-utilities-latest
|
||||
curl
|
||||
vim
|
||||
unzip
|
||||
wget
|
||||
git
|
||||
|
||||
%end
|
||||
95
packer/rocky9/rocky9.pkr.hcl
Normal file
95
packer/rocky9/rocky9.pkr.hcl
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
packer {
|
||||
required_plugins {
|
||||
xenserver= {
|
||||
version = "= v0.7.3"
|
||||
source = "github.com/ddelnano/xenserver"
|
||||
}
|
||||
}
|
||||
}
|
||||
variable "remote_host" {
|
||||
type = string
|
||||
description = "The ip or fqdn of your XCP-ng. It must be the master"
|
||||
sensitive = true
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
variable "remote_username" {
|
||||
type = string
|
||||
description = "The username used to interact with your XCP-ng"
|
||||
sensitive = true
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
variable "remote_password" {
|
||||
type = string
|
||||
description = "The password used to interact with your XCP-ng"
|
||||
sensitive = true
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
variable "sr_iso_name" {
|
||||
type = string
|
||||
description = "The ISO-SR to packer will use"
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
variable "sr_name" {
|
||||
type = string
|
||||
description = "The name of the SR to packer will use"
|
||||
default = "<edited>"
|
||||
}
|
||||
|
||||
|
||||
source "xenserver-iso" "rocky9" {
|
||||
iso_checksum = "e20445907daefbfcdb05ba034e9fc4cf91e0e8dc164ebd7266ffb8fdd8ea99e7"
|
||||
iso_url = "https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-9.4-x86_64-dvd.iso"
|
||||
|
||||
sr_iso_name = var.sr_iso_name
|
||||
sr_name = var.sr_name
|
||||
tools_iso_name = ""
|
||||
|
||||
remote_host = var.remote_host
|
||||
remote_password = var.remote_password
|
||||
remote_username = var.remote_username
|
||||
|
||||
http_directory = "http"
|
||||
ip_getter = "tools"
|
||||
|
||||
// Shutdown configuration
|
||||
shutdown_command = "systemctl poweroff"
|
||||
|
||||
// Boot configuration
|
||||
boot_command = ["<up><wait><tab> inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/inst.ks<enter>"]
|
||||
boot_wait = "10s"
|
||||
|
||||
# Change this to match the ISO of ubuntu you are using in the iso_url variable
|
||||
clone_template = "Rocky Linux 9"
|
||||
vm_name = "Rocky Linux 9.4 template"
|
||||
vm_description = "Rocky Linux 9.4 Packer template"
|
||||
vcpus_max = 2
|
||||
vcpus_atstartup = 2
|
||||
vm_memory = 2048 #MB
|
||||
network_names = ["prod_eth2"]
|
||||
disk_size = 20480 #MB
|
||||
disk_name = "rocky 9.4 disk"
|
||||
vm_tags = ["Generated by Packer"]
|
||||
|
||||
ssh_username = "root"
|
||||
ssh_password = "Packer"
|
||||
ssh_wait_timeout = "60000s"
|
||||
ssh_handshake_attempts = 10000
|
||||
|
||||
output_directory = "packer-rocky-9"
|
||||
keep_vm = "on_success"
|
||||
format = "xva_compressed"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["xenserver-iso.rocky9"]
|
||||
|
||||
provisioner "shell" {
|
||||
scripts = [
|
||||
"scripts/rocky9_provisioning.sh"
|
||||
]
|
||||
}
|
||||
}
|
||||
20
packer/rocky9/scripts/rocky9_provisioning.sh
Normal file
20
packer/rocky9/scripts/rocky9_provisioning.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Description : Creating a virtual machine template under Rocky Linux 9 from ISO file with Packer using VMware Workstation
|
||||
# Author : Yoann LAMY <https://github.com/ynlamy/packer-rockylinux9>
|
||||
# Licence : GPLv3
|
||||
|
||||
echo "Updating the system..."
|
||||
dnf -y -q update &> /dev/null
|
||||
|
||||
echo "Deleting the files ks.cfg..."
|
||||
rm -f /root/anaconda-ks.cfg /root/original-ks.cfg
|
||||
|
||||
echo "Cleaning dnf cache..."
|
||||
dnf -y -q clean all &> /dev/null
|
||||
|
||||
echo "Deleting temporary files..."
|
||||
rm -fr /tmp/*
|
||||
|
||||
echo "Clearing the history..."
|
||||
history -c
|
||||
Loading…
Add table
Reference in a new issue