veronic 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,4 +4,4 @@ gem 'chef'
4
4
  gem 'knife-ec2'
5
5
  gem 'route53'
6
6
  gem 'aws-sdk'
7
- gem 'excon', '= 0.21.0'
7
+ gem 'excon', '~> 0.23.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,87 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ aws-sdk (1.11.2)
5
+ json (~> 1.4)
6
+ nokogiri (< 1.6.0)
7
+ uuidtools (~> 2.1)
8
+ builder (3.2.2)
9
+ chef (11.4.4)
10
+ erubis
11
+ highline (>= 1.6.9)
12
+ json (>= 1.4.4, <= 1.7.7)
13
+ mixlib-authentication (>= 1.3.0)
14
+ mixlib-cli (~> 1.3.0)
15
+ mixlib-config (>= 1.1.2)
16
+ mixlib-log (>= 1.3.0)
17
+ mixlib-shellout
18
+ net-ssh (~> 2.6)
19
+ net-ssh-multi (~> 1.1.0)
20
+ ohai (>= 0.6.0)
21
+ rest-client (>= 1.0.4, < 1.7.0)
22
+ yajl-ruby (~> 1.1)
23
+ erubis (2.7.0)
24
+ excon (0.23.0)
25
+ fog (1.12.1)
26
+ builder
27
+ excon (~> 0.23.0)
28
+ formatador (~> 0.2.0)
29
+ mime-types
30
+ multi_json (~> 1.0)
31
+ net-scp (~> 1.1)
32
+ net-ssh (>= 2.1.3)
33
+ nokogiri (~> 1.5.0)
34
+ ruby-hmac
35
+ formatador (0.2.4)
36
+ highline (1.6.19)
37
+ hpricot (0.8.6)
38
+ ipaddress (0.8.0)
39
+ json (1.7.7)
40
+ knife-ec2 (0.6.4)
41
+ chef (>= 0.10.10)
42
+ fog (~> 1.6)
43
+ mime-types (1.23)
44
+ mixlib-authentication (1.3.0)
45
+ mixlib-log
46
+ mixlib-cli (1.3.0)
47
+ mixlib-config (1.1.2)
48
+ mixlib-log (1.6.0)
49
+ mixlib-shellout (1.1.0)
50
+ multi_json (1.7.6)
51
+ net-scp (1.1.1)
52
+ net-ssh (>= 2.6.5)
53
+ net-ssh (2.6.7)
54
+ net-ssh-gateway (1.2.0)
55
+ net-ssh (>= 2.6.5)
56
+ net-ssh-multi (1.1)
57
+ net-ssh (>= 2.1.4)
58
+ net-ssh-gateway (>= 0.99.0)
59
+ nokogiri (1.5.10)
60
+ ohai (6.16.0)
61
+ ipaddress
62
+ mixlib-cli
63
+ mixlib-config
64
+ mixlib-log
65
+ mixlib-shellout
66
+ systemu
67
+ yajl-ruby
68
+ rest-client (1.6.7)
69
+ mime-types (>= 1.16)
70
+ route53 (0.2.1)
71
+ builder
72
+ hpricot
73
+ ruby-hmac
74
+ ruby-hmac (0.4.0)
75
+ systemu (2.5.2)
76
+ uuidtools (2.1.4)
77
+ yajl-ruby (1.1.0)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ aws-sdk
84
+ chef
85
+ excon (~> 0.23.0)
86
+ knife-ec2
87
+ route53
data/bin/veronic CHANGED
@@ -36,6 +36,47 @@ opt_parser = OptionParser.new do |opt|
36
36
  options[:config_file] = c
37
37
  end
38
38
 
