Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vmware - work in progress #18

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions packer.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ packer {
source = "github.com/hashicorp/proxmox"
}
vmware = {
version = ">= 1.0.0"
version = ">= 1.0.7"
source = "github.com/hashicorp/vmware"
}
virtualbox = {
Expand Down Expand Up @@ -157,14 +157,18 @@ source "vmware-iso" "controller" {
http_directory = "kickstart"
iso_checksum = "${var.iso_checksum}"
iso_urls = ["${var.iso_url1}", "${var.iso_url2}"]
output_directory = "output-vmware-iso"
output_directory = "output-images"
shutdown_command = "echo 'vagrant' | sudo -S /sbin/shutdown -h 0"
ssh_password = "vagrant"
ssh_username = "root"
ssh_username = "vagrant"
ssh_wait_timeout = "10000s"
tools_upload_flavor = "linux"
vm_name = "controller"
vmdk_name = "controller"
vmx_data = {
"svga.autodetect" = true
"usb_xhci.present" = true
}
}

# https://developer.hashicorp.com/packer/plugins/builders/hyperv/iso
Expand Down Expand Up @@ -208,10 +212,15 @@ build {
sources = ["source.azure-arm.controller", "source.hyperv-iso.controller", "source.virtualbox-iso.controller", "source.vmware-iso.controller"]

provisioner "shell" {
except = ["azure-arm.controller"]
except = ["azure-arm.controller"]
execute_command = "bash '{{ .Path }}'"
script = "vagrant.sh"
}
provisioner "shell" {
except = ["azure-arm.controller"]
execute_command = "bash '{{ .Path }}'"
script = "vmtools.sh"
}
provisioner "shell" {
execute_command = "echo 'vagrant' | {{ .Vars }} sudo -S -E bash '{{ .Path }}'"
scripts = ["controller.sh"]
Expand Down
50 changes: 50 additions & 0 deletions vmtools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh -eux

# set a default HOME_DIR environment variable if not set
HOME_DIR=/root

case "$PACKER_BUILDER_TYPE" in

virtualbox-iso|virtualbox-ovf)
yum install -y bzip2 tar gcc make perl cpp libstdc++-devel kernel-devel kernel-headers

mkdir -p /tmp/vbox /run/vboxadd
chown vboxadd /run/vboxadd
chmod 700 /run/vboxadd
mount -o loop $HOME_DIR/VBoxGuestAdditions.iso /tmp/vbox;
sh /tmp/vbox/VBoxLinuxAdditions.run \
|| echo "VBoxLinuxAdditions.run exited $? and is suppressed." \
"For more read https://www.virtualbox.org/ticket/12479";
umount /tmp/vbox;
rm -rf /tmp/vbox;
rm -f $HOME_DIR/*.iso;

yum -y erase gcc make perl cpp libstdc++-devel kernel-devel kernel-headers
yum -y clean all

## https://access.redhat.com/site/solutions/58625 (subscription required)
# add 'single-request-reopen' so it is included when /etc/resolv.conf is generated
echo 'RES_OPTIONS="single-request-reopen"' >> /etc/sysconfig/network
service network restart
echo 'Slow DNS fix applied (single-request-reopen)'

;;

vmware-iso|vmware-vmx)
yum install -y perl fuse-utils
mkdir -p /tmp/vmware
mkdir -p /tmp/vmware-archive
mount -o loop $HOME_DIR/linux.iso /tmp/vmware
tar xzf /tmp/vmware/VMwareTools-*.tar.gz -C /tmp/vmware-archive
/tmp/vmware-archive/vmware-tools-distrib/vmware-install.pl --default
umount /tmp/vmware;
rm -rf /tmp/vmware;
rm -rf /tmp/vmware-archive;
rm -f $HOME_DIR/*.iso;
;;

*)
echo "No guest additions implemented for ${PACKER_BUILDER_TYPE}"
;;

esac