13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/vagrant-startcloud/action/load_config.rb', line 13
def call(env)
machine = env[:machine]
config = machine.config.startcloud
if config.config_path && File.file?(config.config_path)
yaml_config = YAML.load_file(config.config_path)
host = yaml_config['hosts']&.find do |h|
name = "#{h['settings']['server_id']}--#{h['settings']['hostname']}.#{h['settings']['domain']}"
name == machine.name.to_s
end
if host
config.settings = host['settings']
config.networks = host['networks'] || []
config.disks = host['disks'] || {}
config.provisioning = host['provisioning'] || {}
config.folders = host['folders'] || []
config.roles = host['roles'] || []
config.vars = host['vars'] || {}
config.plugins = host['plugins'] || {}
config.zones = host['zones'] || {}
env[:ui].info(I18n.t('vagrant_startcloud.config.loaded', name: machine.name))
else
env[:ui].warn(I18n.t('vagrant_startcloud.config.machine_not_found', name: machine.name))
end
else
env[:ui].warn(I18n.t('vagrant_startcloud.config.not_found', path: config.config_path))
end
@app.call(env)
end
|