39
+ options[:dnsprovider] = ENV['dnsprovider']
40
+ opt.on("--dnsprovider","--dnsprovider r53","Use specific dnsprovider") do |dns|
41
+ options[:dnsprovider] = dns
42
+ end
43
+ options[:cloudprovider] = ENV['cloudprovider']
44
+ opt.on("--cloudprovider","--cloudprovider ec2","Use specific cloudprovider") do |cloud|
45
+ options[:cloudprovider] = cloud
46
+ end
47
+ options[:configprovider] = ENV['configprovider']
48
+ opt.on("--configprovider","--configprovider chef","Use specific configprovider") do |config|
49
+ options[:configprovider] = config
50
+ end
51
+ options[:dnsprovider_access_key_id] = ENV['dnsprovider_access_key_id']
52
+ opt.on("--dnsprovider_access_key_id","--dnsprovider_access_key_id","Use specific dnsprovider_access_key_id") do |d|
53
+ options[:dnsprovider_access_key_id] = d
54
+ end
55
+ options[:dnsprovider_secret_access_key] = ENV['dnsprovider_secret_access_key']
56
+ opt.on("--dnsprovider_secret_access_key","--dnsprovider_secret_access_key","Use specific dnsprovider_secret_access_key") do |d|
57
+ options[:dnsprovider_secret_access_key] = d
58
+ end
59
+ options[:dnsprovider_zones] = ENV['dnsprovider_zones']
60
+ opt.on("--dnsprovider_zones","--dnsprovider_zones","Use specific dnsprovider_zones") do |d|
61
+ options[:dnsprovider_zones] = d
62
+ end
63
+ options[:cloudprovider_access_key_id] = ENV['cloudprovider_access_key_id']
64
+ opt.on("--cloudprovider_access_key_id","--cloudprovider_access_key_id","Use specific cloudprovider_access_key_id") do |c|
65
+ options[:cloudprovider_access_key_id] = c
66
+ end
67
+ options[:cloudprovider_secret_access_key] = ENV['cloudprovider_secret_access_key']
68
+ opt.on("--cloudprovider_secret_access_key","--cloudprovider_secret_access_key","Use specific cloudprovider_secret_access_keye") do |c|
69
+ options[:cloudprovider_secret_access_key] = c
70
+ end
71
+ options[:cloudprovider_images_owner_id] = ENV['cloudprovider_images_owner_id']
72
+ opt.on("--cloudprovider_images_owner_id","--cloudprovider_images_owner_id","Use specific cloudprovider_images_owner_id") do |c|
73
+ options[:cloudprovider_images_owner_id] = c
74
+ end
75
+ options[:region] = ENV['region']
76
+ opt.on("--region","--region","Use specific region") do |r|
77
+ options[:region] = r
78
+ end
79
+
39
80
  options[:environment] = ENV['environment']
40
81
  opt.on("-E","--environment ENVIRONMENT","Which environment you want box run") do |e|
41
82
  options[:environment] = e
data/lib/config/config.rb CHANGED
@@ -3,12 +3,12 @@ module Veronic
3
3
  attr_accessor :dnsprovider, :cloudprovider, :configprovider, :dnsprovider_access_key_id, :dnsprovider_secret_access_key, :cloudprovider_access_key_id, :cloudprovider_secret_access_key, :cloudprovider_images_owner_id, :dnsprovider_zones, :region, :availability_zone, :aws_ssh_key_id, :node_name, :client_key, :validation_client_name, :validation_key, :chef_server_url, :ssl_version, :identity_file, :branch, :environment, :ssh_user, :ssh_port, :role, :flavor, :security_groups, :deploy_cmd, :name, :image, :zone_name, :zone_url, :verbose, :query
4
4
 
5
5
  def initialize(options={})
6
- config_file = File.exists?('/etc/veronic/veronic.yml') ? '/etc/veronic/veronic.yml' : '../../' + File.dirname($0) + '/veronic.yml'
6
+ config_file = File.exists?('/etc/veronic/veronic.yml') ? '/etc/veronic/veronic.yml' : File.exists?('./veronic.yml') ? './veronic.yml' : nil
7
7
  config_from_file = YAML.load_file(options[:config_file] || config_file)
8
8
 
9
- @dnsprovider = :route53
10
- @cloudprovider = :ec2
11
- @configprovider = :chefserver
9
+ @dnsprovider = options[:dnsprovider] || config_from_file['dnsprovider'] || :route53
10
+ @cloudprovider = options[:cloudprovider] || config_from_file['cloudprovider'] || :ec2
11
+ @configprovider = options[:configprovider] || config_from_file['configprovider'] || :chefserver
12
12
  @dnsprovider_access_key_id = options[:dnsprovider_access_key_id] || config_from_file['dnsprovider_access_key_id']
13
13
  @dnsprovider_secret_access_key = options[:dnsprovider_secret_access_key] || config_from_file['dnsprovider_secret_access_key']
