moving forward

This commit is contained in:
2024-10-20 20:38:22 +02:00
parent 9009a3b57b
commit ac7413ca25
6 changed files with 222 additions and 10 deletions

100
data/Linux/linux.pkr.hcl Normal file
View File

@@ -0,0 +1,100 @@
source "proxmox" "ubuntu" {
template_name = "ubuntu"
template_description = "Ubuntu Linux Server template"
proxmox_url = "https://192.168.111.36:8006/api2/json"
node = "n100noeud"
iso_file = var.ISODISK
iso_checksum = var.ISOHASH
insecure_skip_tls_verify = true
pool = "Linux-VM"
vm_name = "PackerTest"
vm_id = 664
memory = 2048
cores = 1
sockets = 2
os = "l26"
http_port_min = 4990
http_port_max = 4999
http_directory = "redhat"
username = "root@pam"
password = "galeregalere"
ssh_username = "root"
ssh_password = "M0ukreneIsVeryGood!"
ssh_timeout = "15m"
network_adapters {
model = "virtio"
bridge = "vmbr111"
}
qemu_agent = true
scsi_controller = "virtio-scsi-pci"
disks {
type = "scsi"
disk_size = "55G"
storage_pool = "FAST"
storage_pool_type = "lvm-thin"
format = "raw"
}
boot_wait = "5s"
boot_command = ["<wait2><up><wait1><tab><wait1> inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/redhat.kix<wait1s><enter>"]
}
source "proxmox" "centos" {
template_name = "centos"
template_description = "Rocky Linux Server template"
proxmox_url = "https://192.168.111.36:8006/api2/json"
node = "n100noeud"
iso_file = var.ISODISK
iso_checksum = "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
insecure_skip_tls_verify = true
pool = "Linux-VM"
vm_name = "PackerTest"
vm_id = 664
memory = 2048
cores = 1
sockets = 2
os = "l26"
http_port_min = 4990
http_port_max = 4999
http_directory = "redhat"
username = "root@pam"
password = "galeregalere"
ssh_username = "root"
ssh_password = "M0ukreneIsVeryGood!"
ssh_timeout = "15m"
network_adapters {
model = "virtio"
bridge = "vmbr111"
}
qemu_agent = true
scsi_controller = "virtio-scsi-pci"
disks {
type = "scsi"
disk_size = "55G"
storage_pool = "FAST"
storage_pool_type = "lvm-thin"
format = "raw"
}
boot_wait = "5s"
boot_command = ["<wait2><up><wait1><tab><wait1> inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/redhat.kix<wait1s><enter>"]
}
build {
sources = [ "source.proxmox.centos" ]
provisioner "ansible" {
pause_before = "20s"
ansible_env_vars= [
"ANSIBLE_HOST_KEY_CHECKING=False",
"ANSIBLE_SSH_ARGS='-o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s'",
"ANSIBLE_NOCOLOR=True"
]
extra_arguments= [
"-e templating=true"
]
playbook_file = "../../../Ansible/playbooks/MyLinuxServers.yaml"
}
}

View File

@@ -0,0 +1,60 @@
packer {
required_version = ">= 1.7.4"
required_plugins {
windows-update = {
version = "0.14.0"
source = "github.com/rgl/windows-update"
}
amazon = {
source = "github.com/hashicorp/amazon"
version = "~> 1"
}
ansible = {
source = "github.com/hashicorp/ansible"
version = "~> 1"
}
vsphere = {
source = "github.com/hashicorp/vsphere"
version = "~> 1"
}
}
}
# Variables definition
variable "SCSI_Controller" {
type = string
default = "pvscsi"
}
variable "packer_svr_addr" {
type = string
default = "127.0.0.1"
}
variable "VMNAME" {
type = string
default = "BMaster-Template"
}
variable "ISODISK" {
type = string
default = ""
}
variable "BOOT_COMMAND" {
type = string
default = "lets boot"
}
variable "kickstart_path" {
type = string
default = "resp_file/centos"
}
variable "kickstart_file" {
type = string
default = "redhat.kix"
}

View File

@@ -1,18 +1,8 @@
packer {
}
variable "ISODISK" {
type = string
default = "ISOS:iso/Rocky-8.5-x86_64-dvd1.iso"
}
source "proxmox" "rocky" {
template_name = "rocky"
template_description = "Rocky Linux Server template"
proxmox_url = "https://192.168.111.34:8006/api2/json"
node = "grosnoeud"
#iso_file = "ISOS:iso/Rocky-8.5-x86_64-minimal.iso"
#iso_file = "ISOS:iso/Rocky-8.5-x86_64-dvd1.iso"
iso_file = var.ISODISK
iso_checksum = "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
insecure_skip_tls_verify = true

62
data/build.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
THE_VER=$(date +'%y%m%d')
date '+%d/%m/%Y %H:%M:%S'
ICPREFIX="ICVM"
PACKER_LOG=1
SCRIPTDIR=$(dirname $0)
#DFT_PARAM="-force -color=false -on-error=ask -var-file ${SCRIPTDIR}/config/irisvars.json"
DFT_PARAM="-force -color=false -var-file ${SCRIPTDIR}/config/irisvars.json"
OSString=$1
case $1 in
ROCKY9)
OSSTRING="ROCKY9"
THEPREFIX="linux"
TheBuilder="proxmox.centos"
VMNAME=${THEPREFIX}-${OSSTRING}-${THE_VER}
BuildSettings="${DFT_PARAM} -only=${TheBuilder} \
-var VMNAME=${VMNAME} \
-var-file=${OSSTRING}.pkrvars.hcl \
${SCRIPTDIR}/Linux"
;;
UBUNTU2004)
OSSTRING="Ubuntu2004"
THEPREFIX="linux"
TheBuilder="proxmox.ubuntu"
VMNAME=${THEPREFIX}-${OSSTRING}-${THE_VER}
BuildSettings="${DFT_PARAM} -only=${TheBuilder} \
-var VMNAME=${VMNAME} \
-var-file=${OSSTRING}.pkrvars.hcl \
${SCRIPTDIR}/Linux"
;;
UBUNTU2404)
OSSTRING="Ubuntu2404"
THEPREFIX="linux"
TheBuilder="proxmox.ubuntu"
VMNAME=${THEPREFIX}-${OSSTRING}-${THE_VER}
BuildSettings="${DFT_PARAM} -only=${TheBuilder} \
-var VMNAME=${VMNAME} \
-var-file=${OSSTRING}.pkrvars.hcl \
${SCRIPTDIR}/Linux"
;;
*)
echo "argument must be 'UBUNTU2004' or 'UBUNTU2404' or 'ROCKY' installation"
exit 555
;;
esac
echo lets build $1
#echo "SCRIPT PATH:${SCRIPTDIR}"
#echo "DFT_PARAM: ${DFT_PARAM}"
#echo "BuildSettings: ${BuildSettings}"
#echo "packer build ${BuildSettings}"
#echo "ISODISK ${ISODISK}"
. $HOME/packer.sh
time packer build ${BuildSettings} | tee $1.log
#packer build ${BuildSettings} | tee $1.log
echo "exit code:$?"
if [ -f ./winver/autounattend.xml ]; then
rm -fv ./winver/autounattend.xml
fi
date '+%d/%m/%Y %H:%M:%S'