I’m creating RHEL servers from a script using PACKER + kickstart file. Works great for a one disk server. Now I need to do the same but for a server with multiple disks. What is the format of the JSON file to accomplish this?
You’ll have to use the parameter disk_additional_size
.
Either you format the additional disks with kickstart or with a provisioner script via ssh.
Here is my JSON file and keed getting an error:
{
“builders”: [
{
“CPUs”: 2,
“RAM”: 16384,
“RAM_reserve_all”: false,
“disk_additional_size”: [
51200
],
“boot_command”: [
" Vmlinuz initrd=initrd.img inst.text inst.ks=hd:fd0:/redclient01-ks.cfg ",
“i”
],
“boot_order”: “disk,cdrom”,
“convert_to_template”: false,
“datacenter”: “DC01”,
“datastore”: “ant_esxds01”,
“disk_controller_type”: “pvscsi”,
“disk_size”: 51200,
“disk_thin_provisioned”: true,
“floppy_files”: [
“{{template_dir}}/redclient01-ks.cfg”
],
“guest_os_type”: “rhel7_64Guest”,
“host”: “esx17”,
“insecure_connection”: “true”,
“iso_checksum_type”: “sha256”,
“iso_paths”: [
“[ant_esx_iso01] ISO/rhel-server-7.7-x86_64-dvd.iso”
],
“network”: “VM Network”,
“network_card”: “vmxnet3”,
“notes”: “Build via Packer”,
“password”: “Paww0rd@”,
“ssh_password”: “Paww0rd”,
“ssh_username”: “root”,
“type”: “vsphere-iso”,
“username”: “administrator@vsphere.local”,
“vcenter_server”: “vcentersrv01”,
“vm_name”: “{{user vm_name
}}”
}
],
“provisioners”: [
{
“execute_command”: “echo ‘root’ | {{.Vars}} sh ‘{{.Path}}’”,
“expect_disconnect”: “true”,
“scripts”: [
“scripts/redhat_client_install”
],
“timeout”: “20m”,
“type”: “shell”
}
],
“variables”: {
“vm_name”: “redclient01”
}
}
Template validation failed. Errors are shown below.
Errors validating build ‘vsphere-iso’. 1 error occurred:
* unknown configuration key: “disk_additional_size”; raws is interface {}{map[string]interface {}{“CPUs”:2, “RAM”:16384, “RAM_reserve_all”:false, “boot_command”:interface {}{" Vmlinuz initrd=initrd.img inst.text inst.ks=hd:fd0:/redclient01-ks.cfg “, “i”}, “boot_order”:“disk,cdrom”, “convert_to_template”:false, “datacenter”:“DC01”, “datastore”:“ant_esxds01”, “disk_additional_size”:interface {}{51200}, “disk_controller_type”:“pvscsi”, “disk_size”:51200, “disk_thin_provisioned”:true, “floppy_files”:interface {}{”/dlgl_admin/kickstart/packer/Linux/redclient01-ks.cfg"}, “guest_os_type”:“rhel7_64Guest”, “host”:“esx17”, “insecure_connection”:“true”, “iso_checksum_type”:“sha256”, “iso_paths”:interface {}{"[ant_esx_iso01] ISO/rhel-server-7.7-x86_64-dvd.iso"}, “network”:“VM Network”, “network_card”:“vmxnet3”, “notes”:“Build via Packer”, “password”:“Paww0rd@”, “ssh_password”:“Paww0rd”, “ssh_username”:“root”, “username”:“administrator@vsphere.local”, “vcenter_server”:“vcentersrv01”, “vm_name”:“redclient01”}, map[string]interface {}{“packer_build_name”:“vsphere-iso”, “packer_builder_type”:“vsphere-iso”, “packer_debug”:false, “packer_force”:false, “packer_on_error”:"", “packer_template_path”:"/dlgl_admin/kickstart/packer/Linux/test1.json", “packer_user_variables”:map[interface {}]interface {}{"":"", “vm_name”:“redclient01”}}}
and ctx data is map[interface {}]interface {}(nil)
packer -version
1.5.5
If it’s only one additional disk, try it without the brackets.
Same result:
Errors validating build ‘vsphere-iso’. 1 error occurred:
* unknown configuration key: “disk_additional_size”;
Ok, wait, you are using the “vsphere-iso” builder. I am using “vmware-iso” and the documentation is from this builder. Let me see for “vsphere-iso”…
Look at this:
Sorry, I have probably overlooked the difference in the builder used.
OK, Found the solution… Here is how the section storage must be defined:
…
“disk_controller_type”: “pvscsi”,
“storage”: [
{
“disk_size”: 51200,
“disk_thin_provisioned”: true
},
{
“disk_size”: 51200,
“disk_thin_provisioned”: true
},
{
“disk_size”: 51200,
“disk_thin_provisioned”: true
},
{
“disk_size”: 102400,
“disk_thin_provisioned”: true
},
{
“disk_size”: 51200,
“disk_thin_provisioned”: true
},
{
“disk_size”: 102400,
“disk_thin_provisioned”: true
}
],
…
@superghi64 I don’t see where you are specifying the additional iso files in your template?
I would like to enable my packer projects (which install mostly debian) to mount all the DVDs provided for a debian release, and refer to them in the preseeded installation to speed things up (bc I install a lot of packages in the preseed). Is this what you’re doing?
I see here that you are specifying the extra disks in your storage array, but where do the paths to the isos get defined?