14
14
  @dnsprovider_zones = options[:dnsprovider_zones] || config_from_file['dnsprovider_zones']
@@ -34,9 +34,9 @@ module Veronic
34
34
  @security_groups = options[:security_groups].split(',') || config_from_file['security_groups'].split(',')
35
35
  @deploy_cmd = options[:deploy_cmd] || config_from_file['deploy_cmd'] || 'sudo chef-client'
36
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
- @query = options[:query] || config_from_file['query']
37
+ @image = options[:ami_image] || config_from_file['ami_image']
38
+ @verbose = options[:verbose] || config_from_file['verbose']
39
+ @query = options[:query] || config_from_file['query']
40
40
  end
41
41
 
42
42
  def to_hash
@@ -32,14 +32,13 @@ module Provider
32
32
  Chef::Config[:client_key] = config[:client_key]
33
33
  Chef::Config[:validation_client_name] = config[:validation_client_name]
34
34
  Chef::Config[:validation_key] = config[:validation_key]
35
- Chef::Config[:chef_server_url] = config[:chef_server_url]
35
+ Chef::Config[:chef_server_url] = config[:chef_server_url] if config[:chef_server_url]
36
36
  Chef::Config[:ssl_version] = config[:ssl_version]
37
37
  Chef::Config[:log_level] = config[:verbose]
38
- @knife = knife
39
38
  end
40
39
 
41
40
  def knife
42
- knife = Provider::ChefServer::Instance.new(@config)
41
+ @knife = @knife || Provider::ChefServer::Instance.new(@config)
43
42
  end
44
43
 
45
44
  def instances(query)
@@ -55,7 +54,7 @@ module Provider
55
54
  end
56
55
 
57
56
  def ssh(query, deploy_cmd, manual)
58
- @knife.ssh(query, deploy_cmd, manual)
57
+ knife.ssh(query, deploy_cmd, manual)
59
58
  end
60
59
 
61
60
  def instance
@@ -12,7 +12,7 @@ module Provider
12
12
  @access_key_id = config[:cloudprovider_access_key_id]
13
13
  @secret_access_key = config[:cloudprovider_secret_access_key]
14
14
  @owner_id = config[:cloudprovider_images_owner_id]
15
- @image = config[:image]
15
+ @image = config[:image] || config[:name]
16
16
  @ec2 = ec2
17
17
  end
18
18
 
@@ -10,16 +10,16 @@ module Provider
10
10
  end
11
11
 
12
12
  def id
13
- if image
14
- @image.id
13
+ if get_image
14
+ get_image.id
15
15
  end
16
16
  end
17
17
 
18
18
  def detroy
19
- puts "Destroying image #{@ami_name}..."
20
- if image
19
+ puts "Destroying image #{@ami_name} ..."
20
+ if get_image
21
21
  begin
22
- @image.deregister
22
+ get_image.deregister
23
23
  sleep 5
24
24
  puts "Image #{@ami_name} destroyed"
25
25
  rescue
@@ -29,17 +29,18 @@ module Provider
29
29
  return true
30
30
  end
31
31
 
32
- def image
33
- puts "Getting image #{@ami_name}..."
34
- @image ||= get_image
32
+ def exists?
33
+ get_image
35
34
  end
36
35
 
37
36
  def get_image
38
- AWS.memoize do
37
+ @get_image || AWS.memoize do
38
+ puts "Getting image #{@ami_name}"
39
39
  my_image = @ec2.images.with_owner(@owner_id).select {|x| x.name == @ami_name}.first
40
40
  unless my_image
41
41
  my_image = @ec2.images[@ami_name]
42
42
  unless my_image.exists?
43
+ puts "Unabled to found image #{@ami_name}"
43
44
  return false
44
45
  end
45
46
  else
@@ -53,7 +54,8 @@ module Provider
53
54
  end
54
55
  puts ""
55
56
  end
56
- return my_image
57
+ @get_image = my_image
58
+ return @get_image
57
59
  end
58
60
  end
59
61
 
@@ -6,7 +6,7 @@ module Provider
6
6
  @ec2 = ec2
7
7
  @name = name
8
8
  @instance = instance
9
- @image = image
9
+ @ami_name = image || name
10
10
  end
11
11
 
