-
Notifications
You must be signed in to change notification settings - Fork 175
vsphere-iso example for CentOS #85
Comments
I am currently using the following packer json file for creating centos7 template on vsphere version 6 (with no boot_cmd option, because the API does not support it). {
"variables": {
"vcenter_host": "server",
"vcenter_user": "user",
"vcenter_password": "",
"ssh_user": "user",
"ssh_password": "password",
"dc": "domain",
"cluster": "cluster",
"network": "network",
"storage": "datastore",
"template_dir": "dir",
"iso_path": "iso",
"ks_file": "kickstart/ks.cfg",
"cpu_cores": "2",
"ram_mb": "4096",
"disk_size_gb": "50"
},
"builders": [
{
"type": "vsphere-iso",
"vcenter_server": "{{ user `vcenter_host` }}",
"username": "{{ user `vcenter_user` }}",
"password": "{{ user `vcenter_password` }}",
"insecure_connection": "true",
"ssh_username": "{{ user `ssh_user` }}",
"ssh_password": "{{ user `ssh_password` }}",
"datacenter": "{{ user `dc` }}",
"cluster": "{{ user `cluster` }}",
"network": "{{ user `network` }}",
"network_card": "vmxnet3",
"datastore": "{{ user `storage` }}",
"vm_name": "centos7_base_{{isotime \"2006-01-02\"}}",
"guest_os_type": "rhel7_64Guest",
"CPUs": "{{ user `cpu_cores` }}",
"RAM": "{{ user `ram_mb` }}",
"RAM_reserve_all": true,
"disk_controller_type": "pvscsi",
"disk_size": "{{ user `disk_size_gb` }}",
"disk_thin_provisioned": true,
"folder": "{{ user `template_dir` }}",
"iso_paths": [
"{{ user `iso_path` }}"
],
"floppy_files": [
"{{ user `ks_file` }}"
],
"boot_order": "disk,cdrom",
"convert_to_template": true
}
],
"provisioners": [
{
"type": "shell",
"inline": ["rm -rf /etc/yum.repos.d/*"],
"execute_command": "echo 'root' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"pause_before": "10s"
},
{
"type": "file",
"source": "repos/",
"destination": "/etc/yum.repos.d"
},
{
"type": "shell",
"execute_command": "echo 'root' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/centos7_cleanup.sh",
"expect_disconnect": "true"
}
]
} You can also use the boot_cmd option if you have vsphere 6.5, otherwise you can edit the centos7 iso and edit the isolinux.cfg to point to the floppy disk(kickstart file) in this setup. |
I can create a kickstart ISO that can load automatically without editing the Centos ISO. Can an extra CD-ROM device be added for the kickstart ISO? And can Packer remove all CD-ROM devices once install completes? Must look at the |
@dkirrane I attempted to use Packer to create a CentOS image with a kickstart.iso created with My template:
|
Packer does IIRC remove all CD-ROM devices when the build is finished, or at least this builder does, but only if you don't convert it to a template. |
@sudomateo I've used the following steps with
|
Hello, I followed all the instructions but I still have a problem here: vphere
kickstart file ks.cfg:
Thanks for your help. |
Thanks for providing some examples, friends. You saved me a ton of time while getting CentOS 7 working with vSphere 5.5. I also had to get CentOS 6 working. Here are a few things I learned.
Another CentOS 6 quirk if you are copy-and-pasting the examples here.
And extra thanks to @sudomateo for the example up there ^^^. You saved me a ton of time with CentOS 7. But watch our for that |
Haha , indeed. that also turned me crazy until I figured out that it was in MB. 😂😂 |
for vsphere 6.5 I made Packer and Kickstart successfully work for template VM. |
You're very welcome! Haha at the time of my writing, the |
@MacFlurry Can you post the code that you go to work? |
oh sorry, I've been pretty busy lately. Do you still need the code? |
Just in case someone want it: {
"variables": {
"vcenter_host": "{{env `VCENTER_HOST` }}",
"vcenter_user": "admin_name",
"vcenter_password": "{{env `VCENTER_PASSWORD` }}",
"ssh_host": "{{env `SSH_HOST` }}",
"ssh_port": "22",
"ssh_user": "root",
"ssh_password": "put_password_here",
"vm_name": "vmname_goes_here",
"dc": "{{env `VCENTER_DATACENTER` }}",
"cluster": "{{env `VCENTER_CLUSTER` }}",
"network": "{{env `VCENTER_NETWORK` }}",
"storage": "{{env `VCENTER_STORAGE` }}",
"ks_file": "ks.cfg",
"cpu_cores": "1",
"ram_mb": "1024",
"disk_size_mb": "14336"
},
"builders": [
{
"type": "vsphere-iso",
"vcenter_server": "{{ user `vcenter_host` }}",
"username": "{{ user `vcenter_user` }}",
"password": "{{ user `vcenter_password` }}",
"insecure_connection": "true",
"ssh_username": "{{ user `ssh_user` }}",
"ssh_password": "{{ user `ssh_password` }}",
"ssh_timeout": "600s",
"ssh_port": "{{ user `ssh_port` }}",
"ssh_host": "{{ user `ssh_host` }}",
"datacenter": "{{ user `dc` }}",
"cluster": "{{ user `cluster` }}",
"network": "{{ user `network` }}",
"network_card": "vmxnet3",
"datastore": "{{ user `storage` }}",
"vm_name": "{{ user `vm_name` }}",
"guest_os_type": "centos7_64Guest",
"CPUs": "{{ user `cpu_cores` }}",
"RAM": "{{ user `ram_mb` }}",
"RAM_reserve_all": true,
"convert_to_template": true,
"disk_controller_type": "pvscsi",
"disk_size": "{{ user `disk_size_mb` }}",
"disk_thin_provisioned": true,
"iso_paths": [
"[datastore_name] directory/centos_7_original.iso"
],
"floppy_files": [
"{{template_dir}}/ks.cfg"
],
"boot_wait": "10s",
"boot_command": "<esc> <wait> linux inst.text inst.ks=hd:fd0:/ks.cfg <enter>"
}
],
"provisioners": [
{
"type": "shell",
"inline": [ "ls /"],
"execute_command": "echo 'root' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"pause_before": "10s"
}
]
} |
@MacFlurry Thanks very much for the snippet, that saves me a little time :) |
You're welcomed :-) |
This will not work on CentOS 8+. I had to revert to http.. |
@kbcz1989 confirmed. I haven't had a chance to dig into why, but I think either kickstart dropped floppy support or the default vmware/floppy driver isn't included anymore. |
i am able to spin the vm in vmware esxi 6.7 but the build is failing at "Build 'vsphere-iso' errored: Timeout waiting for SSH" getting an error “2020/04/10 04:40:05 packer-builder-vsphere-iso plugin: [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.0.68.221:22: i/o timeout” i have given the same ssh_username, password what is there in the kickstart file but still the same . ssh_timeout is 5min . my kickstart file is as below: Basic Configurationlang en_US Installationtext BootLoaderbootloader --location=mbr --timeout=10 --append="rhgb quiet crashkernel=auto" Partitionclearpart --all --initlabel --drives=sda Authauth --passalgo=sha512 --useshadow Disable selinux & Fwselinux --disabled No GUIskipx Post installation%post --nochroot --interpreter=/bin/bash Packages%packages |
@allaboutopensource so, installation finishes or not? Do you see the IP address in VSphere? |
i can see the IP address in the vsphere with the login page showing up but i cannot ping the ip address and nor tenlet to 22 port. |
That sounds like a network problem. If you install the machine manually and set the same ip, can you then ping/telnet from packer machine? |
i am able to create the vm with manually assigned ip address but it just taking more then 5 minutes to activate the network on it. one more thing is that when i try to login to the vmware vm console manually with the username and password it says incorrect login. |
Is there any
vsphere-iso
example for creating a vm from an ISO and Kickstart file.The text was updated successfully, but these errors were encountered: