2014-03-25 39 views
4

我能夠讓工頭運行,並且能夠自動將VM部署到我的vCenter中,然後用puppet配置它們。工頭 - 從vmware模板克隆

無論如何,我得到了從模板中克隆虛擬機的需求。我來到下面的功能請求似乎還沒有實現:http://projects.theforeman.org/issues/2438

我真的很滿意webgui和整個實現 - 所以我很想得到提示來解決這個問題 - 也許調用一個腳本的地方克隆而不是再次部署? 有什麼地方可以自定義工頭中的構建過程來完成這個任務? 或者也許有一個腳本部署在某個地方?

如果這不是所有可能的 - 是否還有另一種工具可以推薦?

Thx很多爲您的幫助!

+0

也許可以用github.com/theforeman/foreman_hooks實現?有人有forman_hooks的經驗嗎? – roegi

回答

1

feature request已經在領班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