veronic 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/config/config.rb +30 -30
- data/lib/providers/chefserver/chefserver.rb +10 -10
- data/lib/providers/chefserver/instance.rb +50 -50
- data/lib/providers/ec2/ec2.rb +8 -7
- data/lib/providers/ec2/image.rb +18 -17
- data/lib/veronic.rb +1 -1
- data/veronic.gemspec +1 -1
- metadata +2 -1
data/lib/config/config.rb
CHANGED
@@ -6,36 +6,36 @@ module Veronic
|
|
6
6
|
config_file = File.exists?('/etc/veronic/veronic.yml') ? '/etc/veronic/veronic.yml' : '../../' + File.dirname($0) + '/veronic.yml'
|
7
7
|
config_from_file = YAML.load_file(options[:config_file] || config_file)
|
8
8
|
|
9
|
-
@dnsprovider
|
10
|
-
@cloudprovider
|
11
|
-
@configprovider
|
12
|
-
@dnsprovider_access_key_id
|
13
|
-
@dnsprovider_secret_access_key
|
14
|
-
@dnsprovider_zones
|
15
|
-
@cloudprovider_access_key_id
|
16
|
-
@cloudprovider_secret_access_key
|
17
|
-
@cloudprovider_images_owner_id
|
18
|
-
@region
|
19
|
-
@availability_zone
|
20
|
-
@aws_ssh_key_id
|
21
|
-
@node_name
|
22
|
-
@client_key
|
23
|
-
@validation_client_name
|
24
|
-
@validation_key
|
25
|
-
@chef_server_url
|
26
|
-
@ssl_version
|
27
|
-
@identity_file
|
28
|
-
@branch
|
29
|
-
@environment
|
30
|
-
@ssh_user
|
31
|
-
@ssh_port
|
32
|
-
@role
|
33
|
-
@flavor
|
34
|
-
@security_groups
|
35
|
-
@deploy_cmd
|
36
|
-
@name
|
37
|
-
@image
|
38
|
-
@verbose
|
9
|
+
@dnsprovider = :route53
|
10
|
+
@cloudprovider = :ec2
|
11
|
+
@configprovider = :chefserver
|
12
|
+
@dnsprovider_access_key_id = options[:dnsprovider_access_key_id] || config_from_file['dnsprovider_access_key_id']
|
13
|
+
@dnsprovider_secret_access_key = options[:dnsprovider_secret_access_key] || config_from_file['dnsprovider_secret_access_key']
|
14
|
+
@dnsprovider_zones = options[:dnsprovider_zones] || config_from_file['dnsprovider_zones']
|
15
|
+
@cloudprovider_access_key_id = options[:cloudprovider_access_key_id] || config_from_file['cloudprovider_access_key_id']
|
16
|
+
@cloudprovider_secret_access_key = options[:cloudprovider_secret_access_key] || config_from_file['cloudprovider_secret_access_key']
|
17
|
+
@cloudprovider_images_owner_id = options[:cloudprovider_images_owner_id] || config_from_file['cloudprovider_images_owner_id']
|
18
|
+
@region = options[:region] || config_from_file['region']
|
19
|
+
@availability_zone = options[:availability_zone] || config_from_file['availability_zone']
|
20
|
+
@aws_ssh_key_id = options[:aws_ssh_key_id] || config_from_file['aws_ssh_key_id']
|
21
|
+
@node_name = options[:node_name] || config_from_file['node_name']
|
22
|
+
@client_key = options[:client_key] || config_from_file['client_key']
|
23
|
+
@validation_client_name = options[:validation_client_name] || config_from_file['validation_client_name']
|
24
|
+
@validation_key = options[:validation_key] || config_from_file['validation_key']
|
25
|
+
@chef_server_url = options[:chef_server_url] || config_from_file['chef_server_url']
|
26
|
+
@ssl_version = options[:ssl_version] || config_from_file['ssl_version']
|
27
|
+
@identity_file = options[:identity_file] || config_from_file['identity_file']
|
28
|
+
@branch = options[:branch] || config_from_file['branch']
|
29
|
+
@environment = options[:environment] || config_from_file['environment']
|
30
|
+
@ssh_user = options[:ssh_user] || config_from_file['ssh_user'] || 'ubuntu'
|
31
|
+
@ssh_port = options[:ssh_port] || config_from_file['ssh_port'] || 22
|
32
|
+
@role = options[:role] || config_from_file['role']
|
33
|
+
@flavor = options[:flavor] || config_from_file['flavor'] || 'm1.medium'
|
34
|
+
@security_groups = [options[:security_groups]] || [config_from_file['security_groups']]
|
35
|
+
@deploy_cmd = options[:deploy_cmd] || config_from_file['deploy_cmd'] || 'sudo chef-client'
|
36
|
+
@name = (options[:branch] || config_from_file['branch']) ? (options[:branch] || config_from_file['branch']) : (options[:name] || config_from_file['name'])
|
37
|
+
@image = options[:ami_image] || config_from_file['ami_image']
|
38
|
+
@verbose = options[:verbose] || config_from_file['verbose']
|
39
39
|
end
|
40
40
|
|
41
41
|
def to_hash
|
@@ -25,16 +25,16 @@ module Provider
|
|
25
25
|
class ChefServer
|
26
26
|
|
27
27
|
def initialize(config)
|
28
|
-
@path
|
29
|
-
@config
|
30
|
-
Chef::Config[:environment]
|
31
|
-
Chef::Config[:node_name]
|
32
|
-
Chef::Config[:client_key]
|
33
|
-
Chef::Config[:validation_client_name]
|
34
|
-
Chef::Config[:validation_key]
|
35
|
-
Chef::Config[:chef_server_url]
|
36
|
-
Chef::Config[:ssl_version]
|
37
|
-
Chef::Config[:log_level]
|
28
|
+
@path = File.dirname($0)
|
29
|
+
@config = config
|
30
|
+
Chef::Config[:environment] = config[:environment]
|
31
|
+
Chef::Config[:node_name] = config[:node_name]
|
32
|
+
Chef::Config[:client_key] = config[:client_key]
|
33
|
+
Chef::Config[:validation_client_name] = config[:validation_client_name]
|
34
|
+
Chef::Config[:validation_key] = config[:validation_key]
|
35
|
+
Chef::Config[:chef_server_url] = config[:chef_server_url]
|
36
|
+
Chef::Config[:ssl_version] = config[:ssl_version]
|
37
|
+
Chef::Config[:log_level] = config[:verbose]
|
38
38
|
@knife = knife
|
39
39
|
end
|
40
40
|
|
@@ -3,28 +3,28 @@ module Provider
|
|
3
3
|
class Instance
|
4
4
|
|
5
5
|
def initialize(config)
|
6
|
-
@access_key_id
|
7
|
-
@secret_access_key
|
8
|
-
@name
|
9
|
-
@image
|
10
|
-
@security_groups
|
11
|
-
@ssh_user
|
12
|
-
@ssh_port
|
13
|
-
@identity_file
|
14
|
-
@aws_ssh_key_id
|
15
|
-
@environment
|
16
|
-
@roles
|
17
|
-
@flavor
|
18
|
-
@region
|
19
|
-
@availability_zone
|
20
|
-
@verbose
|
21
|
-
Chef::Config[:knife][:image]
|
22
|
-
Chef::Config[:knife][:aws_ssh_key_id]
|
23
|
-
Chef::Config[:knife][:aws_access_key_id]
|
24
|
-
Chef::Config[:knife][:aws_secret_access_key]
|
25
|
-
Chef::Config[:knife][:region]
|
26
|
-
Chef::Config[:knife][:availability_zone]
|
27
|
-
Chef::Config[:knife][:log_level]
|
6
|
+
@access_key_id = config[:cloudprovider_access_key_id]
|
7
|
+
@secret_access_key = config[:cloudprovider_secret_access_key]
|
8
|
+
@name = config[:name]
|
9
|
+
@image = config[:image]
|
10
|
+
@security_groups = config[:security_groups]
|
11
|
+
@ssh_user = config[:ssh_user]
|
12
|
+
@ssh_port = config[:ssh_port]
|
13
|
+
@identity_file = config[:identity_file]
|
14
|
+
@aws_ssh_key_id = config[:aws_ssh_key_id]
|
15
|
+
@environment = config[:environment]
|
16
|
+
@roles = "role[#{config[:role]}]"
|
17
|
+
@flavor = config[:flavor]
|
18
|
+
@region = config[:region]
|
19
|
+
@availability_zone = config[:availability_zone]
|
20
|
+
@verbose = config[:verbose]
|
21
|
+
Chef::Config[:knife][:image] = @image
|
22
|
+
Chef::Config[:knife][:aws_ssh_key_id] = @aws_ssh_key_id
|
23
|
+
Chef::Config[:knife][:aws_access_key_id] = @access_key_id
|
24
|
+
Chef::Config[:knife][:aws_secret_access_key] = @secret_access_key
|
25
|
+
Chef::Config[:knife][:region] = @region
|
26
|
+
Chef::Config[:knife][:availability_zone] = @availability_zone
|
27
|
+
Chef::Config[:knife][:log_level] = @verbose
|
28
28
|
end
|
29
29
|
|
30
30
|
def create
|
@@ -32,16 +32,16 @@ module Provider
|
|
32
32
|
|
33
33
|
node = Chef::Knife::Ec2ServerCreate.new()
|
34
34
|
|
35
|
-
node.config[:run_list]
|
36
|
-
node.config[:image]
|
37
|
-
node.config[:flavor]
|
38
|
-
node.config[:security_groups]
|
39
|
-
node.config[:ssh_user]
|
40
|
-
node.config[:ssh_port]
|
41
|
-
node.config[:chef_node_name]
|
42
|
-
node.config[:identity_file]
|
43
|
-
node.config[:environment]
|
44
|
-
node.config[:log_level]
|
35
|
+
node.config[:run_list] = [@roles]
|
36
|
+
node.config[:image] = @image
|
37
|
+
node.config[:flavor] = @flavor
|
38
|
+
node.config[:security_groups] = @security_groups
|
39
|
+
node.config[:ssh_user] = @ssh_user
|
40
|
+
node.config[:ssh_port] = @ssh_port
|
41
|
+
node.config[:chef_node_name] = @name
|
42
|
+
node.config[:identity_file] = @identity_file
|
43
|
+
node.config[:environment] = @environment
|
44
|
+
node.config[:log_level] = @verbose
|
45
45
|
|
46
46
|
puts node.config
|
47
47
|
node.run
|
@@ -52,22 +52,22 @@ module Provider
|
|
52
52
|
|
53
53
|
node = Chef::Knife::Ec2ServerCreate.new()
|
54
54
|
|
55
|
-
node.config[:image]
|
56
|
-
node.config[:flavor]
|
57
|
-
node.config[:security_groups]
|
58
|
-
node.config[:ssh_user]
|
59
|
-
node.config[:ssh_port]
|
60
|
-
node.config[:chef_node_name]
|
61
|
-
node.config[:identity_file]
|
62
|
-
node.config[:environment]
|
63
|
-
node.config[:log_level]
|
55
|
+
node.config[:image] = @image
|
56
|
+
node.config[:flavor] = @flavor
|
57
|
+
node.config[:security_groups] = @security_groups
|
58
|
+
node.config[:ssh_user] = @ssh_user
|
59
|
+
node.config[:ssh_port] = @ssh_port
|
60
|
+
node.config[:chef_node_name] = @name
|
61
|
+
node.config[:identity_file] = @identity_file
|
62
|
+
node.config[:environment] = @environment
|
63
|
+
node.config[:log_level] = @verbose
|
64
64
|
|
65
65
|
puts node.config
|
66
66
|
begin
|
67
67
|
node.run
|
68
68
|
rescue
|
69
69
|
puts "Creation of #{@name} failed"
|
70
|
-
self.destroy([node.server.id])
|
70
|
+
self.destroy([node.server.id]) if node.server
|
71
71
|
self.bootstrap(recursive_count+=1) if recursive_count < 3
|
72
72
|
end
|
73
73
|
end
|
@@ -77,10 +77,10 @@ module Provider
|
|
77
77
|
|
78
78
|
node = Chef::Knife::Ec2ServerDelete.new()
|
79
79
|
|
80
|
-
node.config[:purge]
|
81
|
-
node.config[:chef_node_name]
|
82
|
-
node.config[:yes]
|
83
|
-
node.name_args
|
80
|
+
node.config[:purge] = true
|
81
|
+
node.config[:chef_node_name] = @name
|
82
|
+
node.config[:yes] = true
|
83
|
+
node.name_args = instance_ids
|
84
84
|
|
85
85
|
puts node.config
|
86
86
|
node.run
|
@@ -106,10 +106,10 @@ module Provider
|
|
106
106
|
def ssh(query, cmd_line, manual)
|
107
107
|
knife_ssh = Chef::Knife::Ssh.new()
|
108
108
|
|
109
|
-
knife_ssh.config[:manual]
|
110
|
-
knife_ssh.config[:ssh_user]
|
111
|
-
knife_ssh.config[:identity_file]
|
112
|
-
knife_ssh.config[:log_level]
|
109
|
+
knife_ssh.config[:manual] = manual
|
110
|
+
knife_ssh.config[:ssh_user] = @ssh_user
|
111
|
+
knife_ssh.config[:identity_file] = @identity_file
|
112
|
+
knife_ssh.config[:log_level] = @verbose
|
113
113
|
|
114
114
|
knife_ssh.name_args = [query, cmd_line]
|
115
115
|
sys_status = knife_ssh.run
|
data/lib/providers/ec2/ec2.rb
CHANGED
@@ -6,12 +6,13 @@ module Provider
|
|
6
6
|
class Ec2
|
7
7
|
|
8
8
|
def initialize(config)
|
9
|
-
@name
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
9
|
+
@name = config[:name]
|
10
|
+
@region = config[:region]
|
11
|
+
@environment = config[:environment]
|
12
|
+
@access_key_id = config[:cloudprovider_access_key_id]
|
13
|
+
@secret_access_key = config[:cloudprovider_secret_access_key]
|
14
|
+
@owner_id = config[:cloudprovider_images_owner_id]
|
15
|
+
@ec2 = ec2
|
15
16
|
end
|
16
17
|
|
17
18
|
def image(name=nil)
|
@@ -29,7 +30,7 @@ module Provider
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def ec2
|
32
|
-
AWS::EC2.new(:access_key_id => @access_key_id, :secret_access_key => @secret_access_key)
|
33
|
+
AWS::EC2.new(:access_key_id => @access_key_id, :secret_access_key => @secret_access_key, :region => @region)
|
33
34
|
end
|
34
35
|
|
35
36
|
end
|
data/lib/providers/ec2/image.rb
CHANGED
@@ -36,25 +36,26 @@ module Provider
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def get_image
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
39
|
+
AWS.memoize do
|
40
|
+
my_image = @ec2.images.with_owner(@owner_id).select {|x| x.name == @ami_name}.first
|
41
|
+
unless my_image
|
42
|
+
my_image = @ec2.images[@ami_name]
|
43
|
+
unless my_image.exists?
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
else
|
47
|
+
while my_image.exists? == false && my_image.state != :failed
|
48
|
+
print "."
|
49
|
+
sleep 1
|
50
|
+
end
|
51
|
+
while my_image.state == :pending && my_image.state != :failed
|
52
|
+
print "."
|
53
|
+
sleep 1
|
54
|
+
end
|
55
|
+
puts ""
|
54
56
|
end
|
55
|
-
|
57
|
+
return my_image
|
56
58
|
end
|
57
|
-
return my_image
|
58
59
|
end
|
59
60
|
|
60
61
|
end
|
data/lib/veronic.rb
CHANGED
@@ -44,7 +44,7 @@ module Veronic
|
|
44
44
|
def deploy_stacks
|
45
45
|
bootstrap
|
46
46
|
query = cloudprovider.instance.dns_name
|
47
|
-
deploy_cmd =
|
47
|
+
deploy_cmd = "sudo chef-client #{@config.verbose ? '-l ' + @config.verbose : ''}"
|
48
48
|
manual = true
|
49
49
|
configprovider.ssh(query, deploy_cmd, manual)
|
50
50
|
end
|
data/veronic.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: veronic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -128,3 +128,4 @@ signing_key:
|
|
128
128
|
specification_version: 3
|
129
129
|
summary: Veronic, a simple cloud deployer
|
130
130
|
test_files: []
|
131
|
+
has_rdoc:
|