I am trying to use packer to update a template so that it is patched and than convert back to template. However, the customize setting doesn’t seem to work and won’t run and I get the following error:
Failed to parse template: 1 error occurred:
* Unknown root level key in template: ‘customize’
example below:
“customize”: {
“linux_options”: {
“host_name”: “packer-test”,
“domain”: “test.internal”
},
“network_interface”: {
“ipv4_address”: “10.0.0.10”,
“ipv4_netmask”: “24”
},
“ipv4_gateway”: “10.0.0.1”,
}
Using vsphere-clone builder a bad way to do this or just not supported? Any assistance would be appreciated.
Hey there,
Could you share the full build block, please?
{
"builders": [{
"type": "vsphere-clone",
"vcenter_server": "FQDN of vcenter",
"username": "secret username",
"password": "secret password",
"insecure_connection": "true",
"template": "name of template",
"vm_name": "name of template2",
"cluster": "cluster name",
"host": "esx host",
"datastore": "datastore used",
"convert_to_template": "true",
"ssh_username": "sshusername",
"ssh_password": "sshusername",
"ssh_wait_timeout": "20m",
"boot_command": [
"<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>"
]
}],
“customize”: {
“linux_options”: {
“host_name”: “name of template2”,
“domain”: “domain used”
},
“network_interface”: {
“ipv4_address”: “x.x.x.x”,
“ipv4_netmask”: “24”
},
“ipv4_gateway”: “x.x.x.x”
},
"provisioners": [{
"type": "shell",
"inline": [ "sudo yum -y update" ]
}]
}
Hopefully this came out correctly. I made small edits to keep the information private of course.
The customize
must be inside the vsphere-clone block. Like:
{
"builders": [{
"type": "vsphere-clone",
"vcenter_server": "FQDN of vcenter",
"username": "secret username",
"password": "secret password",
"insecure_connection": "true",
"template": "name of template",
"vm_name": "name of template2",
"cluster": "cluster name",
"host": "esx host",
"datastore": "datastore used",
"convert_to_template": "true",
"ssh_username": "sshusername",
"ssh_password": "sshusername",
"ssh_wait_timeout": "20m",
"boot_command": [
"<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>"
],
“customize”: {
“linux_options”: {
“host_name”: “name of template2”,
“domain”: “domain used”
},
“network_interface”: {
“ipv4_address”: “x.x.x.x”,
“ipv4_netmask”: “24”
},
“ipv4_gateway”: “x.x.x.x”
}
}],
"provisioners": [{
"type": "shell",
"inline": [ "sudo yum -y update" ]
}]
}
Ah thank you so much. That got me passed a lot. I seem to be stuck at the “Waiting for SSH to become available” part now. My guess is I have syntax in the wrong place. Doing some additional googling.
Figured that part out, it was an issue where the template was deploying to a different vlan than the IP range I was using for the VM. Updated that and no issues.
1 Like