madeira 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/bin/madeira +22 -0
- data/ext/bootstrap.rb +19 -0
- data/ext/tasks/apt.rb +32 -0
- data/ext/tasks/puppet.rb +32 -0
- data/lib/madeira.rb +10 -2
- data/lib/madeira/provider.rb +1 -0
- data/lib/madeira/provider/ec2.rb +62 -0
- data/lib/madeira/provisioner/capistrano.rb +25 -0
- data/lib/madeira/ui/bootstrap_command.rb +20 -0
- data/lib/madeira/ui/create_command.rb +48 -0
- data/lib/madeira/ui/global_command.rb +10 -0
- data/lib/madeira/ui/terminate_command.rb +18 -0
- data/lib/madeira/version.rb +3 -0
- data/madeira.gemspec +27 -0
- data/madeira.rdoc +134 -0
- metadata +121 -18
- data/README.md +0 -8
- data/Rakefile +0 -6
- data/lib/madeira/provisioner.rb +0 -7
- data/lib/madeira/provisioner/ec2.rb +0 -72
- data/lib/madeira/tasks.rb +0 -27
data/Gemfile
ADDED
data/bin/madeira
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'gli'
|
4
|
+
require 'madeira'
|
5
|
+
|
6
|
+
include GLI::App
|
7
|
+
|
8
|
+
program_desc <<DESC
|
9
|
+
create and terminate VMs in the cloud and bootstrap your favourite CM tool (puppet, chef etc)
|
10
|
+
DESC
|
11
|
+
|
12
|
+
config_file 'madeira/config.yaml'
|
13
|
+
|
14
|
+
commands_from('madeira/ui')
|
15
|
+
|
16
|
+
on_error do |exception|
|
17
|
+
# Error logic here
|
18
|
+
# return false to skip default error handling
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
exit run(ARGV)
|
data/ext/bootstrap.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#FIXME: find better way of setting the paths to the required tasks
|
2
|
+
#
|
3
|
+
require "#{ENV['HOME']}/madeira/tasks/apt"
|
4
|
+
require "#{ENV['HOME']}/madeira/tasks/puppet"
|
5
|
+
|
6
|
+
|
7
|
+
set :user, 'ubuntu'
|
8
|
+
set :ssh_options, { :forward_agent => true }
|
9
|
+
|
10
|
+
#FIXME: how to get madeira ask for sudo password ?
|
11
|
+
set :use_sudo, true
|
12
|
+
|
13
|
+
ssh_options[:keys] = "~/.ssh/ec2/aws-sydney.pem"
|
14
|
+
|
15
|
+
|
16
|
+
task :bootstrap do
|
17
|
+
aptupgrade
|
18
|
+
puppet_client
|
19
|
+
end
|
data/ext/tasks/apt.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
desc <<-DESC
|
3
|
+
noninteractive apt-get upgrade.
|
4
|
+
|
5
|
+
This task will complete an 'apt-get update' and then an 'apt-get upgrade'
|
6
|
+
|
7
|
+
*WARNING* the following flags are passed to 'apt-get upgrade'
|
8
|
+
|
9
|
+
* DEBIAN_FRONTEND=noninteractive
|
10
|
+
* --yes
|
11
|
+
|
12
|
+
Options:
|
13
|
+
|
14
|
+
HOSTFILTER='fqdn' # fqdn of host to upgrade
|
15
|
+
ROLES='web' # group of hosts to upgrade
|
16
|
+
FORCE=true # add --allow-unauthenticated for unsigned packages
|
17
|
+
|
18
|
+
Examples:
|
19
|
+
|
20
|
+
cap node:aptupgrade HOSTS='foo.example.com'
|
21
|
+
cap node:aptupgrade HOSTFILTER='foo.example.com' FORCE=true
|
22
|
+
|
23
|
+
DESC
|
24
|
+
task :aptupgrade do
|
25
|
+
run "#{sudo} apt-get update -yq"
|
26
|
+
if ENV['FORCE']
|
27
|
+
run "#{sudo} DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes --allow-unauthenticated"
|
28
|
+
else
|
29
|
+
run "#{sudo} DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes --quiet"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/ext/tasks/puppet.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
desc 'bootstrap puppet client.'
|
3
|
+
task :puppet_client do
|
4
|
+
#puts "Bootstrapping new Puppet client".green
|
5
|
+
# clean the slate
|
6
|
+
run "#{sudo} aptitude purge -y ~npuppet libaugeas-ruby ~nrubygems"
|
7
|
+
run "#{sudo} rm -rf /etc/puppet"
|
8
|
+
#
|
9
|
+
# add puppetlabs apt repos
|
10
|
+
filename = "/etc/apt/sources.list.d/puppetlabs.list"
|
11
|
+
run "echo 'deb http://apt.puppetlabs.com/ precise main' | #{sudo} tee #{filename}"
|
12
|
+
run "#{sudo} apt-key adv --keyserver keyserver.ubuntu.com --recv 4BD6EC30"
|
13
|
+
run "#{sudo} apt-get -yq update"
|
14
|
+
#
|
15
|
+
run "#{sudo} apt-get install -yq ruby ruby1.8 rubygems libaugeas-ruby git"
|
16
|
+
run "#{sudo} apt-get install -yq puppet=2.7.20-1puppetlabs1 puppet-common=2.7.20-1puppetlabs1"
|
17
|
+
|
18
|
+
# Prep puppet.conf so the first Puppet run works.
|
19
|
+
puppet_dot_conf = <<-END.gsub(/^ {8}/, '')
|
20
|
+
[main]
|
21
|
+
logdir=/var/log/puppet
|
22
|
+
vardir=/var/lib/puppet
|
23
|
+
ssldir=/var/lib/puppet/ssl
|
24
|
+
rundir=/var/run/puppet
|
25
|
+
factpath=$vardir/lib/facter
|
26
|
+
templatedir=$confdir/templates
|
27
|
+
pluginsync=true
|
28
|
+
END
|
29
|
+
put puppet_dot_conf, "/tmp/puppet.conf.new"
|
30
|
+
run "#{sudo} cp /tmp/puppet.conf.new /etc/puppet/puppet.conf"
|
31
|
+
end
|
32
|
+
end
|
data/lib/madeira.rb
CHANGED
@@ -1,2 +1,10 @@
|
|
1
|
-
require 'madeira/
|
2
|
-
require 'madeira/
|
1
|
+
require 'madeira/version'
|
2
|
+
require 'madeira/provider'
|
3
|
+
require 'madeira/provisioner/capistrano'
|
4
|
+
|
5
|
+
# Add requires for other files you add to your project here, so
|
6
|
+
# you just need to require this one file in your bin file
|
7
|
+
|
8
|
+
require 'pp'
|
9
|
+
require 'fog'
|
10
|
+
require 'table_print'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'madeira/provider/ec2'
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Madeira
|
2
|
+
module Provider
|
3
|
+
module EC2
|
4
|
+
extend self
|
5
|
+
|
6
|
+
# use fog to talk to AWS/ec2
|
7
|
+
#
|
8
|
+
def create(options={})
|
9
|
+
# check all required fog creds are supplied
|
10
|
+
#TODO: #validate_creds(options)
|
11
|
+
|
12
|
+
# connect to ec2
|
13
|
+
#
|
14
|
+
connect(options)
|
15
|
+
|
16
|
+
# create an instance
|
17
|
+
#
|
18
|
+
server = @fog.servers.create(
|
19
|
+
:image_id => options[:ami],
|
20
|
+
:flavor_id => options[:size],
|
21
|
+
:key_name => options[:keypair],
|
22
|
+
:groups => options[:security],
|
23
|
+
:tags => { 'Name' => options[:name] }
|
24
|
+
)
|
25
|
+
|
26
|
+
# print progress as dots whilst waiting for it to get online
|
27
|
+
#
|
28
|
+
server.wait_for { print "."; ready? }
|
29
|
+
puts
|
30
|
+
tp server, :id, {:dns_name => {:width => 65}}, :public_ip_address, :private_ip_address, :tags, :flavor_id, :key_name, :security_group_ids
|
31
|
+
server.dns_name
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# terminate an instance
|
36
|
+
#
|
37
|
+
def terminate(options)
|
38
|
+
# connect to ec2
|
39
|
+
#
|
40
|
+
connect(options)
|
41
|
+
|
42
|
+
instances = @fog.servers.all
|
43
|
+
instance = instances.select {|i| i.dns_name == options[:dns_name] }
|
44
|
+
instance[0].destroy
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
# create connection to AWS
|
50
|
+
# returns @fog object.
|
51
|
+
#
|
52
|
+
def connect(options={})
|
53
|
+
@fog ||= Fog::Compute.new(
|
54
|
+
:provider => 'aws',
|
55
|
+
:region => options[:region],
|
56
|
+
:aws_access_key_id => options[:aws_access_key_id],
|
57
|
+
:aws_secret_access_key => options[:aws_secret_access_key]
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'capistrano/cli'
|
3
|
+
|
4
|
+
module Madeira
|
5
|
+
module Provisioner
|
6
|
+
module Capistrano
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def bootstrap(opts={})
|
10
|
+
config = ::Capistrano::Configuration.new
|
11
|
+
config.logger.level = ::Capistrano::Logger::TRACE
|
12
|
+
config.load "#{ENV['HOME']}/madeira/bootstrap.rb"
|
13
|
+
|
14
|
+
config.default_run_options[:pty] = true
|
15
|
+
|
16
|
+
#TODO: find better way of parsing options to cap tasks
|
17
|
+
#
|
18
|
+
ENV['HOSTS'] = opts[:dns_name]
|
19
|
+
|
20
|
+
puts "\nbootstrapping #{ENV['HOSTS']}....."
|
21
|
+
config.bootstrap
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
desc 'bootstrap an instance'
|
2
|
+
long_desc '''
|
3
|
+
This will run all of the capistrano tasks declared in $HOME/madeira/bootstrap.rb
|
4
|
+
'''
|
5
|
+
command :bootstrap do |c|
|
6
|
+
|
7
|
+
c.desc 'dns_name of instance to bootstrap'
|
8
|
+
c.long_desc 'What is the name of the instance you wish to bootstrap - eg: ec2-54-253-9-16.ap-southeast-2.compute.amazonaws.com'
|
9
|
+
c.flag :dns_name
|
10
|
+
|
11
|
+
c.desc 'EC2 region'
|
12
|
+
c.long_desc 'Which EC2 region ?'
|
13
|
+
c.default_value 'ap-southeast-2'
|
14
|
+
c.flag :region
|
15
|
+
|
16
|
+
c.action do |global_options, options, args|
|
17
|
+
opts=global_options.merge(options)
|
18
|
+
Madeira::Provisioner::Capistrano.bootstrap(opts)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
desc 'create a new instance'
|
2
|
+
command :create do |c|
|
3
|
+
|
4
|
+
c.desc 'ami id to use'
|
5
|
+
c.default_value 'ami-fb8611c1'
|
6
|
+
c.flag :ami
|
7
|
+
|
8
|
+
c.desc 'keypair to use'
|
9
|
+
c.long_desc 'What keypair to use for connecting to this instance ?'
|
10
|
+
c.default_value 'general'
|
11
|
+
c.flag :keypair
|
12
|
+
|
13
|
+
c.desc 'security group to apply'
|
14
|
+
c.long_desc 'What securoty group to add to this instance. Currently only one is supported.'
|
15
|
+
c.default_value 'default'
|
16
|
+
c.flag :security
|
17
|
+
|
18
|
+
c.desc 'size of instance'
|
19
|
+
c.default_value 't1.micro'
|
20
|
+
c.flag :size
|
21
|
+
|
22
|
+
c.desc 'EC2 region'
|
23
|
+
c.long_desc 'Which EC2 region do you want to bring up an instance in ?'
|
24
|
+
c.default_value 'ap-southeast-2'
|
25
|
+
c.flag :region
|
26
|
+
|
27
|
+
c.desc 'instance name'
|
28
|
+
c.long_desc 'Friendly name to display in AWS console'
|
29
|
+
c.flag :name
|
30
|
+
|
31
|
+
c.desc 'bootstrap host'
|
32
|
+
c.long_desc 'whether to bootstrap new instance or not.'
|
33
|
+
c.default_value true
|
34
|
+
c.switch :bootstrap
|
35
|
+
|
36
|
+
c.action do |global_options, options, args|
|
37
|
+
opts=global_options.merge(options)
|
38
|
+
dns_name = Madeira::Provider::EC2.create(opts)
|
39
|
+
if opts[:bootstrap]
|
40
|
+
#FIXME: use Fog's server.ready? method before continuing
|
41
|
+
#
|
42
|
+
sleep(20)
|
43
|
+
Madeira::Provisioner::Capistrano.bootstrap(opts.merge(:dns_name => dns_name))
|
44
|
+
else
|
45
|
+
puts "NOT bootstrapping #{dns_name}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
desc 'terminate an instance'
|
2
|
+
command :terminate do |c|
|
3
|
+
|
4
|
+
c.desc 'dns_name of instance to terminate'
|
5
|
+
c.long_desc 'What is the name of the instance you wish to terminate - eg: ec2-54-253-9-16.ap-southeast-2.compute.amazonaws.com'
|
6
|
+
c.flag :dns_name
|
7
|
+
|
8
|
+
c.desc 'EC2 region'
|
9
|
+
c.long_desc 'Which EC2 region ?'
|
10
|
+
c.default_value 'ap-southeast-2'
|
11
|
+
c.flag :region
|
12
|
+
|
13
|
+
c.action do |global_options, options, args|
|
14
|
+
opts=global_options.merge(options)
|
15
|
+
#TODO: confirm before terminating (highline)
|
16
|
+
Madeira::Provider::EC2.terminate(opts)
|
17
|
+
end
|
18
|
+
end
|
data/madeira.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
require File.join([File.dirname(__FILE__),'lib','madeira','version.rb'])
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = 'madeira'
|
6
|
+
s.version = Madeira::VERSION
|
7
|
+
s.author = 'Mick Pollard'
|
8
|
+
s.email = 'aussielunix@gmail.com'
|
9
|
+
s.homepage = 'http://aussie.lunix.com.au'
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.summary = 'madeira is for creating, terminating and bootstrapping VMs (cloud instances).'
|
12
|
+
# Add your other files here if you make them
|
13
|
+
s.files = Dir['Gemfile', 'madeira.gemspec', '{bin,lib,ext}/**/**']
|
14
|
+
s.require_paths << 'lib'
|
15
|
+
s.has_rdoc = true
|
16
|
+
s.extra_rdoc_files = ['madeira.rdoc']
|
17
|
+
s.rdoc_options << '--title' << 'madeira' << '--main' << '-ri'
|
18
|
+
s.bindir = 'bin'
|
19
|
+
s.executables << 'madeira'
|
20
|
+
s.add_development_dependency('rake')
|
21
|
+
s.add_development_dependency('rdoc')
|
22
|
+
s.add_development_dependency('aruba')
|
23
|
+
s.add_runtime_dependency('gli','2.5.5')
|
24
|
+
s.add_runtime_dependency('fog','1.10.0')
|
25
|
+
s.add_runtime_dependency('table_print')
|
26
|
+
s.add_runtime_dependency('capistrano')
|
27
|
+
end
|
data/madeira.rdoc
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
== madeira - create and terminate VMs in the cloud and bootstrap your favourite CM tool (puppet, chef etc)
|
2
|
+
|
3
|
+
|
4
|
+
=== Global Options
|
5
|
+
=== --aws_access_key_id arg
|
6
|
+
|
7
|
+
aws access key id
|
8
|
+
|
9
|
+
[Default Value] None
|
10
|
+
|
11
|
+
|
12
|
+
=== --aws_secret_access_key arg
|
13
|
+
|
14
|
+
aws_secret_access_key
|
15
|
+
|
16
|
+
[Default Value] None
|
17
|
+
|
18
|
+
|
19
|
+
=== --help
|
20
|
+
Show this message
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
=== --verbose|-v
|
25
|
+
verbose
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
=== Commands
|
30
|
+
==== Command: <tt>bootstrap </tt>
|
31
|
+
bootstrap an instance
|
32
|
+
|
33
|
+
This will run all of the capistrano tasks declared in $HOME/madeira/bootstrap.rb
|
34
|
+
===== Options
|
35
|
+
===== --dns_name arg
|
36
|
+
|
37
|
+
dns_name of instance to bootstrap
|
38
|
+
|
39
|
+
[Default Value] None
|
40
|
+
What is the name of the instance you wish to bootstrap - eg: ec2-54-253-9-16.ap-southeast-2.compute.amazonaws.com
|
41
|
+
|
42
|
+
===== --region arg
|
43
|
+
|
44
|
+
EC2 region
|
45
|
+
|
46
|
+
[Default Value] ap-southeast-2
|
47
|
+
Which EC2 region ?
|
48
|
+
|
49
|
+
==== Command: <tt>create </tt>
|
50
|
+
create a new instance
|
51
|
+
|
52
|
+
|
53
|
+
===== Options
|
54
|
+
===== --ami arg
|
55
|
+
|
56
|
+
ami id to use
|
57
|
+
|
58
|
+
[Default Value] ami-fb8611c1
|
59
|
+
|
60
|
+
|
61
|
+
===== --keypair arg
|
62
|
+
|
63
|
+
keypair to use
|
64
|
+
|
65
|
+
[Default Value] general
|
66
|
+
What keypair to use for connecting to this instance ?
|
67
|
+
|
68
|
+
===== --name arg
|
69
|
+
|
70
|
+
instance name
|
71
|
+
|
72
|
+
[Default Value] None
|
73
|
+
Friendly name to display in AWS console
|
74
|
+
|
75
|
+
===== --region arg
|
76
|
+
|
77
|
+
EC2 region
|
78
|
+
|
79
|
+
[Default Value] ap-southeast-2
|
80
|
+
Which EC2 region do you want to bring up an instance in ?
|
81
|
+
|
82
|
+
===== --security arg
|
83
|
+
|
84
|
+
security group to apply
|
85
|
+
|
86
|
+
[Default Value] default
|
87
|
+
What securoty group to add to this instance. Currently only one is supported.
|
88
|
+
|
89
|
+
===== --size arg
|
90
|
+
|
91
|
+
size of instance
|
92
|
+
|
93
|
+
[Default Value] t1.micro
|
94
|
+
|
95
|
+
|
96
|
+
==== Command: <tt>help command</tt>
|
97
|
+
Shows a list of commands or help for one command
|
98
|
+
|
99
|
+
Gets help for the application or its commands. Can also list the commands in a way helpful to creating a bash-style completion function
|
100
|
+
===== Options
|
101
|
+
===== -c
|
102
|
+
List commands one per line, to assist with shell completion
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
==== Command: <tt>initconfig </tt>
|
107
|
+
Initialize the config file using current global options
|
108
|
+
|
109
|
+
Initializes a configuration file where you can set default options for command line flags, both globally and on a per-command basis. These defaults override the built-in defaults and allow you to omit commonly-used command line flags when invoking this program
|
110
|
+
===== Options
|
111
|
+
===== --[no-]force
|
112
|
+
force overwrite of existing config file
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
==== Command: <tt>terminate </tt>
|
117
|
+
terminate an instance
|
118
|
+
|
119
|
+
|
120
|
+
===== Options
|
121
|
+
===== --dns_name arg
|
122
|
+
|
123
|
+
dns_name of instance to terminate
|
124
|
+
|
125
|
+
[Default Value] None
|
126
|
+
What is the name of the instance you wish to terminate - eg: ec2-54-253-9-16.ap-southeast-2.compute.amazonaws.com
|
127
|
+
|
128
|
+
===== --region arg
|
129
|
+
|
130
|
+
EC2 region
|
131
|
+
|
132
|
+
[Default Value] ap-southeast-2
|
133
|
+
Which EC2 region ?
|
134
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madeira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,26 +9,42 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
-
type: :
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: rdoc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: aruba
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
33
49
|
none: false
|
34
50
|
requirements:
|
@@ -43,40 +59,127 @@ dependencies:
|
|
43
59
|
- - ! '>='
|
44
60
|
- !ruby/object:Gem::Version
|
45
61
|
version: '0'
|
46
|
-
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: gli
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.5.5
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.5.5
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: fog
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.10.0
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.10.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: table_print
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: capistrano
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description:
|
47
127
|
email: aussielunix@gmail.com
|
48
|
-
executables:
|
128
|
+
executables:
|
129
|
+
- madeira
|
49
130
|
extensions: []
|
50
|
-
extra_rdoc_files:
|
131
|
+
extra_rdoc_files:
|
132
|
+
- madeira.rdoc
|
51
133
|
files:
|
52
|
-
-
|
53
|
-
-
|
134
|
+
- Gemfile
|
135
|
+
- madeira.gemspec
|
136
|
+
- bin/madeira
|
54
137
|
- lib/madeira.rb
|
55
|
-
- lib/madeira/
|
56
|
-
- lib/madeira/
|
57
|
-
- lib/madeira/
|
58
|
-
|
138
|
+
- lib/madeira/ui/terminate_command.rb
|
139
|
+
- lib/madeira/ui/bootstrap_command.rb
|
140
|
+
- lib/madeira/ui/global_command.rb
|
141
|
+
- lib/madeira/ui/create_command.rb
|
142
|
+
- lib/madeira/provisioner/capistrano.rb
|
143
|
+
- lib/madeira/provider.rb
|
144
|
+
- lib/madeira/provider/ec2.rb
|
145
|
+
- lib/madeira/version.rb
|
146
|
+
- ext/tasks/apt.rb
|
147
|
+
- ext/tasks/puppet.rb
|
148
|
+
- ext/bootstrap.rb
|
149
|
+
- madeira.rdoc
|
150
|
+
homepage: http://aussie.lunix.com.au
|
59
151
|
licenses: []
|
60
152
|
post_install_message:
|
61
|
-
rdoc_options:
|
153
|
+
rdoc_options:
|
154
|
+
- --title
|
155
|
+
- madeira
|
156
|
+
- --main
|
157
|
+
- -ri
|
62
158
|
require_paths:
|
63
159
|
- lib
|
160
|
+
- lib
|
64
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
65
162
|
none: false
|
66
163
|
requirements:
|
67
164
|
- - ! '>='
|
68
165
|
- !ruby/object:Gem::Version
|
69
166
|
version: '0'
|
167
|
+
segments:
|
168
|
+
- 0
|
169
|
+
hash: -649789194035628970
|
70
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
171
|
none: false
|
72
172
|
requirements:
|
73
173
|
- - ! '>='
|
74
174
|
- !ruby/object:Gem::Version
|
75
175
|
version: '0'
|
176
|
+
segments:
|
177
|
+
- 0
|
178
|
+
hash: -649789194035628970
|
76
179
|
requirements: []
|
77
180
|
rubyforge_project:
|
78
181
|
rubygems_version: 1.8.23
|
79
182
|
signing_key:
|
80
183
|
specification_version: 3
|
81
|
-
summary:
|
184
|
+
summary: madeira is for creating, terminating and bootstrapping VMs (cloud instances).
|
82
185
|
test_files: []
|
data/README.md
DELETED
data/Rakefile
DELETED
data/lib/madeira/provisioner.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'fog'
|
2
|
-
require 'capistrano'
|
3
|
-
|
4
|
-
module Madeira
|
5
|
-
module Provisioner
|
6
|
-
module EC2
|
7
|
-
|
8
|
-
# create a new ec2 instance
|
9
|
-
#
|
10
|
-
def self.create(options={})
|
11
|
-
# connect to ec2
|
12
|
-
#
|
13
|
-
connect(options)
|
14
|
-
|
15
|
-
# create an instance
|
16
|
-
#
|
17
|
-
server = @fog.servers.create(
|
18
|
-
:image_id => options[:image_id],
|
19
|
-
:flavor_id => options[:flavor_id],
|
20
|
-
:key_name => options[:key_name]
|
21
|
-
)
|
22
|
-
|
23
|
-
# print progress as dots whilst waiting for it to get online
|
24
|
-
#
|
25
|
-
server.wait_for { print "."; ready? }
|
26
|
-
puts "instance started as #{server.dns_name}"
|
27
|
-
ec2_address(server.dns_name)
|
28
|
-
end
|
29
|
-
|
30
|
-
# terminate ec2 instance
|
31
|
-
#
|
32
|
-
def self.terminate(options={})
|
33
|
-
# connect to ec2
|
34
|
-
#
|
35
|
-
connect(options)
|
36
|
-
|
37
|
-
if server = @fog.servers.detect{ |s| s.dns_name == ec2_address }
|
38
|
-
puts "Terminating #{server.dns_name}"
|
39
|
-
server.destroy
|
40
|
-
else
|
41
|
-
puts "Appliance not found or not running"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
# create connection to AWS
|
48
|
-
# returns @fog object.
|
49
|
-
#
|
50
|
-
def self.connect(options={})
|
51
|
-
@fog ||= Fog::Compute.new(
|
52
|
-
:provider => options[:provider] || 'AWS',
|
53
|
-
:region => options[:region],
|
54
|
-
:aws_access_key_id => options[:aws_access_key_id],
|
55
|
-
:aws_secret_access_key => options[:aws_secret_access_key]
|
56
|
-
)
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
# write out the ec2 address to a local file
|
61
|
-
#
|
62
|
-
def self.ec2_address(input='get')
|
63
|
-
file = 'ec2.hostname'
|
64
|
-
if input == 'get'
|
65
|
-
(File.read(file) rescue 'NO-SERVER').strip
|
66
|
-
else
|
67
|
-
File.open(file,'w'){|f|f.write(input)}
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
data/lib/madeira/tasks.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
-
namespace :instance do
|
3
|
-
namespace :ec2 do
|
4
|
-
desc 'provision a new ec2 instance'
|
5
|
-
task :create do
|
6
|
-
server = Madeira::Provisioner::EC2.create(
|
7
|
-
:image_id => image_id,
|
8
|
-
:flavor_id => flavor_id,
|
9
|
-
:key_name => key_name,
|
10
|
-
:region => region,
|
11
|
-
:aws_access_key_id => aws_access_key_id,
|
12
|
-
:aws_secret_access_key => aws_secret_access_key
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'terminate your t1.micro at ec2'
|
17
|
-
task :terminate do
|
18
|
-
Madeira::Provisioner::EC2.terminate(
|
19
|
-
:key_name => key_name,
|
20
|
-
:region => region,
|
21
|
-
:aws_access_key_id => aws_access_key_id,
|
22
|
-
:aws_secret_access_key => aws_secret_access_key
|
23
|
-
)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|