Class: Ec2BootstrapGenerator
- Inherits:
-
Object
- Object
- Ec2BootstrapGenerator
- Defined in:
- lib/bigbang/ec2-git-bootstrap.rb
Instance Method Summary collapse
Instance Method Details
#generate_from_dir(path) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/bigbang/ec2-git-bootstrap.rb', line 2 def generate_from_dir(path) basedir = File.dirname(__FILE__) + "/../../" tmp=%x(mktemp -d /tmp/gen-ec2-userdata.XXXXX).strip %x(mkdir -p #{tmp}/data) %x(cp -r #{path}/* #{tmp}/data/) %x(cp #{basedir}/src/* #{tmp}) tmptar=%x(mktemp /tmp/gen-ec2-userdata.XXXXX.tar.gz).strip %x(tar -czf #{tmptar} -C #{tmp} .) File.new("#{basedir}/src/bootstrap.sh").read + File.new(tmptar).read end |
#generate_from_hash(h) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bigbang/ec2-git-bootstrap.rb', line 15 def generate_from_hash(h) tmp=%x(mktemp -d /tmp/gen-ec2-userdata.XXXXX).strip h.each_pair do |k,v| f = File.new("#{tmp}/#{k}", "w") f.write(v) f.close end generate_from_dir(tmp).tap do |r| %x(rm -fr #{tmp}) end end |