Creates a packer image to deploy on AWS or ESXi.
Git clone this repository, all paths are relative to the base directory of this repository.
Create a json file with credentials. For AWS this is optional, you can skip this if you have AWS CLI configured.
{
"aws_access_key": "<AWS ACCESS KEY>",
"aws_secret_key": "<AWS SECRET KEY>",
"aws_region": "<AWS REGION>"
}
{
"username": "packer",
"password": "packer",
"esxi_host": "<ESXi IP>",
"esxi_username": "<ESXi USER>",
"esxi_password": "<ESXi PASSWORD>"
}
{
"vcenter_server": "<VCENTER_ADDRESS>",
"vcenter_username": "<VCENTER_USER>",
"vcenter_password": "<VCENTER_PASSWORD>",
"vcenter_insecure_connection": "<false|true>",
"vcenter_datacenter": "<DATACENTER>",
"vcenter_cluster": "<CLUSTER>",
"vcenter_datastore": "<DATASTORE>"
}
Run packer from the base folder of this repository.
packer validate -var-file=vars/vcenter-vars.json vcenter/centos/7/vcenter-centos7.json
packer build -var-file=vars/vcenter-vars.json vcenter/centos/7/vcenter-centos7.json
Alternatively you can set a parameter as a environment variable:
{
(...)
"vcenter_password": "{{ env `PACKER_VSPHERE_PASSWORD` }}",
(...)
}
Export vSphere password and call Packer:
export PACKER_VSPHERE_PASSWORD="<PASSWORD>"
packer validate -var-file=vars/vcenter-vars.json vcenter/centos/7/vcenter-centos7.json
packer build -var-file=vars/vcenter-vars.json vcenter/centos/7/vcenter-centos7.json
Example:
packer init proxmox/almalinux/9
packer validate proxmox/almalinux/9
export PKR_VAR_password="<PASSWORD>"
packer build proxmox/almalinux/9
An image will be created, AMI for AWS or OVA for ESXi ready to be used. A template will be generated for vCenter.
The vsphere-iso
provider does not cleanup packer_cache
folder, remove it manually if desired.