Question

I was able to get foreman running and I am able to auto deploy VMs to my vcenter and configure them with puppet afterwards.

Anyway, I got the requirement to clone VMs from templates. I came around the below feature request that does not seem to be implemented yet: http://projects.theforeman.org/issues/2438

I am really happy with the webgui and the whole implementation - so I would love to get hints to workaround this - maybe to call a script somewhere to clone instead of deploying again? Is there somewhere a possibility to customize the build process in foreman to get this done? Or maybe is there already a script to deploy somewhere?

If that is not at all possible - is there another tool you can recommend?

Thx a lot for your help!

Was it helpful?

Solution

That feature request has been half implemented in foreman 1.5. You can clone from another VM but not a template.

The linked issue had a script added that does the clone from template:

#!/usr/bin/ruby
require 'rubygems'
require 'fog'
require 'pp'

credentials = {
    :provider         => "vsphere",
    :vsphere_username => "myadminuser",
    :vsphere_password => "*********",
    :vsphere_server   => "vcenter.example.com",
    :vsphere_ssl      => true,
    :vsphere_expected_pubkey_hash => "89d0foof6e6aef34e1ed20ae04dffad48085355e6bfoo792e9435b5a4f1b3e9" 
}

connection = Fog::Compute.new(credentials)
puts "Connected to #{connection.vsphere_server} as #{connection.vsphere_username} (API version #{connection.vsphere_rev})" 

options = {
    'datacenter'    => 'Baltimore',
    'template_path' => '/centos_6_4',
    'power_on'      => true,
    'memoryMB'      => '1024',
    'network_label' => '172.18.2.x',
    'numCPUs'       => 2,
    'datastore'     => 'VM NFS Mount',
    'wait'          => true,
    'hostname'      => 'tester',
    'name'          => 'Tester',
    'customization_spec' => {
        'domain'     => 'example.com',
        'ipsettings' => {
            'ip'      => '172.18.2.10',
            'gateway' => ['172.18.2.1'],
            'subnetMask' => '255.255.255.0',
        },
     },
}

puts "Deploying new VM from template.  This may take a few minutes..." 
new_vm=connection.vm_clone(options)
pp new_vm
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top