12
12
  def stop
@@ -40,7 +40,7 @@ module Provider
40
40
  return true
41
41
  end
42
42
 
43
- def exist?
43
+ def exists?
44
44
  puts "Checking for ec2 server #{@name} ..."
45
45
  if AWS.memoize do @ec2.instances.any? {|x| x.tags['Name'] == @name && x.status != :shutting_down && x.status != :terminated} end
46
46
  puts "Instance #{@name} found"
@@ -78,19 +78,18 @@ module Provider
78
78
  end
79
79
 
80
80
  def create_image
81
- @ami_name = @image || @name
82
81
  puts "Create image #{@ami_name}"
83
- image = @instance.create_image(@ami_name, { :no_reboot => true })
84
- while image.exists? == false && image.state != :failed
82
+ new_image = @instance.create_image(@ami_name, { :no_reboot => true })
83
+ while new_image.exists? == false && new_image.state != :failed
85
84
  print "."
86
85
  sleep 1
87
86
  end
88
- while image.state == :pending && image.state != :failed
87
+ while new_image.state == :pending && new_image.state != :failed
89
88
  print "."
90
89
  sleep 1
91
90
  end
92
91
  puts ""
93
- return image
92
+ return new_image
94
93
  end
95
94
 
96
95
  def tags(hash={})
data/lib/veronic.rb CHANGED
@@ -79,7 +79,7 @@ module Veronic
79
79
  record = dnsprovider.zone.record(dns, [], "A", "1").delete
80
80
  puts "DNS #{dns} deleted"
81
81
  end
82
- if cloudprovider.instance.exist?
82
+ if cloudprovider.instance.exists?
83
83
  configprovider.instance.destroy([cloudprovider.instance.id])
84
84
  else
85
85
  configprovider.instance.destroy([])
@@ -107,14 +107,18 @@ module Veronic
107
107
  end
108
108
 
109
109
  def update_instance_dns
110
- @config.dnsprovider_zones.each do |z|
111
- @config.zone_name = z['zone_name']
112
- @config.zone_url = z['zone_url']
113
- dns = "#{@config.name}.#{z['zone_name']}"
114
- puts "Setting DNS #{dns} ..."
115
- record = dnsprovider.zone.record(dns, [cloudprovider.instance.dns_name], "CNAME", "1").wait_set
116
- puts "DNS #{dns} updated"
117
- end
110
+ if @config.dnsprovider_zones
111
+ @config.dnsprovider_zones.each do |z|
112
+ @config.zone_name = z['zone_name']
113
+ @config.zone_url = z['zone_url']
114
+ dns = "#{@config.name}.#{z['zone_name']}"
115
+ puts "Setting DNS #{dns} ..."
116
+ record = dnsprovider.zone.record(dns, [cloudprovider.instance.dns_name], "CNAME", "1").wait_set
117
+ puts "DNS #{dns} updated"
118
+ end
119
+ else
120
+ puts "Unabled to update DNS"
121
+ end
118
122
  end
119
123
 
120
124
  def instances_list
@@ -145,7 +149,7 @@ module Veronic
145
149
  puts "#{@config.name} is running"
146
150
  elsif cloudprovider.instance.status == :stopped
147
151
  start
148
- elsif cloudprovider.instance.exist? == false
152
+ elsif cloudprovider.instance.exists? == false
149
153
  @config.availability_zone = get_availability_zone
150
154
  get_image
151
155
  configprovider.instance.client.destroy
@@ -175,7 +179,7 @@ module Veronic
175
179
  configprovider.instance.client.destroy
176
180
  end
177
181
  else
178
- abort('Arguments --role or --environment is missing')
182
+ puts 'Unable to set_node arguments --role or --environment is missing'
179
183
  end
180
184
  end
181
185
 
data/veronic.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'veronic'
3
- s.version = '0.0.22'
3
+ s.version = '0.0.23'
4
4
  s.date = '2013-04-05'
5
5
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
6
6
  s.summary = "Veronic, a simple cloud deployer"
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.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -100,6 +100,7 @@ extra_rdoc_files: []
100
100
  files:
101
101
  - .gitignore
102
102
  - Gemfile
103
+ - Gemfile.lock
103
104
  - README.md
104
105
  - bin/veronic
105
106
  - lib/config/config.rb