4

我能够让工头运行,并且能够将虚拟机自动部署到我的 vcenter 并在之后使用 puppet 对其进行配置。

无论如何,我需要从模板中克隆虚拟机。我遇到了以下似乎尚未实现的功能请求:http ://projects.theforeman.org/issues/2438

我对 webgui 和整个实现非常满意 - 所以我很想得到解决这个问题的提示 - 也许在某处调用脚本来克隆而不是再次部署?是否有可能在工头中自定义构建过程来完成这项工作?或者也许已经有一个脚本可以部署在某个地方?

如果这根本不可能 - 您可以推荐其他工具吗?

非常感谢您的帮助!

4

1 回答 1

1

功能请求已在工头 1.5 中实现了一半。您可以从另一个 VM 克隆,但不能从模板克隆。

链接的问题添加了一个从模板克隆的脚本:

#!/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
于 2014-08-26T10:01:26.697 回答