diff --git a/CHANGELOG.md b/CHANGELOG.md index 84f56c267..83cd8b7b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ :boom: **Enhancement**: - Adds VMware Photon OS 5.0 to the project. [GH-582](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/582) +- Adds Debian 12 to the project. [GH-584](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/584) :sweat_drops: **Chore**: diff --git a/README.md b/README.md index 38cce4d99..fd5997f42 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ The following builds are available: - VMware Photon OS 5 - VMware Photon OS 4 +- Debian 12 - Debian 11 - Ubuntu Server 22.04 LTS (cloud-init) - Ubuntu Server 20.04 LTS (cloud-init) @@ -812,6 +813,8 @@ The project supports using a datastore to store your guest operating system [`.i - [Download][download-linux-photon-5] the latest release of the **FULL** `.iso` image. (_e.g.,_ `photon-5.0-xxxxxxxxx.x86_64.iso`) - VMware Photon OS 4 - [Download][download-linux-photon-4] the latest release of the **FULL** `.iso` image. (_e.g.,_ `photon-4.0-xxxxxxxxx.iso`) + - Debian 12 + - [Download][download-linux-debian-12] the latest **netinst** release `.iso` image. (_e.g.,_ `debian-12.x.x-amd64-netinst.iso`) - Debian 11 - [Download][download-linux-debian-11] the latest **netinst** release `.iso` image. (_e.g.,_ `debian-11.x.x-amd64-netinst.iso`) - Ubuntu Server 22.04 LTS @@ -1015,7 +1018,8 @@ Happy building!!! [download-linux-centos-7]: http://isoredirect.centos.org/centos/7/isos/x86_64/ [download-linux-centos-stream-8]: http://isoredirect.centos.org/centos/8-stream/isos/x86_64/ [download-linux-centos-stream-9]: http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/ -[download-linux-debian-11]: https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/ +[download-linux-debian-12]: https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/ +[download-linux-debian-11]: https://cdimage.debian.org/cdimage/archive/11.7.0/amd64/iso-cd/ [download-linux-photon-5]: https://packages.vmware.com/photon/5.0/GA/iso/ [download-linux-photon-4]: https://packages.vmware.com/photon/4.0/Rev2/iso/ [download-linux-rhel-7]: https://access.redhat.com/downloads/content/69/ver=/rhel---7/7.9/x86_64/product-software diff --git a/build.sh b/build.sh index 88631a94a..90a7522b1 100755 --- a/build.sh +++ b/build.sh @@ -82,6 +82,37 @@ menu_option_2() { } menu_option_3() { + INPUT_PATH="$SCRIPT_PATH"/builds/linux/debian/12/ + echo -e "\nCONFIRM: Build a Debian 12 Template for VMware vSphere?" + echo -e "\nContinue? (y/n)" + read -r REPLY + if [[ ! $REPLY =~ ^[Yy]$ ]] + then + exit 1 + fi + + ### Build a Debian 12 Template for VMware vSphere. ### + echo "Building a Debian 12 Template for VMware vSphere..." + + ### Initialize HashiCorp Packer and required plugins. ### + echo "Initializing HashiCorp Packer and required plugins..." + packer init "$INPUT_PATH" + + ### Start the Build. ### + echo "Starting the build...." + packer build -force \ + -var-file="$CONFIG_PATH/vsphere.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/build.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/ansible.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/proxy.pkrvars.hcl" \ + -var-file="$CONFIG_PATH/common.pkrvars.hcl" \ + "$INPUT_PATH" + + ### All done. ### + echo "Done." +} + +menu_option_4() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/debian/11/ echo -e "\nCONFIRM: Build a Debian 11 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -112,7 +143,7 @@ menu_option_3() { echo "Done." } -menu_option_4() { +menu_option_5() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/22-04-lts/ echo -e "\nCONFIRM: Build a Ubuntu Server 22.04 LTS (cloud-init) Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -143,7 +174,7 @@ menu_option_4() { echo "Done." } -menu_option_5() { +menu_option_6() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/ubuntu/20-04-lts/ echo -e "\nCONFIRM: Build a Ubuntu Server 20.04 LTS (cloud-init) Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -174,7 +205,7 @@ menu_option_5() { echo "Done." } -menu_option_6() { +menu_option_7() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/rhel/9/ echo -e "\nCONFIRM: Build a Red Hat Enterprise Linux 9 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -206,7 +237,7 @@ menu_option_6() { echo "Done." } -menu_option_7() { +menu_option_8() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/rhel/8/ echo -e "\nCONFIRM: Build a Red Hat Enterprise Linux 8 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -238,7 +269,7 @@ menu_option_7() { echo "Done." } -menu_option_8() { +menu_option_9() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/rhel/7/ echo -e "\nCONFIRM: Build a Red Hat Enterprise Linux 7 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -270,7 +301,7 @@ menu_option_8() { echo "Done." } -menu_option_9() { +menu_option_10() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/almalinux/9/ echo -e "\nCONFIRM: Build a AlmaLinux OS 9 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -301,7 +332,7 @@ menu_option_9() { echo "Done." } -menu_option_10() { +menu_option_11() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/almalinux/8/ echo -e "\nCONFIRM: Build a AlmaLinux OS 8 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -332,7 +363,7 @@ menu_option_10() { echo "Done." } -menu_option_11() { +menu_option_12() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/rocky/9/ echo -e "\nCONFIRM: Build a Rocky Linux 9 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -363,7 +394,7 @@ menu_option_11() { echo "Done." } -menu_option_12() { +menu_option_13() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/rocky/8/ echo -e "\nCONFIRM: Build a Rocky Linux 8 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -394,7 +425,7 @@ menu_option_12() { echo "Done." } -menu_option_13() { +menu_option_14() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos/9-stream/ echo -e "\nCONFIRM: Build a CentOS Stream 9 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -425,7 +456,7 @@ menu_option_13() { echo "Done." } -menu_option_14() { +menu_option_15() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos/8-stream/ echo -e "\nCONFIRM: Build a CentOS Stream 8 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -456,7 +487,7 @@ menu_option_14() { echo "Done." } -menu_option_15() { +menu_option_16() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/centos/7/ echo -e "\nCONFIRM: Build a CentOS Linux 7 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -487,7 +518,7 @@ menu_option_15() { echo "Done." } -menu_option_16() { +menu_option_17() { INPUT_PATH="$SCRIPT_PATH"/builds/linux/sles/15/ echo -e "\nCONFIRM: Build a SUSE Linux Enterprise Server 15 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -520,7 +551,7 @@ menu_option_16() { } -menu_option_17() { +menu_option_18() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/ echo -e "\nCONFIRM: Build all Windows Server 2022 Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -549,7 +580,7 @@ menu_option_17() { echo "Done." } -menu_option_18() { +menu_option_19() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/ echo -e "\nCONFIRM: Build Microsoft Windows Server 2022 Standard Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -579,7 +610,7 @@ menu_option_18() { echo "Done." } -menu_option_19() { +menu_option_20() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2022/ echo -e "\nCONFIRM: Build Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -609,7 +640,7 @@ menu_option_19() { echo "Done." } -menu_option_20() { +menu_option_21() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/ echo -e "\nCONFIRM: Build all Windows Server 2019 Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -638,7 +669,7 @@ menu_option_20() { echo "Done." } -menu_option_21() { +menu_option_22() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/ echo -e "\nCONFIRM: Build Microsoft Windows Server 2019 Standard Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -668,7 +699,7 @@ menu_option_21() { echo "Done." } -menu_option_22() { +menu_option_23() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/server/2019/ echo -e "\nCONFIRM: Build Microsoft Windows Server 2019 Datacenter Templates for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -698,7 +729,7 @@ menu_option_22() { echo "Done." } -menu_option_23() { +menu_option_24() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/11/ echo -e "\nCONFIRM: Build a Windows 11 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -727,7 +758,7 @@ menu_option_23() { echo "Done." } -menu_option_24() { +menu_option_25() { INPUT_PATH="$SCRIPT_PATH"/builds/windows/desktop/10/ echo -e "\nCONFIRM: Build a Windows 10 Template for VMware vSphere?" echo -e "\nContinue? (y/n)" @@ -791,31 +822,32 @@ until [ "$selection" = "0" ]; do echo "" echo " 1 - VMware Photon OS 5" echo " 2 - VMware Photon OS 4" - echo " 3 - Debian 11" - echo " 4 - Ubuntu Server 22.04 LTS (cloud-init)" - echo " 5 - Ubuntu Server 20.04 LTS (cloud-init)" - echo " 6 - Red Hat Enterprise Linux 9" - echo " 7 - Red Hat Enterprise Linux 8" - echo " 8 - Red Hat Enterprise Linux 7" - echo " 9 - AlmaLinux OS 9" - echo " 10 - AlmaLinux OS 8" - echo " 11 - Rocky Linux 9" - echo " 12 - Rocky Linux 8" - echo " 13 - CentOS Stream 9" - echo " 14 - CentOS Stream 8" - echo " 15 - CentOS Linux 7" - echo " 16 - SUSE Linux Enterprise Server 15" + echo " 3 - Debian 12" + echo " 4 - Debian 11" + echo " 5 - Ubuntu Server 22.04 LTS (cloud-init)" + echo " 6 - Ubuntu Server 20.04 LTS (cloud-init)" + echo " 7 - Red Hat Enterprise Linux 9" + echo " 8 - Red Hat Enterprise Linux 8" + echo " 9 - Red Hat Enterprise Linux 7" + echo " 10 - AlmaLinux OS 9" + echo " 11 - AlmaLinux OS 8" + echo " 12 - Rocky Linux 9" + echo " 13 - Rocky Linux 8" + echo " 14 - CentOS Stream 9" + echo " 15 - CentOS Stream 8" + echo " 16 - CentOS Linux 7" + echo " 17 - SUSE Linux Enterprise Server 15" echo "" echo " Microsoft Windows:" echo "" - echo " 17 - Windows Server 2022 - All" - echo " 18 - Windows Server 2022 - Standard Only" - echo " 19 - Windows Server 2022 - Datacenter Only" - echo " 20 - Windows Server 2019 - All" - echo " 21 - Windows Server 2019 - Standard Only" - echo " 22 - Windows Server 2019 - Datacenter Only" - echo " 23 - Windows 11" - echo " 24 - Windows 10" + echo " 18 - Windows Server 2022 - All" + echo " 19 - Windows Server 2022 - Standard Only" + echo " 20 - Windows Server 2022 - Datacenter Only" + echo " 21 - Windows Server 2019 - All" + echo " 22 - Windows Server 2019 - Standard Only" + echo " 23 - Windows Server 2019 - Datacenter Only" + echo " 24 - Windows 11" + echo " 25 - Windows 10" echo "" echo " Other:" echo "" @@ -849,6 +881,7 @@ until [ "$selection" = "0" ]; do 22 ) clear ; menu_option_22 ; press_enter ;; 23 ) clear ; menu_option_23 ; press_enter ;; 24 ) clear ; menu_option_24 ; press_enter ;; + 25 ) clear ; menu_option_25 ; press_enter ;; I ) clear ; info ; press_enter ;; Q ) clear ; exit ;; * ) clear ; incorrect_selection ; press_enter ;; diff --git a/build.yaml b/build.yaml index 39030f8d5..6e2342e0e 100644 --- a/build.yaml +++ b/build.yaml @@ -15,6 +15,9 @@ menu: - entry: "VMware Photon OS 4" build: path: "builds/linux/photon/4/" + - entry: "Debian 12" + build: + path: "builds/linux/debian/12/" - entry: "Debian 11" build: path: "builds/linux/debian/11/" diff --git a/builds/linux/debian/11/data/ks.pkrtpl.hcl b/builds/linux/debian/11/data/ks.pkrtpl.hcl index 61be1da75..35e1bbf64 100644 --- a/builds/linux/debian/11/data/ks.pkrtpl.hcl +++ b/builds/linux/debian/11/data/ks.pkrtpl.hcl @@ -3,7 +3,8 @@ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# Debian 11 +# Debian 11 (Bullseye) Preseed File +# https://www.debian.org/releases/bullseye/amd64/ # Locale and Keyboard d-i debian-installer/locale string ${vm_guest_os_language} @@ -158,7 +159,7 @@ d-i netcfg/get_domain string unassigned-domain # Mirror settings d-i mirror/country string manual -d-i mirror/http/hostname string ftp.it.debian.org +d-i mirror/http/hostname string cdn-fastly.deb.debian.org d-i mirror/http/directory string /debian d-i mirror/http/proxy string diff --git a/builds/linux/debian/11/linux-debian.auto.pkrvars.hcl b/builds/linux/debian/11/linux-debian.auto.pkrvars.hcl index 9638a5e16..8b34b41e3 100644 --- a/builds/linux/debian/11/linux-debian.auto.pkrvars.hcl +++ b/builds/linux/debian/11/linux-debian.auto.pkrvars.hcl @@ -1,6 +1,6 @@ /* DESCRIPTION: - Debian 11 variables used by the Packer Plugin for VMware vSphere (vsphere-iso). + Debian 11 (Bullseye) build variables. */ // Guest Operating System Metadata diff --git a/builds/linux/debian/11/linux-debian.pkr.hcl b/builds/linux/debian/11/linux-debian.pkr.hcl index cf4209740..ace1cad26 100644 --- a/builds/linux/debian/11/linux-debian.pkr.hcl +++ b/builds/linux/debian/11/linux-debian.pkr.hcl @@ -1,6 +1,7 @@ /* DESCRIPTION: - Debian Linux 11 template using the Packer Builder for VMware vSphere (vsphere-iso). + Debian 11 (Bullseye) build definition. + Packer Plugin for VMware vSphere (`vsphere-iso` builder). */ // BLOCK: packer diff --git a/builds/linux/debian/11/variables.pkr.hcl b/builds/linux/debian/11/variables.pkr.hcl index 67153dca5..dd2551cc1 100644 --- a/builds/linux/debian/11/variables.pkr.hcl +++ b/builds/linux/debian/11/variables.pkr.hcl @@ -1,6 +1,7 @@ /* DESCRIPTION: - Debian 11 variables using the Packer Builder for VMware vSphere (vsphere-iso). + Debian 11 (Bullseye) input variables. + Packer Plugin for VMware vSphere (`vsphere-iso` builder). */ // BLOCK: variable diff --git a/builds/linux/debian/12/data/ks.pkrtpl.hcl b/builds/linux/debian/12/data/ks.pkrtpl.hcl new file mode 100644 index 000000000..a8652e39a --- /dev/null +++ b/builds/linux/debian/12/data/ks.pkrtpl.hcl @@ -0,0 +1,185 @@ +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# Debian 12 (Bookworm) Preseed File +# https://www.debian.org/releases/bookworm/amd64/ + +# Locale and Keyboard +d-i debian-installer/locale string ${vm_guest_os_language} +d-i keyboard-configuration/xkb-keymap select ${vm_guest_os_keyboard} + +# Clock and Timezone +d-i clock-setup/utc boolean true +d-i clock-setup/ntp boolean true +d-i time/zone string ${vm_guest_os_timezone} + +# Grub and Reboot Message +d-i finish-install/reboot_in_progress note +d-i grub-installer/only_debian boolean true + +# Partitioning +d-i partman-auto/method string lvm +d-i partman-lvm/confirm boolean true +d-i partman-lvm/confirm_nooverwrite boolean true +d-i partman-lvm/device_remove_lvm boolean true +d-i partman-auto-lvm/new_vg_name string sysvg +d-i partman-efi/non_efi_system boolean true + +d-i partman-auto/expert_recipe string \ + custom :: \ + 1024 1024 1024 fat32 \ + $primary{ } \ + mountpoint{ /boot/efi } \ + method{ efi } \ + format{ } \ + use_filesystem{ } \ + filesystem{ vfat } \ + label { EFIFS } \ + . \ + 1024 1024 1024 xfs \ + $bootable{ } \ + $primary{ } \ + mountpoint{ /boot } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ xfs } \ + label { BOOTFS } \ + . \ + 1024 1024 1024 linux-swap \ + $lvmok{ } \ + lv_name{ lv_swap } \ + in_vg { sysvg } \ + method{ swap } \ + format{ } \ + label { SWAPFS } \ + . \ + 12288 12288 -1 xfs \ + $lvmok{ } \ + mountpoint{ / } \ + lv_name{ lv_root } \ + in_vg { sysvg } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ xfs } \ + label { ROOTFS } \ + . \ + 4096 4096 4096 xfs \ + $lvmok{ } \ + mountpoint{ /home } \ + lv_name{ lv_home } \ + in_vg { sysvg } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ xfs } \ + label { HOMEFS } \ + options/nodev{ nodev } \ + options/nosuid{ nosuid } \ + . \ + 2048 2048 2048 xfs \ + $lvmok{ } \ + mountpoint{ /opt } \ + lv_name{ lv_opt } \ + in_vg { sysvg } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ xfs } \ + label { OPTFS } \ + options/nodev{ nodev } \ + . \ + 3072 3072 3072 xfs \ + $lvmok{ } \ + mountpoint{ /tmp } \ + lv_name{ lv_tmp } \ + in_vg { sysvg } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ xfs } \ + label { TMPFS } \ + options/nodev{ nodev } \ + options/noexec{ noexec } \ + options/nosuid{ nosuid } \ + . \ + 4096 4096 4096 xfs \ + $lvmok{ } \ + mountpoint{ /var } \ + lv_name{ lv_var } \ + in_vg { sysvg } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ xfs } \ + label { VARFS } \ + options/nodev{ nodev } \ + . \ + 4096 4096 4096 xfs \ + $lvmok{ } \ + mountpoint{ /var/log } \ + lv_name{ lv_log } \ + in_vg { sysvg } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ xfs } \ + label { LOGFS } \ + options/nodev{ nodev } \ + options/noexec{ noexec } \ + options/nosuid{ nosuid } \ + . \ + 4096 4096 4096 xfs \ + $lvmok{ } \ + mountpoint{ /var/log/audit } \ + lv_name{ lv_audit } \ + in_vg { sysvg } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ xfs } \ + label { AUDITFS } \ + options/nodev{ nodev } \ + options/noexec{ noexec } \ + options/nosuid{ nosuid } \ + . \ + +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 + +# Network configuration +d-i netcfg/choose_interface select auto +d-i netcfg/get_hostname string unassigned-hostname +d-i netcfg/get_domain string unassigned-domain + +# Mirror settings +d-i mirror/country string manual +d-i mirror/http/hostname string cdn-fastly.deb.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string + +# User Configuration +d-i passwd/root-login boolean false +d-i passwd/user-fullname string ${build_username} +d-i passwd/username string ${build_username} +d-i passwd/user-password-crypted password ${build_password_encrypted} + +# Package Configuration +d-i pkgsel/run_tasksel boolean false +d-i pkgsel/include string openssh-server open-vm-tools python3-apt perl + +# Add User to Sudoers +d-i preseed/late_command string \ + echo '${build_username} ALL=(ALL) NOPASSWD: ALL' > /target/etc/sudoers.d/${build_username} ; \ + in-target chmod 440 /etc/sudoers.d/${build_username} ; + +%{ if common_data_source == "disk" ~} +# Umount preseed media early +d-i preseed/early_command string \ + umount /media && echo 1 > /sys/block/sr1/device/delete ; +%{ endif ~} diff --git a/builds/linux/debian/12/linux-debian.auto.pkrvars.hcl b/builds/linux/debian/12/linux-debian.auto.pkrvars.hcl new file mode 100644 index 000000000..698958d78 --- /dev/null +++ b/builds/linux/debian/12/linux-debian.auto.pkrvars.hcl @@ -0,0 +1,42 @@ +/* + DESCRIPTION: + Debian 12 (Bookworm) build variables. +*/ + +// Guest Operating System Metadata +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_name = "debian" +vm_guest_os_version = "12.0" + +// Virtual Machine Guest Operating System Setting +vm_guest_os_type = "other5xLinux64Guest" + +// Virtual Machine Hardware Settings +vm_firmware = "efi-secure" +vm_cdrom_type = "sata" +vm_cpu_count = 2 +vm_cpu_cores = 1 +vm_cpu_hot_add = false +vm_mem_size = 2048 +vm_mem_hot_add = false +vm_disk_size = 40960 +vm_disk_controller_type = ["pvscsi"] +vm_disk_thin_provisioned = true +vm_network_card = "vmxnet3" + +// Removable Media Settings +iso_path = "iso/linux/debian" +iso_file = "debian-12.0.0-amd64-netinst.iso" +iso_checksum_type = "sha512" +iso_checksum_value = "b462643a7a1b51222cd4a569dad6051f897e815d10aa7e42b68adc8d340932d861744b5ea14794daa5cc0ccfa48c51d248eda63f150f8845e8055d0a5d7e58e6" + +// Boot Settings +vm_boot_order = "disk,cdrom" +vm_boot_wait = "5s" + +// Communicator Settings +communicator_port = 22 +communicator_timeout = "30m" diff --git a/builds/linux/debian/12/linux-debian.pkr.hcl b/builds/linux/debian/12/linux-debian.pkr.hcl new file mode 100644 index 000000000..9fea2865e --- /dev/null +++ b/builds/linux/debian/12/linux-debian.pkr.hcl @@ -0,0 +1,237 @@ +/* + DESCRIPTION: + Debian 12 (Bookworm) build definition. + Packer Plugin for VMware vSphere (`vsphere-iso` builder). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.9.1" + required_plugins { + git = { + version = ">= 0.4.2" + source = "github.com/ethanmdavidson/git" + } + vsphere = { + version = ">= v1.2.0" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: data +// Defines the data sources. + +data "git-repository" "cwd" {} + +// BLOCK: locals +// Defines the local variables. + +locals { + build_by = "Built by: HashiCorp Packer ${packer.version}" + build_date = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) + build_version = data.git-repository.cwd.head + build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) + manifest_path = "${path.cwd}/manifests/" + manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" + data_source_content = { + "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { + build_username = var.build_username + build_password_encrypted = var.build_password_encrypted + vm_guest_os_language = var.vm_guest_os_language + vm_guest_os_keyboard = var.vm_guest_os_keyboard + vm_guest_os_timezone = var.vm_guest_os_timezone + common_data_source = var.common_data_source + }) + } + data_source_command = var.common_data_source == "http" ? "url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" : "file=/media/ks.cfg" + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${local.build_version}" + bucket_name = replace("${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}", ".", "") + bucket_description = "${var.vm_guest_os_family} ${var.vm_guest_os_name} ${var.vm_guest_os_version}" +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-debian" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + vm_name = local.vm_name + guest_os_type = var.vm_guest_os_type + firmware = var.vm_firmware + CPUs = var.vm_cpu_count + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = local.build_description + + // Removable Media Settings + iso_paths = local.iso_paths + iso_checksum = local.iso_checksum + http_content = var.common_data_source == "http" ? local.data_source_content : null + cd_content = var.common_data_source == "disk" ? local.data_source_content : null + + // Boot and Provisioning Settings + http_ip = var.common_data_source == "http" ? var.common_http_ip : null + http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null + http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [ + "c", + "linux /install.amd/vmlinuz", + " auto-install/enable=true", + " debconf/priority=critical", + " ${local.data_source_command}", + " noprompt --", + "initrd /install.amd/initrd.gz", + "boot", + "", + "", + "", + "", + "", + "mount /dev/sr1 /media", + "", + "" + ] + ip_wait_timeout = var.common_ip_wait_timeout + shutdown_command = "echo '${var.build_password}' | sudo -S -E shutdown -P now" + shutdown_timeout = var.common_shutdown_timeout + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_proxy_host = var.communicator_proxy_host + ssh_proxy_port = var.communicator_proxy_port + ssh_proxy_username = var.communicator_proxy_username + ssh_proxy_password = var.communicator_proxy_password + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + description = local.build_description + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + skip_import = var.common_content_library_skip_export + } + } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-debian"] + + provisioner "ansible" { + playbook_file = "${path.cwd}/ansible/main.yml" + roles_path = "${path.cwd}/ansible/roles" + ansible_env_vars = [ + "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg", + "ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3" + ] + extra_arguments = [ + "--extra-vars", "display_skipped_hosts=false", + "--extra-vars", "BUILD_USERNAME=${var.build_username}", + "--extra-vars", "BUILD_SECRET='${var.build_key}'", + "--extra-vars", "ANSIBLE_USERNAME=${var.ansible_username}", + "--extra-vars", "ANSIBLE_SECRET='${var.ansible_key}'", + ] + } + + post-processor "manifest" { + output = local.manifest_output + strip_path = true + strip_time = true + custom_data = { + ansible_username = var.ansible_username + build_username = var.build_username + build_date = local.build_date + build_version = local.build_version + common_data_source = var.common_data_source + common_vm_version = var.common_vm_version + vm_cpu_cores = var.vm_cpu_cores + vm_cpu_count = var.vm_cpu_count + vm_disk_size = var.vm_disk_size + vm_disk_thin_provisioned = var.vm_disk_thin_provisioned + vm_firmware = var.vm_firmware + vm_guest_os_type = var.vm_guest_os_type + vm_mem_size = var.vm_mem_size + vm_network_card = var.vm_network_card + vsphere_cluster = var.vsphere_cluster + vsphere_datacenter = var.vsphere_datacenter + vsphere_datastore = var.vsphere_datastore + vsphere_endpoint = var.vsphere_endpoint + vsphere_folder = var.vsphere_folder + } + } + + dynamic "hcp_packer_registry" { + for_each = var.common_hcp_packer_registry_enabled ? [1] : [] + content { + bucket_name = local.bucket_name + description = local.bucket_description + bucket_labels = { + "os_family" : var.vm_guest_os_family, + "os_name" : var.vm_guest_os_name, + "os_version" : var.vm_guest_os_version, + } + build_labels = { + "build_version" : local.build_version, + "packer_version" : packer.version, + } + } + } +} diff --git a/builds/linux/debian/12/variables.pkr.hcl b/builds/linux/debian/12/variables.pkr.hcl new file mode 100644 index 000000000..03c0cf916 --- /dev/null +++ b/builds/linux/debian/12/variables.pkr.hcl @@ -0,0 +1,378 @@ +/* + DESCRIPTION: + Debian 12 (Bookworm) input variables. + Packer Plugin for VMware vSphere (`vsphere-iso` builder). +*/ + +// BLOCK: variable +// Defines the input variables. + +// vSphere Credentials + +variable "vsphere_endpoint" { + type = string + description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" +} + +variable "vsphere_username" { + type = string + description = "The username to login to the vCenter Server instance. (e.g. 'svc-packer-vsphere@rainpole.io')" + sensitive = true +} + +variable "vsphere_password" { + type = string + description = "The password for the login to the vCenter Server instance." + sensitive = true +} + +variable "vsphere_insecure_connection" { + type = bool + description = "Do not validate vCenter Server TLS certificate." +} + +// vSphere Settings + +variable "vsphere_datacenter" { + type = string + description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" +} + +variable "vsphere_cluster" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" +} + +variable "vsphere_datastore" { + type = string + description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" +} + +variable "vsphere_network" { + type = string + description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" +} + +variable "vsphere_folder" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" +} + +// Virtual Machine Settings + +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en_US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "us" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + +variable "vm_guest_os_family" { + type = string + description = "The guest operating system family. Used for naming. (e.g. 'linux')" +} + +variable "vm_guest_os_name" { + type = string + description = "The guest operating system name. Used for naming . (e.g. 'debian')" +} + +variable "vm_guest_os_version" { + type = string + description = "The guest operating system version. Used for naming. (e.g. '12')" +} + +variable "vm_guest_os_type" { + type = string + description = "The guest operating system type, also know as guestid. (e.g. 'debian12_64Guest')" +} + +variable "vm_firmware" { + type = string + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" + default = "efi-secure" +} + +variable "vm_cdrom_type" { + type = string + description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" + default = "sata" +} + +variable "vm_cpu_count" { + type = number + description = "The number of virtual CPUs. (e.g. '2')" +} + +variable "vm_cpu_cores" { + type = number + description = "The number of virtual CPUs cores per socket. (e.g. '1')" +} + +variable "vm_cpu_hot_add" { + type = bool + description = "Enable hot add CPU." + default = false +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB. (e.g. '2048')" +} + +variable "vm_mem_hot_add" { + type = bool + description = "Enable hot add memory." + default = false +} + +variable "vm_disk_size" { + type = number + description = "The size for the virtual disk in MB. (e.g. '40960')" +} + +variable "vm_disk_controller_type" { + type = list(string) + description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" + default = ["pvscsi"] +} + +variable "vm_disk_thin_provisioned" { + type = bool + description = "Thin provision the virtual disk." + default = true +} + +variable "vm_network_card" { + type = string + description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" + default = "vmxnet3" +} + +variable "common_vm_version" { + type = number + description = "The vSphere virtual hardware version. (e.g. '19')" +} + +variable "common_tools_upgrade_policy" { + type = bool + description = "Upgrade VMware Tools on reboot." + default = true +} + +variable "common_remove_cdrom" { + type = bool + description = "Remove the virtual CD-ROM(s)." + default = true +} + +// Template and Content Library Settings + +variable "common_template_conversion" { + type = bool + description = "Convert the virtual machine to template. Must be 'false' for content library." + default = false +} + +variable "common_content_library_name" { + type = string + description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null +} + +variable "common_content_library_ovf" { + type = bool + description = "Export to content library as an OVF template." + default = true +} + +variable "common_content_library_destroy" { + type = bool + description = "Delete the virtual machine after exporting to the content library." + default = true +} + +variable "common_content_library_skip_export" { + type = bool + description = "Skip exporting the virtual machine to the content library. Option allows for testing / debugging without saving the machine image." + default = false +} + +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + +// Removable Media Settings + +variable "common_iso_datastore" { + type = string + description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" +} + +variable "iso_path" { + type = string + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/debian')" +} + +variable "iso_file" { + type = string + description = "The file name of the ISO image used by the vendor. (e.g. 'debian--amd64-netinst.iso')" +} + +variable "iso_checksum_type" { + type = string + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" +} + +variable "iso_checksum_value" { + type = string + description = "The checksum value provided by the vendor." +} + +// Boot Settings + +variable "common_data_source" { + type = string + description = "The provisioning data source. (e.g. 'http' or 'disk')" +} + +variable "common_http_ip" { + type = string + description = "Define an IP address on the host to use for the HTTP server." + default = null +} + +variable "common_http_port_min" { + type = number + description = "The start of the HTTP port range." +} + +variable "common_http_port_max" { + type = number + description = "The end of the HTTP port range." +} + +variable "vm_boot_order" { + type = string + description = "The boot order for virtual machines devices. (e.g. 'disk,cdrom')" + default = "disk,cdrom" +} + +variable "vm_boot_wait" { + type = string + description = "The time to wait before boot." +} + +variable "common_ip_wait_timeout" { + type = string + description = "Time to wait for guest operating system IP address response." +} + +variable "common_shutdown_timeout" { + type = string + description = "Time to wait for guest operating system shutdown." +} + +// Communicator Settings and Credentials + +variable "build_username" { + type = string + description = "The username to login to the guest operating system. (e.g. 'rainpole')" + sensitive = true +} + +variable "build_password" { + type = string + description = "The password to login to the guest operating system." + sensitive = true +} + +variable "build_password_encrypted" { + type = string + description = "The encrypted password to login the guest operating system." + sensitive = true +} + +variable "build_key" { + type = string + description = "The public key to login to the guest operating system." + sensitive = true +} + +variable "communicator_proxy_host" { + type = string + description = "A SOCKS proxy host to use for SSH connection." + default = null +} + +variable "communicator_proxy_port" { + type = number + description = "A port of the SOCKS proxy." + default = null +} + +variable "communicator_proxy_username" { + type = string + description = "The optional username to authenticate with the proxy server." + default = null +} + +variable "communicator_proxy_password" { + type = string + description = "The optional password to use to authenticate with the proxy server." + sensitive = true + default = null +} + +variable "communicator_port" { + type = string + description = "The port for the communicator protocol." +} + +variable "communicator_timeout" { + type = string + description = "The timeout for the communicator protocol." +} + +// Ansible Credentials + +variable "ansible_username" { + type = string + description = "The username for Ansible to login to the guest operating system. (e.g. 'ansible')" + sensitive = true +} + +variable "ansible_key" { + type = string + description = "The public key for Ansible to login to the guest operating system." + sensitive = true +} + +// HCP Packer Settings + +variable "common_hcp_packer_registry_enabled" { + type = bool + description = "Enable the HCP Packer registry." + default = false +}