Appliance as code aka AAC with Packer

2020/12/03 | 1 minute read |

For my tools VMware Lab, building your VMware vSphere 7 Lab in less than 40 min.😀 Why a DNS server beacause if you want to learn DSC for VMware you need to have a DNS server to make this.

1 First Try

My first try was to build a photonOs appliance in version 3 to make a DNS server.

  • Download the PhotonOs OVA from the github repository
  • Connect to ssh and configure it
  • Cleanup and export to OVF
  • Convert to OVA

It work’s but too heavy to build and maintain.

2 The automation with Packer

I decide to make my appliance as code with Packer.

2.1 Requirements

2.2 Clone the git repository

git clone https://github.com/JM2K69/Photon-DNS-Appliance.git

2.3 Edit the photon-builder.json file to configure the vSphere endpoint for building the PhotonOS appliance

{
  "builder_host": "192.168.30.10",
  "builder_host_username": "root",
  "builder_host_password": "VMware1!",
  "builder_host_datastore": "vsanDatastore",
  "builder_host_portgroup": "VM Network"
}

Note: If you need to change the initial root password on the PhotonOS appliance, take a look at photon-version.json and http/photon-kickstart.json. When the OVA is produced, there is no default password, so this does not really matter other than for debugging purposes.

2.4 Start the build by running the build script which simply calls Packer and the respective build files

./build.sh or ./build_Photon4.sh 

When you run the script ./build.sh or ./build_Photon4.sh we use the provider vmware-iso and not vsphere-iso, you need to enable SSH on your host ESXI.

Enable “Guest IP Hack” Run the following command on the ESXi host:

esxcli system settings advanced set -o /Net/GuestIPHack -i 1

if you want to try my appliances:

Auhtors_img

My repo is on Github here

Thank’s for reading.🤗

Written by Jérôme Bezet-Torres @JM2K69.