vsphere-template post-processor syntax

213 views
Skip to first unread message

Aaron Kulbe

unread,
May 7, 2018, 8:32:41 PM5/7/18
to Packer
I am building a VM, then attempting to upload that VM to vSphere and mark it as a template.

The VM builds fine, it uploads to vSphere fine. It's just not getting marked as a template.

I have read the section in the docs titled "Using the vSphere Template with local builders", and I thought I had it right, but it's not working. Here's my template, sanitized.

{
  "variables": {
    "name": "BaseImage",
    "platform": "rh72",
    "version": "1.3.0"
  },
  "builders": [
    {
      "type": "vmware-iso",
      "boot_command": [ "<up><tab> text biosdevname=0 net.ifnames=0 ks=hd:fd0:/baseimage_130_72.cfg<enter><wait>" ],
      "boot_wait": "15s",
      "disk_size": "20480",
      "guest_os_type": "rhel7-64",
      "headless": true,
      "iso_urls": [ "rhel-server-7.2-x86_64-dvd.iso" ],
      "floppy_files": [ "http/baseimage_130_72.cfg" ],
      "iso_checksum_type": "sha256",
      "iso_checksum": "03f3a0291634335f6995534d829bd21ffaa0d000004dfeb1b2fb81052d64a4d5",
      "ssh_username": "vagrant",
      "ssh_password": "vagrant",
      "ssh_port": 22,
      "ssh_wait_timeout": "20000s",
      "shutdown_command": "echo 'vagrant'|sudo -S /sbin/halt -h -p",
      "tools_upload_flavor": "linux",
      "vm_name": "Base_Image",
      "vnc_port_min": "5902",
      "vnc_port_max": "5902",
      "vnc_disable_password": true,
      "network": "nat",
      "vmx_data": {
        "cpuid.coresPerSocket": "1",
        "memsize": "1024",
        "numvcpus": "1"
      }
    }
  ],
  "post-processors": [
    {
      "output": "builds/{{user `name`}}-{{user `platform`}}-{{user `version`}}-{{timestamp}}.box",
      "type": "vagrant",
      "keep_input_artifact": true
    },
    {
      "target": "{{user `name`}}-{{user `platform`}}-{{user `version`}}-{{timestamp}}.ova",
      "type": "ovftool",
      "only": [ "vmware-iso" ],
      "format": "ova"
    },
    {
      "type": "vsphere",
      "cluster": "mycluster",
      "datacenter": "mydatacenter",
      "datastore": "mydatastore",
      "host": "myvmhost.mycompany.com",
      "username": "myuser",
      "password": "mypass",
      "vm_name": "test-vm-rh72-130",
      "overwrite": true,
      "vm_network": "my_network" 
    },
    {
      "type": "vsphere-template",
      "host": "myvmhost.mycompany.com",
      "insecure": true,
      "username": "myuser",
      "password": "mypass",
      "datacenter": "mydatacenter"
   }
  ]
}

Alvaro Miranda Aguilera

unread,
May 8, 2018, 12:17:32 PM5/8/18
to packe...@googlegroups.com

Aaron Kulbe

unread,
May 8, 2018, 4:03:14 PM5/8/18
to packe...@googlegroups.com

Hi Alvaro,

 

Thank you for responding. I have four total post-processors running, as shown below. If I use the double brackets as you mentioned previously, and try them around all four post-processors, it doesn’t work. If I double-bracket around just vsphere and vsphere-template, and remove vagrant and ovftool blocks, it works. Is there any way to do all four post-processors? I’m not sure how to format it.

 

"post-processors": [

    {

      "type": "vagrant",

    },

    {

      "type": "ovftool",

    },

    {

      "type": "vsphere",

    },

    {

      "type": "vsphere-template",

    }

  ]

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHqq0ewK4OtFZfn5jZwtn2-mw0q1hNB9bTMvYp5zoP%3DiDqtfeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Kulbe

unread,
May 8, 2018, 5:33:09 PM5/8/18
to packe...@googlegroups.com

I got it figured out. Thank you for pointing me in the right direction!

Ayesha Sultana

unread,
May 8, 2018, 5:36:00 PM5/8/18
to packe...@googlegroups.com
Hello Aaron,

I am not sure why you are using the ovftool post-processor - as the vsphere already does that.  For your code to work use this format:


"post-processors": [

    [

      {

          "type": "vagrant",

      },

      {

          "type": "vsphere",

      },

     {

        "type": "vsphere-template",

     }

  ]

 ]


The reason to have it in the [] block is to pass the artifact from the previous post-processor - specially in case of using the vSphere and the vSphere-template (to mark it as template it needs to know what was processed by the vSphere post processor)  I really feel that you don't need the ovftool processor.


Try this within the array block of [] and it should work.


Thanks



To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.

--
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/E495E980-D937-42B8-9A80-06DA9175004C%40longviewbits.com.

Aaron Kulbe

unread,
May 8, 2018, 6:07:10 PM5/8/18
to packe...@googlegroups.com

I’m using the ovftool post-processor because I also want to generate an OVA for use outside of vSphere. Are you saying I can still do that with the vSphere plugin?

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

--
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...@googlegroups.com.

 

--

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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CADg8VGrAioK_nKrQf1tEAwiYEPsY4cfM9SVeNMpgmDz5zCZT1Q%40mail.gmail.com.

Ayesha Sultana

unread,
May 8, 2018, 6:18:30 PM5/8/18
to packe...@googlegroups.com
Hello Aaron,

If you have other uses for OVA then its fine but if you exclusively using it to upload to vSphere then its not required as the vSphere post-processor uses the ovftool to convert the generated vmx and uploads it to the vCenter as a OVF Template (in vSphere Client you see it as a VM) and then the vSphere-teplate marks it as template.

Thanks

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.

--
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.

--
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.

--
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/993328A8-4A3E-47FC-A2E6-D19D189AE7F1%40longviewbits.com.
Reply all
Reply to author
Forward
0 new messages