Skip to content

Commit

Permalink
fixed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Stromweld committed Feb 16, 2024
1 parent bf825b7 commit 49a9826
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 350 deletions.
1 change: 1 addition & 0 deletions lib/bento/test_templates/bootstrap.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "Shell Provisioner Says What"
21 changes: 21 additions & 0 deletions os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
os_name = "amazonlinux"
os_version = "2"
os_arch = "x86_64"
vbox_guest_os_type = "RedHat_64"
sources_enabled = [
"source.virtualbox-ovf.amazonlinux"
]
vboxmanage = [
[
"modifyvm",
"{{ .Name }}",
"--memory",
"2048",
"--cpus",
"2",
"--audio",
"none",
"--nat-localhostreachable1",
"on",
]
]
9 changes: 9 additions & 0 deletions os_pkrvars/centos/centos-7-x86_64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
os_name = "centos"
os_version = "7.9"
os_arch = "x86_64"
iso_url = "http://mirrors.kernel.org/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso"
iso_checksum = "file:https://mirrors.edge.kernel.org/centos/7.9.2009/isos/x86_64/sha256sum.txt"
parallels_guest_os_type = "centos"
vbox_guest_os_type = "RedHat_64"
vmware_guest_os_type = "centos-64"
boot_command = ["<wait><up><wait><tab> inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/rhel/7ks.cfg<enter><wait>"]
9 changes: 9 additions & 0 deletions os_pkrvars/centos/centos-stream-9-x86_64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
os_name = "centos-stream"
os_version = "9"
os_arch = "x86_64"
iso_url = "https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso"
iso_checksum = "file:https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso.SHA256SUM"
parallels_guest_os_type = "centos"
vbox_guest_os_type = "RedHat_64"
vmware_guest_os_type = "centos-64"
boot_command = ["<wait><up><wait><tab> inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/rhel/9ks.cfg<enter><wait>"]
2 changes: 0 additions & 2 deletions os_pkrvars/windows/windows-10-x86_64.pkrvars.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ iso_checksum = "ef7312733a9f5d7d51cfa04ac497671995674ca5e1058d5164d60
parallels_guest_os_type = "win-10"
vbox_guest_os_type = "Windows10_64"
vmware_guest_os_type = "windows9srv-64"

# https://software.download.prss.microsoft.com/dbazure/Win10_22H2_English_x64v1.iso?t=f1cf9077-9373-441c-b238-907e3fac3231&P1=1707583719&P2=601&P3=2&P4=l0y%2fNUso0z871ymK7QtD6%2f6vN1zBGJRzfpJCISynZTcakhL1tbE1cIPv20cz70wyfmUqhcBMnTDy0OVZiCD%2fFztKsl8hKlCbsPmxVjzdKth7nwntwy3IQFYmyFhoOp%2bPZFW01u%2fPO%2b8%2fLByLxdebsEjF5wt%2bdLN0bi46TVSDn3FXoiNTNDUt4gkW5ihlExBPDRXMV8jTLR5Kf1gp9Owet1zunRiPVxZN3cB5Y9J3RcqyIvR6SGTi2n75DxXerJQXtRYkToJXsvpNpL%2bOunhbZgudHqM1FgamFSrD4rNSPfhxS0AYIxCbHVCrhf6EZRVyQMY8GYAUpwydhk2zZFFoIQ%3d%3d
13 changes: 4 additions & 9 deletions packer_templates/pkr-sources.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ locals {
var.is_windows ? [
["set", "{{ .Name }}", "--efi-boot", "off"],
["set", "{{ .Name }}", "--efi-secure-boot", "off"],
# ["set", "{{ .Name }}", "--3d-accelerate", "off"],
# ["set", "{{ .Name }}", "--videosize", "16"],
["set", "{{ .Name }}", "--device-add", "cdrom", "--image", "${path.root}/../unattended.iso", "--connect"],
] : [
# ["set", "{{ .Name }}", "--3d-accelerate", "off"],
# ["set", "{{ .Name }}", "--videosize", "16"]
]
["set", "{{ .Name }}", "--device-add", "cdrom", "--image", "${path.root}/../builds/iso/unattended.iso", "--connect"],
] : null
) : var.parallels_prlctl

