7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rig/model/userdata.rb', line 7
def create(name, roles, environment, opts={ })
package = opts.delete(:package) || Rig.get_config(:userdata)
directory = "#{Rig::Config.dir}/userdata/#{package}"
config = YAML.load_file("#{directory}/userdata.yml")
data = {
:name => name,
:roles => roles,
:environment => environment,
:zone => Rig.get_config(:dns_zone),
:dependencies => [],
:gems => [],
:files => [],
:directory => directory,
:template => "userdata.sh.erb",
}.merge(config).merge(opts)
template = File.open("#{directory}/#{data[:template]}").read
erb = Erubis::Eruby.new(template)
out = erb.evaluate(data)
end
|