mccloud 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +9 -5
- data/Gemfile.lock +1 -1
- data/bin/mccloud +39 -30
- data/lib/mccloud/command/bootstrap.rb +1 -1
- data/lib/mccloud/command/destroy.rb +3 -3
- data/lib/mccloud/command/init.rb +503 -3
- data/lib/mccloud/command/multi.rb +7 -0
- data/lib/mccloud/command/provision.rb +5 -2
- data/lib/mccloud/command/server.rb +10 -5
- data/lib/mccloud/command/ssh.rb +7 -1
- data/lib/mccloud/command/status.rb +14 -5
- data/lib/mccloud/command/up.rb +10 -11
- data/lib/mccloud/configurator/mccloud.rb +21 -1
- data/lib/mccloud/generators.rb +16 -3
- data/lib/mccloud/provisioner/chef_solo.rb +5 -2
- data/lib/mccloud/provisioner/puppet.rb +6 -2
- data/lib/mccloud/session.rb +13 -7
- data/lib/mccloud/templates/bootstrap-centos-rubysource-1.8.7.sh +26 -0
- data/lib/mccloud/templates/bootstrap-centos-rvm-1.8.7.sh +12 -0
- data/lib/mccloud/templates/bootstrap-centos-rvm-1.9.2.sh +12 -0
- data/lib/mccloud/templates/bootstrap-centos-rvm-ree-1.8.7.sh +12 -0
- data/lib/mccloud/templates/bootstrap-custom.sh +1 -0
- data/lib/mccloud/templates/bootstrap-ubuntu-rvm-1.8.7.sh +14 -0
- data/{ruby-bootstrap.sh → lib/mccloud/templates/bootstrap-ubuntu-system.sh} +1 -2
- data/lib/mccloud/util/iterator.rb +3 -4
- data/lib/mccloud/util/sshkey.rb +74 -0
- data/lib/mccloud/version.rb +1 -1
- data/mccloud.gemspec +1 -0
- metadata +13 -7
- data/lib/mccloud/templates/Mccloudfilet +0 -44
- data/ruby-bootstrap2.sh +0 -39
@@ -3,18 +3,17 @@ module Mccloud
|
|
3
3
|
module Util
|
4
4
|
def on_selected_machines(selection=nil)
|
5
5
|
if selection.nil? || selection == "all"
|
6
|
-
puts "no selection - all machines"
|
6
|
+
#puts "no selection - all machines"
|
7
7
|
@session.config.vms.each do |name,vm|
|
8
8
|
id=@all_servers["#{name}"]
|
9
9
|
vm=@session.config.vms[name]
|
10
|
-
|
11
|
-
|
10
|
+
yield id,vm
|
12
11
|
end
|
13
12
|
else
|
14
13
|
name=selection
|
15
14
|
id=@all_servers["#{name}"]
|
16
15
|
vm=@session.config.vms[name]
|
17
|
-
|
16
|
+
yield id,vm
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#Shameless copy of https://github.com/bensie/sshkey/raw/master/lib/sshkey.rb
|
2
|
+
# Make it 1.8 compatbible
|
3
|
+
|
4
|
+
require 'openssl'
|
5
|
+
require 'base64'
|
6
|
+
require 'digest/md5'
|
7
|
+
|
8
|
+
module Mccloud
|
9
|
+
module Util
|
10
|
+
|
11
|
+
class SSHKey
|
12
|
+
|
13
|
+
def self.generate(options = {})
|
14
|
+
SSHKey.new(OpenSSL::PKey::RSA.generate(2048).to_pem, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :key_object, :comment, :rsa_private_key, :rsa_public_key, :ssh_public_key, :fingerprint
|
18
|
+
|
19
|
+
def initialize(private_key, options = {})
|
20
|
+
@key_object = OpenSSL::PKey::RSA.new(private_key)
|
21
|
+
@comment = options[:comment] || ""
|
22
|
+
@rsa_private_key = @key_object.to_pem
|
23
|
+
@rsa_public_key = @key_object.public_key.to_pem
|
24
|
+
raw_ssh_public_key = ssh_public_key_conversion
|
25
|
+
|
26
|
+
# @ssh_public_key = ["ssh-rsa", Base64.strict_encode64(raw_ssh_public_key), @comment].join(" ").strip
|
27
|
+
|
28
|
+
@ssh_public_key = ["ssh-rsa", [raw_ssh_public_key].pack("m0").gsub(/\n/,''), @comment].join(" ").strip
|
29
|
+
@fingerprint = Digest::MD5.hexdigest(raw_ssh_public_key).gsub(/(.{2})(?=.)/, '\1:\2')
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# All data type encoding is defined in the section #5 of RFC #4251.
|
35
|
+
# String and mpint (multiple precision integer) types are encoded this way :
|
36
|
+
# 4-bytes word: data length (unsigned big-endian 32 bits integer)
|
37
|
+
# n bytes : binary representation of the data
|
38
|
+
|
39
|
+
# For instance, the "stringsh-rsa" string is encoded as the following byte array
|
40
|
+
# [0, 0, 0, 7, 's', 's', 'h', '-', 'r', 's', 'a']
|
41
|
+
def ssh_public_key_conversion
|
42
|
+
e = @key_object.public_key.e.to_i
|
43
|
+
n = @key_object.public_key.n.to_i
|
44
|
+
|
45
|
+
out = [0,0,0,7].pack("c*")
|
46
|
+
out += "ssh-rsa"
|
47
|
+
out += encode_unsigned_int_32(to_byte_array(e).length).pack("c*")
|
48
|
+
out += to_byte_array(e).pack("c*")
|
49
|
+
out += encode_unsigned_int_32(to_byte_array(n).length).pack("c*")
|
50
|
+
out += to_byte_array(n).pack("c*")
|
51
|
+
|
52
|
+
return out
|
53
|
+
end
|
54
|
+
|
55
|
+
def encode_unsigned_int_32(value)
|
56
|
+
out = []
|
57
|
+
out[0] = value >> 24 & 0xff
|
58
|
+
out[1] = value >> 16 & 0xff
|
59
|
+
out[2] = value >> 8 & 0xff
|
60
|
+
out[3] = value & 0xff
|
61
|
+
return out
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_byte_array(num)
|
65
|
+
result = []
|
66
|
+
begin
|
67
|
+
result << (num & 0xff)
|
68
|
+
num >>= 8
|
69
|
+
end until (num == 0 || num == -1) && (result.last[7] == num[7])
|
70
|
+
result.reverse
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/mccloud/version.rb
CHANGED
data/mccloud.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mccloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Patrick Debois
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-08 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -245,7 +245,14 @@ files:
|
|
245
245
|
- lib/mccloud/provisioner/vagrant/puppet_server.rb
|
246
246
|
- lib/mccloud/provisioner/vagrant/shell.rb
|
247
247
|
- lib/mccloud/session.rb
|
248
|
-
- lib/mccloud/templates/
|
248
|
+
- lib/mccloud/templates/Mccloudfile.erb
|
249
|
+
- lib/mccloud/templates/bootstrap-centos-rubysource-1.8.7.sh
|
250
|
+
- lib/mccloud/templates/bootstrap-centos-rvm-1.8.7.sh
|
251
|
+
- lib/mccloud/templates/bootstrap-centos-rvm-1.9.2.sh
|
252
|
+
- lib/mccloud/templates/bootstrap-centos-rvm-ree-1.8.7.sh
|
253
|
+
- lib/mccloud/templates/bootstrap-custom.sh
|
254
|
+
- lib/mccloud/templates/bootstrap-ubuntu-rvm-1.8.7.sh
|
255
|
+
- lib/mccloud/templates/bootstrap-ubuntu-system.sh
|
249
256
|
- lib/mccloud/type/forwarding.rb
|
250
257
|
- lib/mccloud/type/lb.rb
|
251
258
|
- lib/mccloud/type/vm.rb
|
@@ -253,10 +260,9 @@ files:
|
|
253
260
|
- lib/mccloud/util/platform.rb
|
254
261
|
- lib/mccloud/util/rsync.rb
|
255
262
|
- lib/mccloud/util/ssh.rb
|
263
|
+
- lib/mccloud/util/sshkey.rb
|
256
264
|
- lib/mccloud/version.rb
|
257
265
|
- mccloud.gemspec
|
258
|
-
- ruby-bootstrap.sh
|
259
|
-
- ruby-bootstrap2.sh
|
260
266
|
has_rdoc: true
|
261
267
|
homepage: http://github.com/jedi4ever/mccloud/
|
262
268
|
licenses: []
|
@@ -1,44 +0,0 @@
|
|
1
|
-
Mccloud::Config.run do |config|
|
2
|
-
# All Mccloud configuration is done here. For a detailed explanation
|
3
|
-
# and listing of configuration options, please view the documentation
|
4
|
-
# online.
|
5
|
-
|
6
|
-
config.mccloud.prefix="mccloud"
|
7
|
-
|
8
|
-
config.vm.define :web do |web_config|
|
9
|
-
web_config.vm.ami = "ami-cef405a7"
|
10
|
-
web_config.vm.provider="AWS"
|
11
|
-
|
12
|
-
#web_config.vm.provisioner=:chef_solo
|
13
|
-
#web_config.vm.provisioner=:puppet
|
14
|
-
|
15
|
-
web_config.vm.provider_options={
|
16
|
-
# ID = "ami-cef405a7" = x64 Ubuntu 10.10
|
17
|
-
:image_id => 'ami-cef405a7',
|
18
|
-
# Flavors
|
19
|
-
:flavor_id => 't1.micro',
|
20
|
-
#:flavor_id => 'm1.large',
|
21
|
-
:groups => %w(ec2securitygroup), :key_name => "ec2-keyname",
|
22
|
-
:availability_zone => "us-east-1b"
|
23
|
-
}
|
24
|
-
web_config.vm.forward_port("http", 80, 8080)
|
25
|
-
web_config.vm.user="ubuntu"
|
26
|
-
web_config.vm.bootstrap="ruby-bootstrap.sh"
|
27
|
-
web_config.vm.private_key="my-ec2-key.pem"
|
28
|
-
end
|
29
|
-
|
30
|
-
### Provisioners
|
31
|
-
config.vm.provision :puppet do |puppet|
|
32
|
-
puppet.pp_path = "/tmp/vagrant-puppet"
|
33
|
-
#puppet.manifests_path = "puppet/manifests"
|
34
|
-
#puppet.module_path = "puppet/modules"
|
35
|
-
puppet.manifest_file = "newbox.pp"
|
36
|
-
end
|
37
|
-
|
38
|
-
config.vm.provision :chef_solo do |chef|
|
39
|
-
chef.cookbooks_path = ["<your cookboopath>"]
|
40
|
-
chef.add_recipe("<some recipe>")
|
41
|
-
# You may also specify custom JSON attributes:
|
42
|
-
chef.json.merge!({})
|
43
|
-
end
|
44
|
-
end
|
data/ruby-bootstrap2.sh
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/bin/bash -ex
|
2
|
-
|
3
|
-
# redirecting output
|
4
|
-
# http://alestic.com/2010/12/ec2-user-data-output
|
5
|
-
#exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
|
6
|
-
|
7
|
-
apt-get -y update
|
8
|
-
apt-get -y upgrade
|
9
|
-
apt-get -y dist-upgrade
|
10
|
-
|
11
|
-
apt-get -y install git
|
12
|
-
|
13
|
-
# For CC compiler of ruby
|
14
|
-
apt-get -y install build-essential
|
15
|
-
|
16
|
-
# no such file to load -- zlib (LoadError)
|
17
|
-
# http://stackoverflow.com/questions/2441248/rvm-ruby-1-9-1-troubles
|
18
|
-
apt-get install -y zlib1g-dev libssl-dev libreadline5-dev libxml2-dev libsqlite3-dev
|
19
|
-
|
20
|
-
> /tmp/base-finished
|
21
|
-
|
22
|
-
#/.rvm/src/rvm/scripts/install: line 243: HOME: unbound variable
|
23
|
-
HOME="/root"
|
24
|
-
export HOME
|
25
|
-
|
26
|
-
# RVM
|
27
|
-
# http://rvm.beginrescueend.com/
|
28
|
-
#bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
|
29
|
-
bash < <( curl -L http://bit.ly/rvm-install-system-wide )
|
30
|
-
|
31
|
-
echo ". /usr/local/rvm" >> /etc/profile.d/rvm-system-wide
|
32
|
-
|
33
|
-
#
|
34
|
-
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
|
35
|
-
. /usr/local/rvm/scripts/rvm
|
36
|
-
|
37
|
-
rvm install 1.9.2
|
38
|
-
rvm use 1.9.2 --default
|
39
|
-
|