# qemu
Expand All @@ -39,7 +34,7 @@ locals {
) : var.qemu_machine_type
qemuargs = var.qemuargs == null ? (
var.is_windows ? [
["-drive", "file=${path.root}/win_answer_files/virtio-win.iso,media=cdrom,index=3"],
["-drive", "file=${path.root}/../builds/iso/virtio-win.iso,media=cdrom,index=3"],
["-drive", "file=${path.root}/../builds/packer-${var.os_name}-${var.os_version}-${var.os_arch}-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1"],
] : (
var.os_arch == "aarch64" ? [
Expand Down Expand Up @@ -211,7 +206,7 @@ source "qemu" "vm" {
}
source "virtualbox-iso" "vm" {
# Virtualbox specific options
firmware = "efi"
#firmware = "efi"
gfx_controller = local.vbox_gfx_controller
gfx_vram_size = local.vbox_gfx_vram_size
guest_additions_path = var.vbox_guest_additions_path
Expand Down
2 changes: 1 addition & 1 deletion packer_templates/pkr-variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ variable "vmware_version" {
variable "vmware_vmx_data" {
type = map(string)
default = {
"firmware" = "efi"
# "firmware" = "efi"
"cpuid.coresPerSocket" = "2"
"ethernet0.pciSlotNumber" = "32"
"svga.autodetect" = true
Expand Down
47 changes: 47 additions & 0 deletions packer_templates/scripts/_common/parallels-rhel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh -eux

# set a default HOME_DIR environment variable if not set
HOME_DIR="${HOME_DIR:-/home/vagrant}";

case "$PACKER_BUILDER_TYPE" in
parallels-iso|parallels-pvm)
major_version="$(sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/redhat-release | awk -F. '{print $1}')"
# make sure we use dnf on EL 8+
if [ "$major_version" -ge 8 ]; then
dnf -y install checkpolicy selinux-policy-devel gcc kernel-devel kernel-headers make
else
yum -y install checkpolicy selinux-policy-devel gcc kernel-devel kernel-headers make
fi

mkdir -p /tmp/parallels;
if [ "$(uname -m)" = "aarch64" ] ; then
mount -o loop "$HOME_DIR"/prl-tools-lin-arm.iso /tmp/parallels;
else
mount -o loop "$HOME_DIR"/prl-tools-lin.iso /tmp/parallels;
fi
VER="$(cat /tmp/parallels/version)";

echo "Parallels Tools Version: $VER";

/tmp/parallels/install --install-unattended-with-deps \
|| (code="$?"; \
echo "Parallels tools installation exited $code, attempting" \
"to output /var/log/parallels-tools-install.log"; \
cat /var/log/parallels-tools-install.log; \
exit $code);
umount /tmp/parallels;
rm -rf /tmp/parallels;
rm -f "$HOME_DIR"/*.iso;

# Parallels Tools for Linux includes native auto-mount script,
# which causes losing some of Vagrant-relative shared folders.
# So, we should disable this behavior.
# https://github.com/Parallels/vagrant-parallels/issues/325#issuecomment-418727113
# TODO: verify this is fixed in latest version of parallels
# auto_mount_script='/usr/bin/prlfsmountd'
# if [ -f "${auto_mount_script}" ]; then
# printf '#!/bin/sh\n # Shared folders auto-mount is disabled by Vagrant' > "${auto_mount_script}"
# fi

;;
esac
39 changes: 39 additions & 0 deletions packer_templates/scripts/_common/parallels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh -eux

# set a default HOME_DIR environment variable if not set
HOME_DIR="${HOME_DIR:-/home/vagrant}";

case "$PACKER_BUILDER_TYPE" in
parallels-iso|parallels-pvm)
mkdir -p /tmp/parallels;
if [ "$(uname -m)" = "aarch64" ] ; then
mount -o loop "$HOME_DIR"/prl-tools-lin-arm.iso /tmp/parallels;
else
mount -o loop "$HOME_DIR"/prl-tools-lin.iso /tmp/parallels;
fi
VER="$(cat /tmp/parallels/version)";

echo "Parallels Tools Version: $VER";

/tmp/parallels/install --install-unattended-with-deps \
|| (code="$?"; \
echo "Parallels tools installation exited $code, attempting" \
"to output /var/log/parallels-tools-install.log"; \
cat /var/log/parallels-tools-install.log; \
exit $code);
umount /tmp/parallels;
rm -rf /tmp/parallels;
rm -f "$HOME_DIR"/*.iso;

# Parallels Tools for Linux includes native auto-mount script,
# which causes losing some of Vagrant-relative shared folders.
# So, we should disable this behavior.
# https://github.com/Parallels/vagrant-parallels/issues/325#issuecomment-418727113
# TODO: verify this is fixed in latest version of parallels
# auto_mount_script='/usr/bin/prlfsmountd'
# if [ -f "${auto_mount_script}" ]; then
# printf '#!/bin/sh\n # Shared folders auto-mount is disabled by Vagrant' > "${auto_mount_script}"
# fi

;;
esac
4 changes: 4 additions & 0 deletions packer_templates/scripts/debian/systemd_debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh -eux

# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751636
apt-get install libpam-systemd
24 changes: 24 additions & 0 deletions packer_templates/scripts/solaris/vmtools_solaris.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -eux

# Add pkgadd auto-answer file
sudo mkdir -p /tmp
sudo chmod 777 /tmp
{
echo "mail="
echo "instance=overwrite"
echo "partial=nocheck"
echo "runlevel=nocheck"
echo "idepend=nocheck"
echo "rdepend=nocheck"
echo "space=nocheck"
echo "setuid=nocheck"
echo "conflict=nocheck"
echo "action=nocheck"
echo "basedir=default"
} > /tmp/nocheck

if [ -f /home/vagrant/.vbox_version ]; then
mkdir /tmp/vbox
ls
echo "all" | sudo -i pkgadd -a /tmp/nocheck -d /media/VBOXADDITIONS_*/VBoxSolarisAdditions.pkg
fi
7 changes: 7 additions & 0 deletions packer_templates/scripts/ubuntu/sudoers_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh -eux

sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=sudo' /etc/sudoers;

# Set up password-less sudo for the vagrant user
echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >/etc/sudoers.d/99_vagrant;
chmod 440 /etc/sudoers.d/99_vagrant;
17 changes: 17 additions & 0 deletions packer_templates/scripts/windows/enable-file-sharing.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'

trap {
Write-Host
Write-Host "ERROR: $_"
($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1' | Write-Host
($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1' | Write-Host
Write-Host
Write-Host 'Sleeping for 60m to give you time to look around the virtual machine before self-destruction...'
Start-Sleep -Seconds (60*60)
Exit 1
}

Write-Host 'Enable filesharing'
Enable-NetFirewallRule -DisplayGroup "File and Printer Sharing"
Loading

0 comments on commit 49a9826

Please sign in to comment.