whiskey_disk 0.6.4 → 0.6.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +34 -0
- data/README.integration_specs +36 -0
- data/README.markdown +122 -5
- data/VERSION +1 -1
- data/bin/wd +5 -0
- data/lib/whiskey_disk/config.rb +35 -7
- data/lib/whiskey_disk.rb +31 -9
- data/scenarios/git_repositories/config.git/HEAD +1 -0
- data/scenarios/git_repositories/config.git/config +5 -0
- data/scenarios/git_repositories/config.git/description +1 -0
- data/scenarios/git_repositories/config.git/git-daemon-export-ok +0 -0
- data/scenarios/git_repositories/config.git/hooks/applypatch-msg.sample +15 -0
- data/scenarios/git_repositories/config.git/hooks/commit-msg.sample +24 -0
- data/scenarios/git_repositories/config.git/hooks/post-commit.sample +8 -0
- data/scenarios/git_repositories/config.git/hooks/post-receive.sample +15 -0
- data/scenarios/git_repositories/config.git/hooks/post-update.sample +8 -0
- data/scenarios/git_repositories/config.git/hooks/pre-applypatch.sample +14 -0
- data/scenarios/git_repositories/config.git/hooks/pre-commit.sample +46 -0
- data/scenarios/git_repositories/config.git/hooks/pre-rebase.sample +169 -0
- data/scenarios/git_repositories/config.git/hooks/prepare-commit-msg.sample +36 -0
- data/scenarios/git_repositories/config.git/hooks/update.sample +128 -0
- data/scenarios/git_repositories/config.git/info/exclude +6 -0
- data/scenarios/git_repositories/config.git/objects/17/6bf54cf17d1d1c24556dc059c4144a5df230e8 +0 -0
- data/scenarios/git_repositories/config.git/objects/20/e9ff3feaa8ede30f707e5f1b4356e3c02bb7ec +0 -0
- data/scenarios/git_repositories/config.git/objects/45/117b1c775f0de415478dbf08ed9d667ab17d13 +0 -0
- data/scenarios/git_repositories/config.git/objects/71/eb5df52676e8e6efba471050b46978173af110 +1 -0
- data/scenarios/git_repositories/config.git/objects/d1/0bcd51fec41f854001e4d61f99d9e282a695d3 +0 -0
- data/scenarios/git_repositories/config.git/objects/e6/b02c66ad632e6b8535c4630cb8fe07732a72fc +0 -0
- data/scenarios/git_repositories/config.git/objects/f9/49d5d8a4f12c91471e34d4e277239c35ebd10d +0 -0
- data/scenarios/git_repositories/config.git/refs/heads/master +1 -0
- data/scenarios/git_repositories/project.git/HEAD +1 -0
- data/scenarios/git_repositories/project.git/config +5 -0
- data/scenarios/git_repositories/project.git/description +1 -0
- data/scenarios/git_repositories/project.git/git-daemon-export-ok +0 -0
- data/scenarios/git_repositories/project.git/hooks/applypatch-msg.sample +15 -0
- data/scenarios/git_repositories/project.git/hooks/commit-msg.sample +24 -0
- data/scenarios/git_repositories/project.git/hooks/post-commit.sample +8 -0
- data/scenarios/git_repositories/project.git/hooks/post-receive.sample +15 -0
- data/scenarios/git_repositories/project.git/hooks/post-update.sample +8 -0
- data/scenarios/git_repositories/project.git/hooks/pre-applypatch.sample +14 -0
- data/scenarios/git_repositories/project.git/hooks/pre-commit.sample +46 -0
- data/scenarios/git_repositories/project.git/hooks/pre-rebase.sample +169 -0
- data/scenarios/git_repositories/project.git/hooks/prepare-commit-msg.sample +36 -0
- data/scenarios/git_repositories/project.git/hooks/update.sample +128 -0
- data/scenarios/git_repositories/project.git/info/exclude +6 -0
- data/scenarios/git_repositories/project.git/objects/20/1c7641c2e42b0b904e5c1f793489d8b858e4da +2 -0
- data/scenarios/git_repositories/project.git/objects/80/26076649ceccbe96a6292f2432652f08483035 +0 -0
- data/scenarios/git_repositories/project.git/objects/ef/2a88894d5421920b9dfe67a9a4d8043830e62e +0 -0
- data/scenarios/git_repositories/project.git/refs/heads/master +1 -0
- data/scenarios/invalid/deploy.yml +1 -0
- data/scenarios/local/deploy.yml +16 -0
- data/scenarios/remote/deploy.yml +5 -0
- data/spec/integration/invalid_configuration_spec.rb +39 -0
- data/spec/integration/local_deployments_spec.rb +230 -0
- data/spec/integration/remote_deployments_spec.rb +54 -0
- data/spec/spec_helper.rb +57 -0
- data/spec/wd_command_spec.rb +289 -6
- data/spec/whiskey_disk/config_spec.rb +233 -89
- data/spec/whiskey_disk/rake_spec.rb +0 -21
- data/spec/whiskey_disk_spec.rb +160 -142
- data/whiskey_disk.gemspec +55 -2
- metadata +57 -4
data/CHANGELOG
CHANGED
@@ -1,4 +1,38 @@
|
|
1
1
|
|
2
|
+
0.6.10 / 2011-02-08
|
3
|
+
==================
|
4
|
+
|
5
|
+
* bump version to 0.6.10
|
6
|
+
* Merge branch 'feature/improved-integration-specs' into develop
|
7
|
+
* reorganizing integration specs
|
8
|
+
* adding a quick README on how to run integration specs
|
9
|
+
* adding a remote deployment integration spec
|
10
|
+
* working around permissioning issues to support "remote" integration specs
|
11
|
+
* integration specs for non-matching --only deployment
|
12
|
+
* make sure the integration test is actually testing the local library
|
13
|
+
* fixing 'unit@' --only local deployment WD.remote? bug
|
14
|
+
* Adding initial integration spec suite
|
15
|
+
* save +x chmod state to bin/wd
|
16
|
+
* Merge branch 'develop' of git.ogtastic.com:whiskey_disk into develop
|
17
|
+
* Merge branch 'hotfix/cd-before-post-scripts' into develop
|
18
|
+
* adding --only support to wd binary
|
19
|
+
* an ENV['only'] domain should deploy locally
|
20
|
+
* adding support for ENV['none'] to WhiskeyDisk, ::Config
|
21
|
+
* updating README to document upcoming --only / ENV['only'] functionality
|
22
|
+
* WD.fetch now iterates over all domains, local or remote
|
23
|
+
* reorganizing specs
|
24
|
+
* make it an error for a domain to appear more than once in a given project/target
|
25
|
+
* changing internal :domain representation
|
26
|
+
* WhiskeyDisk.remote? now takes a domain argument
|
27
|
+
* README updates for specifying local deployments via "local" domain
|
28
|
+
* added tl;dr quickstart section to README
|
29
|
+
* Merge branch 'feature/enable_pulling_deploy.yml_from_url' into develop
|
30
|
+
* updating README to describe using --path URLs
|
31
|
+
* can now specify path to deploy.yml info using an URL
|
32
|
+
* Merge branch 'feature/move_todo_to_pivotal_tracker' into develop
|
33
|
+
* removing TODO.txt
|
34
|
+
* updating README to point to PT project instead of old TODO.txt file
|
35
|
+
|
2
36
|
0.6.4 / 2011-01-26
|
3
37
|
==================
|
4
38
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
It is possible to run an integration spec suite which attempts to exercise the
|
2
|
+
full whiskey_disk stack. I want this to be able to work on a single machine
|
3
|
+
(especially since I like to work on whiskey_disk on airplanes and in foreign
|
4
|
+
countries with questionable bandwidth/infrastructure). So, here's how I set my
|
5
|
+
environment up to make this possible
|
6
|
+
|
7
|
+
|
8
|
+
- need the following /etc/hosts entry:
|
9
|
+
127.0.0.1 localhost wd-git.example.com wd-app1.example.com wd-app2.example.com
|
10
|
+
|
11
|
+
- enable sshd logins
|
12
|
+
|
13
|
+
- create a local user named 'user', then:
|
14
|
+
|
15
|
+
user% mkdir wd-integration-target
|
16
|
+
user% chmod 777 wd-integration-target
|
17
|
+
user% ln -s ~/wd-integration-target /tmp/wd-integration-target
|
18
|
+
|
19
|
+
user% ssh-keygen (specify no passphrase)
|
20
|
+
user% cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
|
21
|
+
user% chmod 700 ~/.ssh/; chmod 600 ~/.ssh/authorized_keys
|
22
|
+
|
23
|
+
user% ssh user@wd-app1.example.com (answer 'yes' to the trust host prompt)
|
24
|
+
^D
|
25
|
+
user% ssh user@wd-app2.example.com ( ditto )
|
26
|
+
^D
|
27
|
+
|
28
|
+
then, as user, git clone whiskey_disk from github or ln -s to an already checked out version
|
29
|
+
(which is what I usually do)
|
30
|
+
|
31
|
+
- run git-daemon:
|
32
|
+
user% cd git/whiskey_disk
|
33
|
+
user% git daemon --base-path=`pwd`/scenarios/git_repositories/ --reuseaddr --verbose &
|
34
|
+
|
35
|
+
user% export INTEGRATION=true
|
36
|
+
user% rake
|
data/README.markdown
CHANGED
@@ -8,6 +8,32 @@ Right-arrow through a short whiskey_disk presentation at [http://wd2010.rickbrad
|
|
8
8
|
You can also right-arrow through a shorter but more up-to-date whiskey_disk "lightning talk" presentation
|
9
9
|
(from the 2010 Ruby Hoedown) at [http://wdlightning.rickbradley.com/](http://wdlightning.rickbradley.com) (slide source available [here](http://github.com/rick/whiskey_disk_presentation/tree/lightning).), covering the 0.4.*-era functionality.
|
10
10
|
|
11
|
+
### tl;dr ###
|
12
|
+
|
13
|
+
First:
|
14
|
+
|
15
|
+
% gem install whiskey_disk
|
16
|
+
|
17
|
+
|
18
|
+
Then make a deploy.yml file (in config/ if you're doing a Rails project):
|
19
|
+
|
20
|
+
staging:
|
21
|
+
domain: "deployment_user@staging.mydomain.com"
|
22
|
+
deploy_to: "/path/to/where/i/deploy/staging.mydomain.com"
|
23
|
+
repository: "https://github.com/username/project.git"
|
24
|
+
branch: "staging"
|
25
|
+
rake_env:
|
26
|
+
RAILS_ENV: 'production'
|
27
|
+
|
28
|
+
then:
|
29
|
+
|
30
|
+
% wd setup --to=staging
|
31
|
+
|
32
|
+
then:
|
33
|
+
|
34
|
+
% wd deploy --to=staging
|
35
|
+
|
36
|
+
|
11
37
|
### Selling points ###
|
12
38
|
|
13
39
|
- If you share the same opinions as we do there's almost no code involved, almost no
|
@@ -142,6 +168,26 @@ of deploy:setup
|
|
142
168
|
lib/tasks/ or in your project's Rakefile) will cause that task to be run
|
143
169
|
at the end of deploy:now
|
144
170
|
|
171
|
+
It's easy to specify a local deployment. The simplest way is to just not specify a "domain":
|
172
|
+
|
173
|
+
local:
|
174
|
+
deploy_to: "/var/www/www.ogtastic.com"
|
175
|
+
repository: "git@ogtastic.com:www.ogtastic.com.git"
|
176
|
+
branch: "stable"
|
177
|
+
rake_env:
|
178
|
+
RAILS_ENV: 'production'
|
179
|
+
|
180
|
+
|
181
|
+
Or, just specify the string 'local' as the domain:
|
182
|
+
|
183
|
+
local:
|
184
|
+
domain: "local"
|
185
|
+
deploy_to: "/var/www/www.ogtastic.com"
|
186
|
+
repository: "git@ogtastic.com:www.ogtastic.com.git"
|
187
|
+
branch: "stable"
|
188
|
+
rake_env:
|
189
|
+
RAILS_ENV: 'production'
|
190
|
+
|
145
191
|
|
146
192
|
For deploying to multiple hosts, the config/deploy.yml might look like:
|
147
193
|
|
@@ -156,6 +202,19 @@ For deploying to multiple hosts, the config/deploy.yml might look like:
|
|
156
202
|
RAILS_ENV: 'production'
|
157
203
|
|
158
204
|
|
205
|
+
You can even include a local deployment along with remote deployments, simply use the 'local' name:
|
206
|
+
|
207
|
+
qa:
|
208
|
+
domain:
|
209
|
+
- "local"
|
210
|
+
- "ogc@qa2.ogtastic.com""
|
211
|
+
deploy_to: "/var/www/www.ogtastic.com"
|
212
|
+
repository: "git@ogtastic.com:www.ogtastic.com.git"
|
213
|
+
branch: "stable"
|
214
|
+
rake_env:
|
215
|
+
RAILS_ENV: 'production'
|
216
|
+
|
217
|
+
|
159
218
|
### Specifying domains, with or without roles ###
|
160
219
|
|
161
220
|
There are a number of ways to specify domains (the ssh connection strings denoting the hosts
|
@@ -187,7 +246,6 @@ otherwise it's optional and superfluous):
|
|
187
246
|
domain:
|
188
247
|
- name: "build@ci.example.com"
|
189
248
|
|
190
|
-
|
191
249
|
It's also possible to assign various "roles" to the domains to which you deploy. Some common usages would be
|
192
250
|
"www", which might need a post\_deploy task which notifies some web server software (apache, nginx, passenger,
|
193
251
|
unicorn, etc.) that it should refresh the contents being served; or perhaps "db", which might need some set of
|
@@ -231,6 +289,17 @@ But domains with roles can be specified alongside simple domains as well:
|
|
231
289
|
- "db"
|
232
290
|
|
233
291
|
|
292
|
+
And, if you need to assign roles for a local deployment, you can do that as well:
|
293
|
+
|
294
|
+
local:
|
295
|
+
domain:
|
296
|
+
- name: "local"
|
297
|
+
roles:
|
298
|
+
- "web"
|
299
|
+
- "app"
|
300
|
+
- "db"
|
301
|
+
|
302
|
+
|
234
303
|
All that said, it's often simpler to refrain from carving up hosts into roles. But who's going to listen to reason?
|
235
304
|
|
236
305
|
|
@@ -364,18 +433,44 @@ are in an environment where the 'app' role is active but the 'web' role is not:
|
|
364
433
|
% wd setup --to=<target>
|
365
434
|
% wd setup --to=<project>:<target>
|
366
435
|
% wd setup --to=foo:qa --path=/etc/whiskey_disk/deploy.yml
|
367
|
-
|
436
|
+
% wd setup --to=foo:qa --path=https://github.com/username/project/raw/master/path/to/configs/deploy.yml
|
437
|
+
% wd setup --to=foo:qa --only=myhost.example.com
|
438
|
+
|
368
439
|
% wd deploy --to=<target>
|
369
440
|
% wd deploy --to=<project>:<target>
|
370
441
|
% wd deploy --to=foo:qa --path=/etc/whiskey_disk/deploy.yml
|
371
|
-
|
442
|
+
% wd deploy --to=foo:qa --path=https://github.com/username/project/raw/master/path/to/configs/deploy.yml
|
443
|
+
% wd deploy --to=foo:qa --only=myhost.example.com
|
372
444
|
|
373
445
|
Note that the wd command (unlike rake, which requires a Rakefile in the current directory) can be run from anywhere, so you can deploy any project, working from any path, and can even specify where to find the deployment YAML configuration file.
|
374
446
|
|
375
447
|
The --path argument can take either a file or a directory. When given a file it will use that file as the configuration file. When given a directory it will look in that directory for deploy/<project>/<target>.yml, then deploy/<project>.yml, then deploy/<target>.yml, then <target>.yml, and finally, deploy.yml.
|
376
|
-
|
448
|
+
|
449
|
+
To make things even better, you can provide an URL as the --path argument and have a central location from which to pull deployment YAML data. This means that you can centrally administer the definitive deployment information for the various projects and targets you manage. This could be as simple as keeping them in a text file hosted on a web server, checking them into git and using github or gitweb to serve up the file contents on HEAD, or it could be a programmatically managed configuration management system returning dynamically-generated results.
|
450
|
+
|
377
451
|
All this means you can manage a large number of project deployments (local or remote) and have a single scripted deployment manager that keeps them up to date. Configurations can live in a centralized location, and developers don't have to be actively involved in ensuring code gets shipped up to a server. Win.
|
378
452
|
|
453
|
+
When doing scripted deployments for a group of nodes who appear in the same 'domain' list, it's possible to specify the --only setting so that you can identify which domain entries belong to a specific node. For example, given this configuration:
|
454
|
+
|
455
|
+
|
456
|
+
production:
|
457
|
+
domain:
|
458
|
+
- foo.example.com
|
459
|
+
- bar.example.com
|
460
|
+
repository: git@github.com:foo.git
|
461
|
+
|
462
|
+
|
463
|
+
We would like to be able to set up the following scripted runs on foo.example.com and bar.example.com:
|
464
|
+
|
465
|
+
|
466
|
+
foo% wd deploy --to=app:production --path=http://automation.example.com/wd/deploy.yml
|
467
|
+
bar% wd deploy --to=app:production --path=http://automation.example.com/wd/deploy.yml
|
468
|
+
|
469
|
+
|
470
|
+
But without specifying --only we end up with undesired results. When foo.example.com runs it will see that it needs to make sure deployment happens on 'foo.example.com' and 'bar.example.com'. So, wd will ssh from foo.example.com to foo.example.com (less than ideal), deploy, and then ... it will ssh from foo.example.com to bar.example.com and do a deployment. When bar.example.com runs, however, it will also ssh to bar.example.com, and also to foo.example.com. So each host will be deployed twice.
|
471
|
+
|
472
|
+
The --only setting is used to tell a node what its name is, and to tell it not to bother trying to deploy other nodes that it finds in the target's "domain" listing. In other words, deployment is being managed from afar, and it's best to just manage ourselves and forego managing other nodes.
|
473
|
+
|
379
474
|
|
380
475
|
### A note about post\_{setup,deploy} Rake tasks
|
381
476
|
|
@@ -403,6 +498,28 @@ In your Rakefile:
|
|
403
498
|
% rake deploy:setup to=<project>:<target> (e.g., "foo:qa", "bar:production", etc.)
|
404
499
|
% rake deploy:now to=<project>:<target>
|
405
500
|
|
501
|
+
enabling staleness checking (see below):
|
502
|
+
|
503
|
+
% rake deploy:setup to=<project>:<target> check=yes
|
504
|
+
% rake deploy:now to=<project>:<target> check=yes
|
505
|
+
|
506
|
+
maybe even specifying the path to the configuration file:
|
507
|
+
|
508
|
+
% rake deploy:setup to=<project>:<target> path=/etc/deploy.yml
|
509
|
+
% rake deploy:now to=<project>:<target> path=/etc/deploy.yml
|
510
|
+
|
511
|
+
how about specifying the configuration file via URL:
|
512
|
+
|
513
|
+
% rake deploy:setup to=<project>:<target> path=https://github.com/username/project/raw/master/path/to/configs/deploy.yml
|
514
|
+
% rake deploy:now to=<project>:<target> path=https://github.com/username/project/raw/master/path/to/configs/deploy.yml
|
515
|
+
|
516
|
+
Finally, it's also possible to specify the 'only' variable to limit 'domain' entries of interest:
|
517
|
+
|
518
|
+
% rake deploy:setup to=<project>:<target> only=myhost.example.com
|
519
|
+
% rake deploy:now to=<project>:<target> only=myhost.example.com
|
520
|
+
|
521
|
+
(see the discussion of --only above in "Running whiskey\_disk from the command-line" for more information)
|
522
|
+
|
406
523
|
|
407
524
|
### Staleness checks ###
|
408
525
|
|
@@ -637,7 +754,7 @@ Notice that there are no separate trees for 'uat' and 'qa' targets.
|
|
637
754
|
|
638
755
|
### Future Directions ###
|
639
756
|
|
640
|
-
Check out the [
|
757
|
+
Check out the [Pivotal Tracker project](https://www.pivotaltracker.com/projects/202125)
|
641
758
|
to see what we have in mind for the near future.
|
642
759
|
|
643
760
|
### Resources ###
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.10
|
data/bin/wd
CHANGED
@@ -15,6 +15,10 @@ op = OptionParser.new do |opts|
|
|
15
15
|
options[:path] = path
|
16
16
|
end
|
17
17
|
|
18
|
+
opts.on('-o=DOMAIN', '--only=DOMAIN', "limit deployment to this domain") do |domain|
|
19
|
+
options[:only] = domain
|
20
|
+
end
|
21
|
+
|
18
22
|
opts.on('-c', '--check', "do a staleness check before deploying") do |path|
|
19
23
|
options[:check] = 'true'
|
20
24
|
end
|
@@ -32,6 +36,7 @@ raise op.to_s unless ['deploy', 'setup'].include?(command)
|
|
32
36
|
|
33
37
|
ENV['to'] = options[:target]
|
34
38
|
ENV['path'] = options[:path]
|
39
|
+
ENV['only'] = options[:only]
|
35
40
|
ENV['check'] = options[:check]
|
36
41
|
|
37
42
|
if command == 'deploy'
|
data/lib/whiskey_disk/config.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'uri'
|
3
|
+
require 'open-uri'
|
2
4
|
|
3
5
|
class WhiskeyDisk
|
4
6
|
class Config
|
@@ -26,6 +28,11 @@ class WhiskeyDisk
|
|
26
28
|
def check_staleness?
|
27
29
|
!!(ENV['check'] && ENV['check'] =~ /^(?:t(?:rue)?|y(?:es)?|1)$/)
|
28
30
|
end
|
31
|
+
|
32
|
+
def domain_limit
|
33
|
+
return false unless ENV['only'] and ENV['only'] != ''
|
34
|
+
ENV['only']
|
35
|
+
end
|
29
36
|
|
30
37
|
def contains_rakefile?(path)
|
31
38
|
File.exists?(File.expand_path(File.join(path, 'Rakefile')))
|
@@ -47,9 +54,19 @@ class WhiskeyDisk
|
|
47
54
|
find_rakefile_from_current_path
|
48
55
|
end
|
49
56
|
|
50
|
-
def
|
51
|
-
|
57
|
+
def valid_path?(path)
|
58
|
+
if path
|
59
|
+
uri = URI.parse(path)
|
60
|
+
return path if uri.scheme
|
61
|
+
return path if File.file?(path)
|
62
|
+
end
|
63
|
+
|
64
|
+
false
|
65
|
+
end
|
52
66
|
|
67
|
+
def configuration_file
|
68
|
+
return path if valid_path?(path)
|
69
|
+
|
53
70
|
files = []
|
54
71
|
|
55
72
|
files += [
|
@@ -69,8 +86,7 @@ class WhiskeyDisk
|
|
69
86
|
end
|
70
87
|
|
71
88
|
def configuration_data
|
72
|
-
|
73
|
-
File.read(configuration_file)
|
89
|
+
open(configuration_file) {|f| f.read }
|
74
90
|
end
|
75
91
|
|
76
92
|
def project_name
|
@@ -104,13 +120,17 @@ class WhiskeyDisk
|
|
104
120
|
{ project_name => data }
|
105
121
|
end
|
106
122
|
|
123
|
+
def localize_domain_list(list)
|
124
|
+
[ list ].flatten.collect { |d| (d.nil? or d == '') ? 'local' : d }
|
125
|
+
end
|
126
|
+
|
107
127
|
def compact_list(list)
|
108
128
|
[ list ].flatten.delete_if { |d| d.nil? or d == '' }
|
109
129
|
end
|
110
130
|
|
111
131
|
def normalize_domain(data)
|
112
|
-
compacted =
|
113
|
-
|
132
|
+
compacted = localize_domain_list(data)
|
133
|
+
compacted = [ 'local' ] if compacted.empty?
|
114
134
|
|
115
135
|
compacted.collect do |d|
|
116
136
|
if d.respond_to?(:keys)
|
@@ -124,10 +144,18 @@ class WhiskeyDisk
|
|
124
144
|
end
|
125
145
|
end
|
126
146
|
|
147
|
+
def check_duplicates(project, target, domain_list)
|
148
|
+
seen = {}
|
149
|
+
domain_list.each do |domain|
|
150
|
+
raise "duplicate domain [#{domain[:name]}] in configuration file for project [#{project}], target [#{target}]" if seen[domain[:name]]
|
151
|
+
seen[domain[:name]] = true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
127
155
|
def normalize_domains(data)
|
128
156
|
data.each_pair do |project, project_data|
|
129
157
|
project_data.each_pair do |target, target_data|
|
130
|
-
target_data['domain'] = normalize_domain(target_data['domain'])
|
158
|
+
target_data['domain'] = check_duplicates(project, target, normalize_domain(target_data['domain']))
|
131
159
|
end
|
132
160
|
end
|
133
161
|
end
|
data/lib/whiskey_disk.rb
CHANGED
@@ -40,8 +40,13 @@ class WhiskeyDisk
|
|
40
40
|
buffer << command
|
41
41
|
end
|
42
42
|
|
43
|
-
def remote?
|
44
|
-
|
43
|
+
def remote?(domain)
|
44
|
+
return false unless domain
|
45
|
+
return false if domain == 'local'
|
46
|
+
limit = WhiskeyDisk::Config.domain_limit
|
47
|
+
return false if limit and domain_limit_match?(domain, limit)
|
48
|
+
|
49
|
+
true
|
45
50
|
end
|
46
51
|
|
47
52
|
def has_config_repo?
|
@@ -108,25 +113,42 @@ class WhiskeyDisk
|
|
108
113
|
return '' if buffer.empty?
|
109
114
|
(staleness_checks_enabled? and check_staleness?) ? apply_staleness_check(join_commands) : join_commands
|
110
115
|
end
|
116
|
+
|
117
|
+
def domain_limit_match?(domain, limit)
|
118
|
+
domain.sub(%r{^.*@}, '') == limit
|
119
|
+
end
|
120
|
+
|
121
|
+
def domain_of_interest?(domain)
|
122
|
+
return true unless limit = WhiskeyDisk::Config.domain_limit
|
123
|
+
domain_limit_match?(domain, limit)
|
124
|
+
end
|
111
125
|
|
112
126
|
def encode_roles(roles)
|
113
127
|
return '' unless roles and !roles.empty?
|
114
128
|
"export WD_ROLES='#{roles.join(':')}'; "
|
115
129
|
end
|
130
|
+
|
131
|
+
def build_command(domain, cmd)
|
132
|
+
"set -x; " + encode_roles(domain[:roles]) + cmd
|
133
|
+
end
|
116
134
|
|
117
|
-
def run(cmd)
|
135
|
+
def run(domain, cmd)
|
136
|
+
system('ssh', '-v', domain[:name], build_command(domain, cmd))
|
137
|
+
end
|
138
|
+
|
139
|
+
def shell(domain, cmd)
|
140
|
+
system(build_command(domain, cmd))
|
141
|
+
end
|
142
|
+
|
143
|
+
def flush
|
118
144
|
needs(:domain)
|
119
145
|
self[:domain].each do |domain|
|
120
|
-
|
146
|
+
next unless domain_of_interest?(domain[:name])
|
147
|
+
status = remote?(domain[:name]) ? run(domain, bundle) : shell(domain, bundle)
|
121
148
|
record_result(domain[:name], status)
|
122
149
|
end
|
123
150
|
end
|
124
151
|
|
125
|
-
def flush
|
126
|
-
return run(bundle) if remote?
|
127
|
-
record_result('local', system(bundle))
|
128
|
-
end
|
129
|
-
|
130
152
|
def record_result(domain, status)
|
131
153
|
@results ||= []
|
132
154
|
@results << { :domain => domain, :status => status }
|
@@ -0,0 +1 @@
|
|
1
|
+
ref: refs/heads/master
|