rebuy_deployment 0.4.4 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rebuy_deployment/deploy.rb +46 -1
  2. metadata +35 -3
@@ -1,7 +1,7 @@
1
1
  Encoding.default_internal = "UTF-8"
2
- Encoding.default_external = "UTF-8"
3
2
  require 'mail'
4
3
  require 'capistrano/campfire'
4
+ require 'zk'
5
5
 
6
6
  def prompt_if_unset(name, default = '')
7
7
  unless exists? name
@@ -58,6 +58,48 @@ def get_git_log
58
58
  end
59
59
  end
60
60
 
61
+ def discover_hosts(application, type)
62
+ zk = ZK.new('zookeeper.dc1.rebuy:2181')
63
+
64
+ if not zk.exists?("/services/" + application)
65
+ raise "No server is registered for application " + application
66
+ end
67
+
68
+ servers = zk.children("/services/" + application)
69
+
70
+ if servers.size == 0
71
+ raise "No server is registered for application " + application
72
+ end
73
+
74
+ role_app = []
75
+ role_cron = []
76
+ role_web = []
77
+
78
+ servers.each do |server|
79
+ info = zk.get("/services/" + application + "/" + server)
80
+ roles = JSON.parse(info[0])['roles']
81
+ roles.each do |role|
82
+ case role.strip
83
+ when 'app'
84
+ role_app.push(server)
85
+ when 'cron'
86
+ role_cron.push(server)
87
+ when 'web'
88
+ role_web.push(server)
89
+ end
90
+ end
91
+ end
92
+
93
+ if type == :app
94
+ return role_app
95
+ elsif type == :web
96
+ return role_web
97
+ elsif type == :cron
98
+ return role_cron
99
+ end
100
+ return []
101
+ end
102
+
61
103
  unless exists?(:stages)
62
104
  set :stages, %w(production sandbox)
63
105
  end
@@ -67,6 +109,9 @@ require 'capistrano/ext/multistage'
67
109
 
68
110
  prompt_if_unset :branch, 'master'
69
111
  ssh_options[:user] = 'deployment'
112
+ ssh_options[:paranoid] = false #StrictHostKeyChecking
113
+ ssh_options[:user_known_hosts_file] = '/dev/null' #UserKnownHostsFile
114
+
70
115
  default_run_options[:pty] = true
71
116
 
72
117
  set :application, 'REPLACE_ME'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rebuy_deployment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-04-05 00:00:00.000000000 Z
14
+ date: 2013-05-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: capistrano
@@ -93,6 +93,38 @@ dependencies:
93
93
  - - ! '>='
94
94
  - !ruby/object:Gem::Version
95
95
  version: 0.2.0
96
+ - !ruby/object:Gem::Dependency
97
+ name: zookeeper
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: json
114
+ requirement: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ type: :runtime
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
96
128
  description: This gem offers deployment for all rebuy.de projects
97
129
  email:
98
130
  - m.roetgers@rebuy.de
@@ -125,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
157
  version: '0'
126
158
  requirements: []
127
159
  rubyforge_project:
128
- rubygems_version: 1.8.23
160
+ rubygems_version: 1.8.24
129
161
  signing_key:
130
162
  specification_version: 3
131
163
  summary: Capistrano deployment for rebuy.de projects