diff --git a/data/Linux/linux.pkr.hcl b/data/Linux/linux.pkr.hcl new file mode 100644 index 0000000..de5e16d --- /dev/null +++ b/data/Linux/linux.pkr.hcl @@ -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 = [" inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/redhat.kix"] +} + +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 = [" inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/redhat.kix"] +} + +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" + } +} \ No newline at end of file diff --git a/data/Linux/variables.pkr.hcl b/data/Linux/variables.pkr.hcl new file mode 100644 index 0000000..1db5b06 --- /dev/null +++ b/data/Linux/variables.pkr.hcl @@ -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" +} \ No newline at end of file diff --git a/data/QuickAndDirty/rockylinux.pkr.hcl b/data/QuickAndDirty/rockylinux.pkr.hcl index 4c6f212..163402a 100644 --- a/data/QuickAndDirty/rockylinux.pkr.hcl +++ b/data/QuickAndDirty/rockylinux.pkr.hcl @@ -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 diff --git a/data/build.sh b/data/build.sh new file mode 100755 index 0000000..8d4c88a --- /dev/null +++ b/data/build.sh @@ -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' \ No newline at end of file diff --git a/data/ubuntu-20.04/meta-data b/data/ubuntu/meta-data similarity index 100% rename from data/ubuntu-20.04/meta-data rename to data/ubuntu/meta-data diff --git a/data/ubuntu-20.04/user-data b/data/ubuntu/user-data similarity index 100% rename from data/ubuntu-20.04/user-data rename to data/ubuntu/user-data