Build with vsphere on esxi node not connected to destination cluster

277 views
Skip to first unread message

Hendrik

unread,
Dec 6, 2017, 7:45:30 AM12/6/17
to Packer
Hi,

I'm building a vm with packer and vmware-iso on a second esxi node. This node is not connected to the vsphere-cluster where the vm should be published.
Copying the image to the cluster with vmware-iso works but vsphere-template fails with an error:

    vmware-iso (vsphere): Completed successfully
    vmware
-iso (vsphere):
==> vmware-iso: Running post-processor: vsphere-template
    vmware
-iso (vsphere-template): Waiting 10s for VMware vSphere to start
    vmware
-iso (vsphere-template): Choosing datacenter...
    vmware
-iso (vsphere-template): Creating or checking destination folders...
    vmware
-iso (vsphere-template): Marking as a template...
==> vmware-iso (vsphere-template): VM at path /DC02/vm/Discovered virtual machine/centos7_1711 not found

I dont know how packer assembles this path.
My json looks like this:

{
   
"builders": [
       
{
           
"boot_command": [
               
"<tab> text ks=hd:fd0:/ks.cfg ip=dhcp <enter><wait><wait><enter>"
           
],
           
"boot_wait": "10s",
           
"disk_size": "{{user `disk_size`}}",
           
"disk_type_id": "thin",
           
"floppy_files": [
               
"anaconda/ks.cfg"
           
],
           
"format": "ovf",
           
"guest_os_type": "rhel7-64",
           
"headless": "true",
           
"iso_checksum": "bba314624956961a2ea31dd460cd860a77911c1e0a56e4820a12b9c5dad363f5",
           
"iso_checksum_type": "sha256",
           
"iso_url": "http://mirrors.ocf.berkeley.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso",
           
"keep_registered": "true",
           
"output_directory": "output-{{build_type}}",
           
"remote_cache_datastore": "{{user `datastore`}}",
           
"remote_cache_directory": "cache",
           
"remote_datastore": "{{user `esxi_datastore`}}",
           
"remote_host": "{{user `esxi_host`}}",
           
"remote_password": "{{user `esxi_password`}}",
           
"remote_type": "esx5",
           
"remote_username": "{{user `esxi_user`}}",
           
"shutdown_command": "echo {{user `ssh_pass`}} | sudo -S systemctl poweroff",
           
"ssh_password": "{{user `ssh_pass`}}",
           
"ssh_timeout": "{{user `ssh_timeout`}}",
           
"ssh_username": "{{user `ssh_name`}}",
           
"type": "vmware-iso",
           
"vm_name": "{{user `image_name`}}",
           
"vmx_data": {
               
"cpuid.coresPerSocket": "2",
               
"ethernet0.networkName": "VM Network",
               
"ethernet0.virtualDev": "vmxnet3",
               
"memsize": "1024",
               
"numvcpus": "2"
           
}
       
}
   
],
   
"post-processors": [
       
[{
           
"cluster": "{{user `vsphere_prod_cluster`}}",
           
"datacenter": "{{user `vsphere_prod_datacenter`}}",
           
"datastore": "{{user `vsphere_prod_datastore`}}",
           
"host": "{{user `vsphere_prod_host`}}",
           
"insecure": "true",
           
"overwrite": "true",
           
"password": "{{user `vsphere_prod_pass`}}",
           
"resource_pool": " ",
           
"type": "vsphere",
           
"username": "{{user `vsphere_prod_username`}}",
           
"vm_folder": "/packer-templates/os/{{user `image_name`}}",
           
"vm_name": "{{user `image_name`}}"
       
},
       
{
           
"datacenter": "{{user `vsphere_prod_datacenter`}}",
           
"folder": "/packer-templates/os/{{user `image_name`}}",
           
"host": "{{user `vsphere_prod_host`}}",
           
"insecure": true,
           
"password": "{{user `vsphere_prod_pass`}}",
           
"type": "vsphere-template",
           
"username": "{{user `vsphere_prod_username`}}"
       
}],
       
{
           
"cluster": "{{user `vsphere_dev_cluster`}}",
           
"datacenter": "{{user `vsphere_dev_datacenter`}}",
           
"datastore": "{{user `vsphere_dev_datastore`}}",
           
"host": "{{user `vsphere_dev_host`}}",
           
"insecure": "true",
           
"overwrite": "true",
           
"password": "{{user `vsphere_dev_pass`}}",
           
"resource_pool": " ",
           
"type": "vsphere",
           
"username": "{{user `vsphere_dev_username`}}",
           
"vm_folder": "/packer-templates/os/{{user `image_name`}}",
           
"vm_name": "{{user `image_name`}}"
       
},
       
{
           
"datacenter": "{{user `vsphere_dev_datacenter`}}",
           
"folder": "/packer-templates/os/{{user `image_name`}}",
           
"host": "{{user `vsphere_dev_host`}}",
           
"insecure": true,
           
"password": "{{user `vsphere_dev_pass`}}",
           
"type": "vsphere-template",
           
"username": "{{user `vsphere_dev_username`}}"
       
}
   
],
   
"provisioners": [
       
{
           
"ansible_env_vars": [
               
"ANSIBLE_NOCOWS=1"
           
],
           
"extra_arguments": [
               
"--extra-vars",
               
"ansible_become_pass={{user `ssh_pass`}} ansible_become_user=root ansible_ssh_user={{user `ssh_name`}} ansible_become=true ansible_ssh_pass={{user `ssh_pass`}} ansible_become_method=sudo root_pass={{user `root_pass`}} admin=pass={{user `admin_pass`}}"
           
],
           
"playbook_file": "../ansible/bootstrap-{{user `image_name`}}/bootstrap.yml",
           
"type": "ansible",
           
"user": "{{user `ssh_name`}}"
       
}
   
],
   
"variables": {
       
"admin_pass": "",
       
"disk_size": "20480",
       
"esxi_datastore": "",
       
"esxi_host": "",
       
"esxi_password": "",
       
"esxi_user": "",
       
"hostname": "centos",
       
"image_name": "centos7_1711",
       
"memory": "1024",
       
"root_pass": "",
       
"ssh_name": "administrator",
       
"ssh_pass": "administrator",
       
"ssh_timeout": "20m",
       
"vsphere_dev_address": "",
       
"vsphere_dev_datacenter": "",
       
"vsphere_dev_datastore": "",
       
"vsphere_dev_host": "",
       
"vsphere_dev_pass": "",
       
"vsphere_dev_username": "",
       
"vsphere_prod_address": "",
       
"vsphere_prod_datacenter": "",
       
"vsphere_prod_datastore": "",
       
"vsphere_prod_host": "",
       
"vsphere_prod_pass": "",
       
"vsphere_prod_username": ""
   
}
}

Packer version is 1.1.2.
Does anybody have a working .json on this setup?

Alvaro Miranda Aguilera

unread,
Dec 6, 2017, 4:28:01 PM12/6/17
to packe...@googlegroups.com
hello

there is no template in standalone ESXi

can you clone a VM into a template in that ESXi directly?

Alvaro.


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/da021814-ef96-4ce2-9695-9255ba78492c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Hendrik

unread,
Dec 12, 2017, 5:24:28 AM12/12/17
to Packer
I'm creating the vm with vmware-iso on a secondary single esxi host and post-process it with "vsphere" to upload it to my vsphere-cluster.
After that I would like to mark the uploaded vm on my cluster as a template.

The single esxi machine IS NOT CONNECTED to the vsphere cluster.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages