Class: KnifeLxc::LxcServerCreate

Inherits:
Chef::Knife
  • Object
show all
Includes:
Cucumber::Chef::Handy, Toft
Defined in:
lib/chef/knife/lxc_server_create.rb

Instance Method Summary collapse

Instance Method Details

#runObject

This method will be executed when you run this knife command.



39
40
41
42
43
44
45
46
# File 'lib/chef/knife/lxc_server_create.rb', line 39

def run
  puts "Creating lxc container '#{config[:node_name]}' with ip '#{config[:node_ip]}' from template '#{config[:distro]}'"
  node = create_node config[:node_name], {:ip => config[:node_ip], :type => config[:distro]}
  start_node node
  puts "Run chef client with run list: #{config[:run_list].join(' ')}"
  run_chef node, config[:run_list], config[:environment]
  puts "Node created! Details: ip => #{node.ip}, name => #{node.hostname} "
end