Skip to content

VM Clone Examples

Dan Jellesma edited this page Nov 5, 2015 · 1 revision

VM Clone Examples

As of knife-vsphere 1.2 there are certain configuration combinations that appear to work better than others. This document will lay out some examples that users have had success with. Substitute with your own folder/file names. YMMV.

If you're having trouble cloning a template, try converting to a vm first, and leave it powered off. There seems to be no functional difference between a VM Template and a VM when cloning/deploying.

Cloning a Linux vm

Using Linux (vs Windows), features like --datastore and --linked-clone appear to work best. Tested with a CentOS 7 x64 VM.

Simple clone

knife vsphere vm clone \
  --random-vmname \
  --folder 'Templates/Linux' \
  --template 'tmpl_centos7_x64'
  --dest-folder 'Vms/Linux/Testing' \
  --resource-pool 'Cluster-Name/Normal' \
  --ccpu 1 \
  --cram 1 \
  --cspec 'cust_centos7_x64'

Clone to specified datastore / linked clone

knife vsphere vm clone \
  --random-vmname \
  --folder 'Templates/Linux' \
  --template 'tmpl_centos7_x64' \
  --dest-folder 'Vms/Linux/Testing' \
  --resource-pool 'Cluster-Name/Normal' \
  --ccpu 1 \
  --cram 1 \
  --datastore 'VM-Datastore-01' \
  --linked-clone \
  --cspec 'cust_centos7_x64'

Clone VM and Bootstrap Chef Client

knife vsphere vm clone \
  --random-vmname \
  --folder 'Templates/Linux' \
  --template 'tmpl_centos7_x64'
  --dest-folder 'Vms/Linux/Testing' \
  --resource-pool 'Cluster-Name/Normal' \
  --ccpu 1 \
  --cram 1 \
  --start \
  --distro chef-full \
  --ssh-user <USERNAME> \
  --ssh-password **** \
  --environment 'Linux' \
  --cspec 'cust_centos7_x64'

These examples are user submitted and not guaranteed to work in your environment. Please use them only as samples.