Class: Nucleon::Extension::Vagrant

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleon/extension/vagrant.rb

Instance Method Summary collapse

Instance Method Details

#network_new_node_config(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nucleon/extension/vagrant.rb', line 6

def network_new_node_config(config)
  plugin   = config[:plugin]
  provider = plugin.plugin_provider

  if provider == :vagrant
    image_name   = string(config.delete(:image))
    machine_type = symbol(config.delete(:machine_type))
    hostname     = string(config[:hostname])

    public_ip    = string(config.delete(:public_ip))

    case machine_type
    when :docker
      config.set([ :vm, :providers, :docker, :image ], image_name)
    else
      config.set([ :vm, :providers, machine_type, :private_network ], public_ip) if public_ip
      config.set([ :vm, :providers, machine_type, :override, :vm, :box ], image_name)
    end

    config.set([ :vm, :providers, :docker, :create_args ], [ "--hostname='#{hostname}'" ])
  end
end