Project

General

Profile

Actions

Feature #2438

closed

Ability to deploy hosts from vmware templates

Added by Oliver Weinmann over 11 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Compute resources
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Hi,

it would be nice to deploy hosts from VMware templates to speedup the deployment process.

Regards,
Oliver


Related issues 2 (0 open2 closed)

Related to Foreman - Feature #5125: List available VMware imagesClosedTimo Goebel04/09/2014Actions
Has duplicate Foreman - Feature #2703: Create vmware virtual machines by cloning a templateDuplicate06/24/2013Actions
Actions #1

Updated by Jon McKenzie over 11 years ago

+1 to this. I work in an environment with multiple, disconnected LANs, so in many instances, I need to be able to provision from templates to reduce provisioning errors, reduce the chance that someone has changed something, not have to rely on network resources (that may be down), etc.

Actions #2

Updated by Jason Ashby about 11 years ago

I would love this functionality. Looks like rbvmomi, the gem used by Foreman to talk to VMware, has the ability to deploy from an OVF.

http://rdoc.info/github/rlane/rbvmomi/master/RbVmomi/VIM/OvfManager

So I think you could convert the VMware template to OVF format and make it accessible via http. I'm thinking:

- add new medium in Foreman pointing to my "golden" OVF.
- then I can create a new host in Foreman using the OVF as the source + any applicable fields.

I'm not sure how the kickstart portion would work in regards to setting up networking, etc... to get the new host handed off to puppet. Not sure you can configure the guest OS' network when deploying from OVF.

Anyone have any ideas, concerns? I'd be happy to work on this.

Actions #3

Updated by Jason Ashby about 11 years ago

You can mark this as a duplicate of http://projects.theforeman.org/issues/2703. I know 2703 is newer, but it has some better info and code to start with.

Actions #4

Updated by Dominic Cleal about 11 years ago

  • Has duplicate Feature #2703: Create vmware virtual machines by cloning a template added
Actions #5

Updated by Dominic Cleal about 11 years ago

  • Description updated (diff)
  • Category set to Compute resources

I kept this one as it's got more votes, thanks for pointing it out Jason. (But yes, do check the other issue for a script snippet.)

Actions #6

Updated by Jason Ashby about 11 years ago

Here is a script to launch a VM from a VMware template, allowing a static IP and networking to be set on the guest OS. This expands on Ronny's script in issue 2703.

#!/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

Side note: I had to change the guest OS setting on my CentOS 6 template to RHEL 6 due to CentOS guest customization not being supported in vSphere per the error below. You need to convert the template to a VM, change the guest OS to Red Hat, and convert back to a template and you're golden.

/usr/lib/ruby/gems/1.8/gems/rbvmomi-1.6.0/lib/rbvmomi/vim/Task.rb:11:in `wait_for_completion': UncustomizableGuest: Customization of the guest operating system 'centos64Guest' is not supported in this configuration. Microsoft Vista (TM) and Linux guests with Logical Volume Manager are supported only for recent ESX host and VMware Tools versions. Refer to vCenter documentation for supported configurations. (RbVmomi::Fault)
        from /usr/lib/ruby/gems/1.8/gems/fog-1.15.0/lib/fog/vsphere/requests/compute/vm_clone.rb:259:in `vm_clone'
        from ./fogtest.rb:46
Actions #7

Updated by Jason Ashby about 11 years ago

I'll see about incorporating this in Foreman. First, one should be able to retrieve a list of available templates from a compute resource and have that populate a drop-down in the deploy New Host view. I'm not sure if all the fields when deploying a new host in Foreman are applicable/supported by fog's vm_clone or even vSphere, so the functionality may be limited. Still, having this ability through Foreman to deploy a new host via template would be huge in my environment.

Actions #8

Updated by Dominic Cleal about 11 years ago

Thanks for looking into this Jason. You might want to investigate Foreman's image support, which allows you to associate a compute resource image with an operating system, so it's available to select on the new host form. CRs such as EC2 and OpenStack use this method, but we'll need to support both methods for VMware.

Actions #9

Updated by Jason Ashby about 11 years ago

Will do Dominic, thanks.

I'm running into an issue with fog where I can't deploy a VM to a different datacenter/resource pool other than where the template resides. Hopefully I'll get some info while I dig into this issue myself. Details on github:

https://github.com/fog/fog/issues/2233

Actions #10

Updated by Ronny M about 11 years ago

Beside (or instead of) a template selection drop-down menu I was thinking that it would be nice if vmware templates could be linked to an hosts selected OS version.
This way selecting, for example Redhat/CentOS 6.4 64bit OS for a host would default to a vmware template (rhel6_64bit) that is optimized for this OS version without the need of having to select a template from a drop-down menu. The drop-down menu could then be used to override a default or if no default template would exist for an OS version.

This minimizes the amount of configuration changes a user has to do for creating a host and could also prevent a maybe unnecessary selection of a wrong template for a configured/chosen OS version.

Actions #11

Updated by Rufus Post almost 11 years ago

I have a PR open for a basic implementation, looking for feedback and have more time to invest in this https://github.com/theforeman/foreman/pull/1183

Actions #12

Updated by Dominic Cleal almost 11 years ago

  • Status changed from New to Ready For Testing
  • Target version set to 1.9.2
Actions #13

Updated by Anonymous almost 11 years ago

  • Target version changed from 1.9.2 to 1.9.1
Actions #14

Updated by Anonymous almost 11 years ago

  • Target version changed from 1.9.1 to 1.9.0
Actions #15

Updated by Anonymous over 10 years ago

  • Target version changed from 1.9.0 to 1.8.4
Actions #16

Updated by Jean-Christophe Counio over 10 years ago

Hi,

This a a very good and needed feature, and I'd love to see that in 1.5.0.
Just a few comments :
- The PR actually doesn't use VmWare templates from what I tested. It requires one of the VMs in the list of 'Virtual Machines', which are actual VMs (that can be off) but not VmWare templates
- If the image VM is located in a folder, it fails since it it try to take it from the root. Moving the image VM to the root of the DataCenter solved the issue
- The image id to enter when creating the image is indeed the UUID. It's ok when you know it, but since the field is common to many cloud servers, the UI isn't explicit on this

Thanks

JC

Actions #17

Updated by Dominic Cleal over 10 years ago

This is very unlikely to land in Foreman 1.5 now as we're approaching feature freeze this week, and the PR still has issues as you noted. If anybody has the time to resurrect it and address the noted issues, that'd be much appreciated. We'd be happy to give guidance on the PR, foreman-dev mailing list or IRC channel.

Actions #18

Updated by Jean-Christophe Counio over 10 years ago

I commented with a way to make the clone work when image isn't in the root in the PR.
Using Vms instead of templates isn't a blocker, what is important is to be able to clone, it saves a lot of time (eg for us, 3-7 mns to clone, 30-40mns to create new VMs with OS).
Maybe it's worth to merge it for 1.5.0 and go on with new issues/PR to improve it, since this one is opened for a while.

Actions #19

Updated by Dominic Cleal over 10 years ago

  • Translation missing: en.field_release set to 4

Thanks for your input Jean-Christophe, it's been very helpful.

Actions #20

Updated by Dominic Cleal over 10 years ago

Actions #21

Updated by Rufus Post over 10 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF