https://github.com/mhmdio/packer-esxi-ssh
Packer build on ESXi connected with SSH
https://github.com/mhmdio/packer-esxi-ssh
esxi packer ssh ubuntu
Last synced: 6 months ago
JSON representation
Packer build on ESXi connected with SSH
- Host: GitHub
- URL: https://github.com/mhmdio/packer-esxi-ssh
- Owner: mhmdio
- Created: 2021-01-30T11:44:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-30T11:55:35.000Z (over 5 years ago)
- Last Synced: 2025-03-10T23:18:55.845Z (over 1 year ago)
- Topics: esxi, packer, ssh, ubuntu
- Language: HCL
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Packer Build on VMware ESXi

Use Packer to build VM on ESXi 7.0u1
- build machines directly on VMware vSphere Hypervisor using SSH (as opposed to the vSphere API)
## Building Requirements
- Packer
- ovftool
- ESXi host connectivity
- ESXi host username and password with permission
## ESXi Requirements
- enable ssh
- enable shell
- run `esxcli system settings advanced set -o /Net/GuestIPHack -i 1`
## Packer commands
```bash
cd OS_FOLDER
packer fmt . # Rewrites HCL2 config files to canonical format
packer validate . # check that a template is valid
packer inspect . # see components of a template
packer build . # build image(s) from template
```
## ovftool
Download from [here](https://my.vmware.com/group/vmware/downloads/details?downloadGroup=OVFTOOL441&productId=742)
### macOS
```bash
ln -s /Applications/"VMware OVF Tool"/ovftool /usr/local/bin/ovftool
```
## Packer Templates
- LTS -> [linux-ubuntu-20.04](./linux-ubuntu-20.04/)
- [linux-ubuntu-20.10](./linux-ubuntu-20.10/)
- [linux-alpine](./linux-alpine/)
## Troubleshoot
- Networking: make sure VMs are getting IPv4 from DHCP.
## References
- (ubuntu autoinstall)[https://ubuntu.com/server/docs/install/autoinstall-reference]
- (packer vmware-iso source)[https://www.packer.io/docs/builders/vmware/iso]
## Generate Hash Password
user-data file (cloud-init) used hashed Password.
```bash
printf vagrant | mkpasswd -m sha-512 -S vagrant. -s
```
## Packer autoinstall
Packer autoinstall can be done with cloud-init by passing meta-data and user-data with one of the following methods:
- via CD drive, you need to pass `autoinstall ds=nocloud;seedfrom=/cidata/` [not all OS reqiure this]
- via HTTP IP and HTTP Port, you need to pass `autoinstall ds=nocloud-net\\;s=http://{{.HTTPIP}}:{{.HTTPPort}}/`
## Build
Packer will generate OVA (OVF package) for each image in [build](./build) folder.
Tested import OVA on:
- macOS - VMware Fusion