Here is a JSON file to be used with Packer on a Mac. It will create a local VM for Fusion. The variables section is ‘use it or loose it’. I use it in order to pass variables from the CLI when creating several VMs.
The variables are passed to the Linux Boot Menu i.e. by pressing [TAB]. The builders -> boot_command is where the variables are inserted as seen in the JSON files boot_command section.
{ "variables": { "hostname": "rhdev100", "domain": "rocksolid.com", "ip": "192.168.198.30", "gateway": "192.168.198.2", "netmask": "255.255.255.0", "dns1": "192.168.198.2", "dns2": "192.168.198.3" }, "builders": [ { "boot_command": [ "<tab>", "vmlinuz initrd=initrd.img ", "myhostname={{user `hostname`}} ", "mydomain={{user `domain`}} ", "myip={{user `ip`}} ", "mygateway={{user `gateway`}} ", "mynetmask={{user `netmask`}} ", "mydns1={{user `dns1`}} ", "mydns2={{user `dns2`}} ", "ks=http://192.168.198.1:8000/Build/kickstart/rh.cfg <enter><wait>" ], "boot_wait": "10s", "disk_size": 40000, "guest_os_type": "centos-64", "headless": false, "iso_checksum": "32c7695b97f7dcd1f59a77a71f64f2957dddf738", "iso_checksum_type": "sha1", "iso_url": "http://192.168.198.1:8000/packer/ISO/CentOS-6.5-x86_64-bin-DVD1.iso", "output_directory": "/Users/TheDude/VirtualMachines/{{user `hostname`}}", "shutdown_command": "shutdown -h now", "ssh_password": "SecretPasswd", "ssh_port": 22, "ssh_username": "root", "ssh_wait_timeout": "360s", "tools_upload_path": "/var/tmp/linux.iso", "tools_upload_flavor": "linux", "type": "vmware-iso", "vm_name": "{{user `fqdn`}}", "vmx_data": { "ethernet0.present": "TRUE", "ethernet0.virtualDev": "vmxnet3", "memsize": "512", "numvcpus": "1", "cpuid.coresPerSocket": "1", "scsi0:0.fileName": "disk.vmdk", "scsi0:0.present": "TRUE", "scsi0:0.redo": "" } } ], "provisioners": [ { "execute_command": "echo 'TheDude' | {{.Vars}} sudo -S -E bash '{{.Path}}'", "scripts": [ "scripts/yum.sh", "scripts/sysctl.sh", "scripts/network.sh", "scripts/vmtoolslocal.sh" ], "type": "shell" } ] }