Skip to content
---
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
PACKER_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# PACKER_LOG: "1"
jobs:
x86_64:
runs-on: macos-13
strategy:
fail-fast: false
matrix:
os:
- debian-11
- debian-12
- ubuntu-22.04
- ubuntu-24.04
provider:
- vmware-iso
steps:
- name: Checkout
uses: actions/checkout@main
- name: Install Vagrant VMware-fusion
run: |
brew tap hashicorp/tap
brew update
brew install --cask hashicorp/tap/hashicorp-vagrant
brew install --cask vmware-fusion
brew install --cask vagrant-vmware-utility
vagrant plugin install vagrant-vmware-desktop
sudo mkdir -p /Library/Preferences/VMware\ Fusion/vmnet8
NETWORKING_CONF="/Library/Preferences/VMware Fusion/networking"
DHCPD_CONF="/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf"
NAT_CONF="/Library/Preferences/VMware Fusion/vmnet8/nat.conf"
NAT_MAC_CONF="/Library/Preferences/VMware Fusion/vmnet8/nat.mac"
DHCPD_CONFIG='
# Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
###### VMNET DHCP Configuration. Start of "DO NOT MODIFY SECTION" #####
# Modification Instructions: This section of the configuration file contains
# information generated by the configuration program. Do not modify this
# section.
# Written at: 05/20/2024 11:50:44
allow unknown-clients;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours
subnet 172.16.38.0 netmask 255.255.255.0 {
range 172.16.38.128 172.16.38.254;
option broadcast-address 172.16.38.255;
option domain-name-servers 172.16.38.2;
option domain-name localdomain;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours
option netbios-name-servers 172.16.38.2;
option routers 172.16.38.2;
}
host vmnet8 {
hardware ethernet 00:50:56:C0:00:08;
fixed-address 172.16.38.1;
option domain-name-servers 0.0.0.0;
option domain-name "";
option routers 0.0.0.0;
}
####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######
'
NAT_CONFIG="
# VMware NAT configuration file
[host]
# Use MacOS network virtualization API
useMacosVmnetVirtApi = 1
# NAT gateway address
ip = 172.16.38.2
netmask = 255.255.255.0
# VMnet device if not specified on command line
device = vmnet8
# Allow PORT/EPRT FTP commands (they need incoming TCP stream ...)
activeFTP = 1
# Allows the source to have any OUI. Turn this on if you change the OUI in the MAC address of your virtual machines.
allowAnyOUI = 1
# VMnet host IP address
hostIp = 172.16.38.1
# Controls if (TCP) connections should be reset when the adapter they are bound to goes down
resetConnectionOnLinkDown = 1
# Controls if (TCP) connection should be reset when guest packet's destination is NAT's IP address
resetConnectionOnDestLocalHost = 1
# Controls if enable nat ipv6
natIp6Enable = 0
# Controls if enable nat ipv6
natIp6Prefix = fd15:4ba5:5a2b:1008::/64
[tcp]
# Value of timeout in TCP TIME_WAIT state, in seconds
timeWaitTimeout = 30
[udp]
# Timeout in seconds. Dynamically-created UDP mappings will purged if idle for this duration of time 0 = no timeout, default = 60; real value might be up to 100% longer
timeout = 60
[netbios]
# Timeout for NBNS queries.
nbnsTimeout = 2
# Number of retries for each NBNS query.
nbnsRetries = 3
# Timeout for NBDS queries.
nbdsTimeout = 3
[incomingtcp]
# Use these with care - anyone can enter into your VM through these...
# The format and example are as follows:
#<external port number> = <VM's IP address>:<VM's port number>
#8080 = 172.16.3.128:80
[incomingudp]
# UDP port forwarding example
#6000 = 172.16.3.0:6001
"
NAT_MAC_CONFIG="00:50:56:F2:C7:28"
NETWORKING_CONFIG="
VERSION=1,0
answer VNET_1_DHCP yes
answer VNET_1_DHCP_CFG_HASH 97D56988968565698E051056ADEDEEACF00F5981
answer VNET_1_HOSTONLY_NETMASK 255.255.255.0
answer VNET_1_HOSTONLY_SUBNET 172.16.252.0
answer VNET_1_HOSTONLY_UUID 74A7B7F5-AB8E-41CF-9E0F-595F9C9FA1C5
answer VNET_1_VIRTUAL_ADAPTER yes
answer VNET_8_DHCP yes
answer VNET_8_DHCP_CFG_HASH 2040265D0F7053A921FB3F6EDE944490D9E687D6
answer VNET_8_HOSTONLY_NETMASK 255.255.255.0
answer VNET_8_HOSTONLY_SUBNET 172.16.38.0
answer VNET_8_HOSTONLY_UUID 3CBAC6B3-6A71-4182-8BC6-849058A947B8
answer VNET_8_NAT yes
answer VNET_8_VIRTUAL_ADAPTER yes
"
# Write the network configuration to the file
echo "$NETWORKING_CONFIG" | sudo tee "$NETWORKING_CONF" > /dev/null
echo "$DHCPD_CONFIG" | sudo tee "$DHCPD_CONF" > /dev/null
echo "$NAT_CONFIG" | sudo tee "$NAT_CONF" > /dev/null
echo "$NAT_MAC_CONFIG" | sudo tee "$NAT_MAC_CONF" > /dev/null
echo "VMware Fusion networking configuration updated."
- name: Install Chef
uses: actionshub/[email protected]
with:
version: 24.2.1058
- name: Setup Packer
uses: hashicorp/setup-packer@main
with:
version: latest
- name: Install Bento
run: |
eval "$(chef shell-init bash)"
gem build bento.gemspec
gem install bento-*.gem
- name: Bento build
run: |
eval "$(chef shell-init bash)"
bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl"
ls -alh builds/
cat builds/${{ matrix.os }}*-x86_64._metadata.json
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: "${{ matrix.os }}-vmware-x86_64"
path: |
builds/*.box
builds/*.json
retention-days: 10
compression-level: 0 # no compression
- name: Bento Test
run: |
eval "$(chef shell-init bash)"
bento test