obbistrano 1.1.72 → 1.1.73

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.
Files changed (3) hide show
  1. data/lib/obbistrano_tasks.rb +103 -101
  2. data/obbistrano.gemspec +1 -1
  3. metadata +3 -3
@@ -1,5 +1,5 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
-
2
+
3
3
  #### Performs the initial setup for tasks ####
4
4
  task :config_setup do
5
5
  set :root_pass, root rescue nil
@@ -7,11 +7,11 @@ Capistrano::Configuration.instance(:must_exist).load do
7
7
  set :build_to, build_to rescue set :build_to, deploy_to
8
8
  end
9
9
 
10
-
10
+
11
11
  #### Slicehost Namespace.... Allows Auto Creation of DNS ####
12
-
12
+
13
13
  namespace :slicehost do
14
-
14
+
15
15
  desc "Sets up slicehost DNS for each of the servers specified with a role of web."
16
16
  task :setup do
17
17
  puts "*** You need to set a Slicehost API key in /etc/capistrano.conf to run this operation" if !defined? SLICEHOST_API_PASSWORD
@@ -33,7 +33,7 @@ Capistrano::Configuration.instance(:must_exist).load do
33
33
  [recordOne, recordTwo, recordThree, recordFour, recordFive, recordSix, recordSeven].each {|r| r.save}
34
34
  end
35
35
  end
36
-
36
+
37
37
  task :get_slice_ip do
38
38
  set :slice_ip, get_ip(fetch("host", false))
39
39
  end
@@ -65,19 +65,19 @@ Capistrano::Configuration.instance(:must_exist).load do
65
65
  [recordOne, recordTwo].each {|r| r.save}
66
66
  end
67
67
  end
68
-
68
+
69
69
  end
70
70
 
71
71
 
72
72
  #### Github Namespace.... Allows Auto Creation of Repository, ssh keys and Repo permissions ####
73
73
 
74
74
  namespace :github do
75
-
75
+
76
76
  task :init do
77
77
  puts "*** You need to specify a github login and token to run this operation" if !defined? "#{github_login}" || !defined? "#{github_token}"
78
78
  exit if !defined? "#{github_login}" || !defined? "#{github_token}"
79
79
  end
80
-
80
+
81
81
  desc "Sets up a Github Project and allows access for the devs at One Black Bear"
82
82
  task :setup do
83
83
  init
@@ -95,7 +95,7 @@ Capistrano::Configuration.instance(:must_exist).load do
95
95
  api.add_collaborator("MichalNoskovic")
96
96
  github:key
97
97
  end
98
-
98
+
99
99
  desc "Grabs the SSH key from the server and adds it to the Github deploy keys"
100
100
  task :key do
101
101
  init
@@ -105,16 +105,16 @@ Capistrano::Configuration.instance(:must_exist).load do
105
105
  server_ssh_key
106
106
  api.add_key({:title=>"#{host}",:key=>server_ssh_key})
107
107
  end
108
-
108
+
109
109
 
110
110
  end
111
-
112
- namespace :app do
111
+
112
+ namespace :app do
113
113
 
114
114
  # =============================================================================
115
115
  # DEPLOYING APPLICATIONS
116
116
  # =============================================================================
117
-
117
+
118
118
  task :full_deploy, :roles =>[:web] do
119
119
  host.config_check
120
120
  deploy_check
@@ -123,7 +123,7 @@ Capistrano::Configuration.instance(:must_exist).load do
123
123
  bundle.css
124
124
  bundle.js
125
125
  end
126
-
126
+
127
127
  desc "Deploys the application only - no Framework / Plugins"
128
128
  task :deploy, :roles =>[:web] do
129
129
  host.config_check
@@ -131,14 +131,14 @@ Capistrano::Configuration.instance(:must_exist).load do
131
131
  bundle.css
132
132
  bundle.js
133
133
  end
134
-
135
- task :deploy_check, :roles =>[:web] do
134
+
135
+ task :deploy_check, :roles =>[:web] do
136
136
  fetch "repository" rescue abort "You have not specified a repository for this application"
137
137
  git_copy if deploy_via=="copy" rescue ""
138
138
  git_deploy if repository.include? "git"
139
139
  svn_deploy if repository.include? "svn"
140
140
  end
141
-
141
+
142
142
  task :git_copy, :roles=>[:web] do
143
143
  Dir.mkdir("tmp/deploy_cache") rescue ""
144
144
  system("git clone --depth 1 #{repository} tmp/deploy_cache/" )
@@ -146,16 +146,16 @@ Capistrano::Configuration.instance(:must_exist).load do
146
146
  upload "tmp/deploy_cache/", "#{deploy_to}", :via => :scp, :recursive=>true
147
147
  FileUtils.rm_rf 'tmp/deploy_cache'
148
148
  end
149
-
149
+
150
150
  task :git_deploy, :roles =>[:web] do
151
151
  logger.level = 2
152
-
152
+
153
153
  set :local_branch, $1 if `git branch` =~ /\* (\S+)\s/m
154
154
  if !local_branch.eql? branch
155
- logger.info "You are on branch #{local_branch}, not #{branch}, please check out there before deploying to be able to combine the correct js and css files."
155
+ logger.info "You are on branch #{local_branch}, not #{branch}, please check out there before deploying to be able to combine the correct js and css files."
156
156
  exit
157
157
  end
158
-
158
+
159
159
  if defined? "#{commit}"
160
160
  logger.info "Deploying application from #{repository} on commit #{commit}"
161
161
  else
@@ -170,9 +170,9 @@ Capistrano::Configuration.instance(:must_exist).load do
170
170
  run "cd #{deploy_to} && git remote add origin #{repository}"
171
171
  end
172
172
  logger.level = 2
173
-
173
+
174
174
  run "cd #{deploy_to} && git fetch"
175
-
175
+
176
176
  if defined? "#{commit}"
177
177
  run "cd #{deploy_to} && git checkout #{commit} && git submodule update --init --recursive"
178
178
  else
@@ -182,14 +182,14 @@ Capistrano::Configuration.instance(:must_exist).load do
182
182
  run "cd #{deploy_to} && git checkout -b #{branch} origin/#{branch} && git submodule update --init --recursive"
183
183
  end
184
184
  end
185
-
185
+
186
186
  logger.info "Application has been updated on branch #{branch}"
187
187
  end
188
-
188
+
189
189
  task :svn_deploy, :roles =>[:web] do
190
190
  run "svn export #{repository} #{deploy_to} --force"
191
191
  end
192
-
192
+
193
193
  task :cms_deploy, :roles =>[:web] do
194
194
  logger.level = -1
195
195
  run "mkdir -p #{deploy_to}/plugins/cms"
@@ -213,8 +213,8 @@ Capistrano::Configuration.instance(:must_exist).load do
213
213
  logger.level = 2
214
214
  logger.info "Wildfire CMS has been updated on branch #{cms}"
215
215
  end
216
-
217
-
216
+
217
+
218
218
  task :php_wax_deploy, :roles =>[:web] do
219
219
  logger.level = -1
220
220
  run "mkdir -p #{deploy_to}/wax"
@@ -238,30 +238,30 @@ Capistrano::Configuration.instance(:must_exist).load do
238
238
  logger.level = 3
239
239
  logger.info "PHP Wax has been updated on branch #{phpwax}"
240
240
  end
241
-
242
-
241
+
242
+
243
243
  # =============================================================================
244
244
  # GENERAL ADMIN FOR APPLICATIONS
245
245
  # =============================================================================
246
-
246
+
247
247
  desc "Clears the application's cache files from tmp/cache."
248
248
  task :clearcache, :roles =>[:web] do
249
249
  run "cd #{deploy_to} && find tmp/cache -type f -exec rm -f \"{}\" \\;"
250
250
  end
251
-
251
+
252
252
  desc "Clears the application's log files from tmp/log."
253
253
  task :clearlogs, :roles =>[:web] do
254
254
  run "cd #{deploy_to} && find tmp/log -type f -exec rm -f \"{}\" \\;"
255
255
  end
256
-
257
-
256
+
257
+
258
258
  desc "Uses configs in the app/platform directory to configure servers"
259
- task :install, :roles =>[:host] do
259
+ task :install, :roles =>[:host] do
260
260
  host.config_check
261
261
  host.needs_root
262
262
  set :user_to_config, "#{user}"
263
263
  begin
264
- with_user("root", "#{root_pass}") do
264
+ with_user("root", "#{root_pass}") do
265
265
  run "rm -f /etc/nginx/sites-enabled/#{user_to_config}.conf; ln -s /home/#{user_to_config}/#{deploy_to}/app/platform/nginx.conf /etc/nginx/sites-enabled/#{user_to_config}.conf"
266
266
  run "rm -f /etc/apache2/sites-enabled/#{user_to_config}.conf; ln -s /home/#{user_to_config}/#{deploy_to}/app/platform/apache.conf /etc/apache2/sites-enabled/#{user_to_config}.conf"
267
267
  end
@@ -269,10 +269,10 @@ Capistrano::Configuration.instance(:must_exist).load do
269
269
  logger.info "Writing User Cron File"
270
270
  write_crontab(user_cron_tasks)
271
271
  rescue
272
-
272
+
273
273
  end
274
274
  end
275
-
275
+
276
276
  def write_crontab(data)
277
277
  tmp_cron_file = Tempfile.new('temp_cron').path
278
278
  File.open(tmp_cron_file, File::WRONLY | File::APPEND) do |file|
@@ -291,8 +291,8 @@ Capistrano::Configuration.instance(:must_exist).load do
291
291
  exit(1)
292
292
  end
293
293
  end
294
-
295
-
294
+
295
+
296
296
  end
297
297
 
298
298
 
@@ -302,22 +302,22 @@ Capistrano::Configuration.instance(:must_exist).load do
302
302
  t[3]
303
303
  end
304
304
 
305
- def with_user(new_user, new_pass, &block)
306
- old_user, old_pass = user, password
307
- set :user, new_user
308
- set :password, new_pass
309
- close_sessions
310
- yield
311
- set :user, old_user
312
- set :password, old_pass
313
- close_sessions
314
- end
315
- def close_sessions
316
- sessions.values.each { |session| session.close }
317
- sessions.clear
305
+ def with_user(new_user, new_pass, &block)
306
+ old_user, old_pass = user, password
307
+ set :user, new_user
308
+ set :password, new_pass
309
+ close_sessions
310
+ yield
311
+ set :user, old_user
312
+ set :password, old_pass
313
+ close_sessions
318
314
  end
319
-
320
-
315
+ def close_sessions
316
+ sessions.values.each { |session| session.close }
317
+ sessions.clear
318
+ end
319
+
320
+
321
321
  namespace :deploy do
322
322
  desc "Uses the specified repository to deploy an application. Also checks for correct versions of PHPWax and plugins."
323
323
  task :default, :roles => [:web] do
@@ -325,17 +325,17 @@ Capistrano::Configuration.instance(:must_exist).load do
325
325
  app.full_deploy
326
326
  end
327
327
  end
328
-
328
+
329
329
  namespace :setup do
330
330
  desc "Sets up the server with a user, home directory and mysql login."
331
331
  task :default do
332
332
  host.setup
333
333
  end
334
334
  end
335
-
336
- namespace :host do
337
-
338
-
335
+
336
+ namespace :host do
337
+
338
+
339
339
  desc "Sets up the server with a user, home directory and mysql login."
340
340
  task :setup, :roles => [:host] do
341
341
  try_login
@@ -345,25 +345,25 @@ Capistrano::Configuration.instance(:must_exist).load do
345
345
 
346
346
  desc "Restarts the web server."
347
347
  task :restart, :roles => [:host] do
348
- needs_root
348
+ needs_root
349
349
  fedora.restart
350
350
  end
351
-
351
+
352
352
  desc "Creates a new Apache VHost."
353
353
  task :vhost, :roles => [:host] do
354
354
  needs_root
355
355
  fedora.vhost
356
356
  fedora.restart
357
357
  end
358
-
358
+
359
359
  desc "Sets up a new user."
360
360
  task :setup_user, :roles => [:host] do
361
361
  needs_root
362
362
  fedora.setup_user
363
363
  end
364
-
364
+
365
365
  desc "Creates or gets an ssh key for the application"
366
- task :ssh_key, :roles =>[:host] do
366
+ task :ssh_key, :roles =>[:host] do
367
367
  config_check
368
368
  begin
369
369
  run "cat .ssh/id_rsa.pub"
@@ -373,7 +373,7 @@ Capistrano::Configuration.instance(:must_exist).load do
373
373
  run "cat .ssh/id_rsa.pub"
374
374
  end
375
375
  end
376
-
376
+
377
377
  desc "Creates a MySQL user and database"
378
378
  task :setup_mysql, :roles =>[:host] do
379
379
  needs_root
@@ -391,7 +391,7 @@ Capistrano::Configuration.instance(:must_exist).load do
391
391
  end
392
392
  end
393
393
  end
394
-
394
+
395
395
  desc "Detects what flavour of linux is being used"
396
396
  task :detect_os, :roles =>[:host] do
397
397
  begin
@@ -406,30 +406,30 @@ Capistrano::Configuration.instance(:must_exist).load do
406
406
  end
407
407
  eval "#{os_ver}".testos
408
408
  end
409
-
410
-
411
-
409
+
410
+
411
+
412
412
  # =============================================================================
413
413
  # +MIGRATING+ APPLICATIONS
414
414
  # =============================================================================
415
-
416
-
417
-
418
-
415
+
416
+
417
+
418
+
419
419
  ###### Private tasks for server operations #############
420
-
420
+
421
421
  task :config_check do
422
422
  config_setup
423
423
  databases rescue set(:databases, ["#{application}"])
424
424
  aliases rescue set(:aliases, []);
425
425
  end
426
-
426
+
427
427
  task :needs_root do
428
428
  puts "*** This operation needs root access - Please set a root password inside your /etc/capistrano.conf file" if !defined? "#{root_pass}"
429
429
  exit if !defined? "#{root_pass}"
430
430
  config_check
431
431
  end
432
-
432
+
433
433
  task :try_login, :roles =>[:host] do
434
434
  config_check
435
435
  begin
@@ -443,22 +443,22 @@ Capistrano::Configuration.instance(:must_exist).load do
443
443
  setup_user
444
444
  end
445
445
  end
446
-
446
+
447
447
  end
448
-
448
+
449
449
  namespace :fedora do
450
450
 
451
451
  task :setup_user, :roles =>[:host] do
452
452
  set :user_to_add, "#{user}"
453
453
  set :passwd_to_add, "#{password}"
454
- with_user("root", "#{root_pass}") do
454
+ with_user("root", "#{root_pass}") do
455
455
  run "useradd -m -r -p `openssl passwd #{passwd_to_add}` #{user_to_add}"
456
456
  run "chmod -R 0755 /home/#{user_to_add}"
457
457
  end
458
458
  end
459
-
459
+
460
460
  task :vhost, :roles =>[:host] do
461
- with_user("root", "#{root_pass}") do
461
+ with_user("root", "#{root_pass}") do
462
462
  public_ip = ""
463
463
  run "ifconfig eth0 | grep inet | awk '{print $2}' | sed 's/addr://'" do |_, _, public_ip| end
464
464
  public_ip = public_ip.strip
@@ -469,31 +469,31 @@ Capistrano::Configuration.instance(:must_exist).load do
469
469
  buffer = ERB.new(contents)
470
470
  config = buffer.result(binding())
471
471
  put config, "/etc/httpd/conf.d/#{webserver}-apache-vhost.conf"
472
- end
472
+ end
473
473
  end
474
474
  end
475
475
 
476
476
  task :restart, :roles =>[:host] do
477
- with_user("root", "#{root_pass}") do
477
+ with_user("root", "#{root_pass}") do
478
478
  run "/etc/init.d/httpd restart"
479
479
  end
480
480
  end
481
-
482
- task :ostest, :roles => [:host] do
481
+
482
+ task :ostest, :roles => [:host] do
483
483
  puts "#{os_ver}"
484
484
  exit
485
485
  end
486
486
 
487
487
  end
488
-
488
+
489
489
  namespace :ubuntu do
490
- task :ostest, :roles => [:host] do
490
+ task :ostest, :roles => [:host] do
491
491
  puts "#{os_ver}"
492
492
  exit
493
493
  end
494
494
  end
495
-
496
- task :mirror do
495
+
496
+ task :mirror do
497
497
  print "==== Which server would you like to copy #{application} to? [Full Domain Name] "
498
498
  new_server = STDIN.gets.strip
499
499
  old_roles = roles[:web]
@@ -508,25 +508,26 @@ Capistrano::Configuration.instance(:must_exist).load do
508
508
  "#{databases}".each do |db|
509
509
  run "mysqldump #{db} | ssh #{user}@#{new_server} mysql #{db}"
510
510
  end
511
-
512
- end
513
511
 
512
+ end
514
513
 
515
- namespace :bundle do
514
+
515
+ namespace :bundle do
516
516
 
517
517
  task :css, :roles => [:web] do
518
518
  paths = get_top_level_directories("#{build_to}/public/stylesheets")
519
- if defined? "#{newdeploy}" then
519
+ if defined? "#{newdeploy}" then
520
520
  paths << "#{build_to}/public/stylesheets/"
521
521
  if defined? "#{plugins}"
522
522
  plugins.each do |plugin|
523
+ print "#{plugin}"
523
524
  paths << "#{build_to}/plugins/#{plugin}/resources/public/stylesheets"
524
525
  end
525
526
  end
526
527
  Dir.mkdir("#{build_to}/public/stylesheets/build") rescue ""
527
- paths.each do |bundle_directory|
528
- bundle_name = bundle_directory.gsub(/(\/plugins)|(resources)|(public)|(stylesheets)|(\/)/i, "")
529
- bundle_name = if(bundle_name.index(".") == 0) then bundle_name[1..bundle_name.length] else bundle_name end
528
+ paths.each do |bundle_directory|
529
+ bundle_name = bundle_directory.gsub("#{build_to}/", "").gsub("plugins/", "").gsub("/resources/public/stylesheets", "")
530
+ puts " #{bundle_name}"
530
531
  next if bundle_name.empty?
531
532
  files = recursive_file_list(bundle_directory, ".css")
532
533
  next if files.empty? || bundle_name == 'dev'
@@ -542,6 +543,7 @@ Capistrano::Configuration.instance(:must_exist).load do
542
543
  paths << "#{build_to}/public/stylesheets/"
543
544
  Dir.mkdir("#{build_to}/public/stylesheets/build") rescue ""
544
545
  paths.each do |bundle_directory|
546
+ puts bundle_directory
545
547
  bundle_name = if bundle_directory.index("plugins") then bundle_directory.gsub("#{build_to}/plugins/cms/resources/public/stylesheets", "") else bundle_directory.gsub("#{build_to}/public/stylesheets/", "") end
546
548
  bundle_name = if bundle_name.index("/") then bundle_name[0..bundle_name.index("/")-1] else bundle_name end
547
549
  next if bundle_name.empty?
@@ -560,7 +562,7 @@ Capistrano::Configuration.instance(:must_exist).load do
560
562
 
561
563
  task :js , :roles => [:web] do
562
564
  paths = get_top_level_directories("#{build_to}/public/javascripts")
563
- if defined? "#{newdeploy}" then
565
+ if defined? "#{newdeploy}" then
564
566
  paths << "#{build_to}/public/javascripts/"
565
567
  if defined? "#{plugins}"
566
568
  plugins.each do |plugin|
@@ -570,8 +572,8 @@ Capistrano::Configuration.instance(:must_exist).load do
570
572
  Dir.mkdir("#{build_to}/public/javascripts/build") rescue ""
571
573
  paths.each do |bundle_directory|
572
574
  puts bundle_directory
573
- bundle_name = bundle_directory.gsub(/(\/plugins)|(resources)|(public)|(javascripts)|(\/)/i, "")
574
- bundle_name = if(bundle_name.index(".") == 0) then bundle_name[1..bundle_name.length] else bundle_name end
575
+ bundle_name = bundle_directory.gsub("#{build_to}/", "").gsub("plugins/", "").gsub("/resources/public/javascripts", "")
576
+ puts " #{bundle_name}"
575
577
  next if bundle_name.empty?
576
578
  files = recursive_file_list(bundle_directory, ".js")
577
579
  next if files.empty? || bundle_name == 'dev'
@@ -603,7 +605,7 @@ Capistrano::Configuration.instance(:must_exist).load do
603
605
  upload "#{build_to}/public/javascripts/build", "#{deploy_to}/public/javascripts/", :via => :scp, :recursive=>true
604
606
 
605
607
  end
606
-
608
+
607
609
 
608
610
  require 'find'
609
611
  def recursive_file_list(basedir, ext)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{obbistrano}
5
- s.version = "1.1.72"
5
+ s.version = "1.1.73"
6
6
  s.authors = ["Ross Riley", "One Black Bear"]
7
7
  s.date = Time.now
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 72
9
- version: 1.1.72
8
+ - 73
9
+ version: 1.1.73
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ross Riley
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-23 00:00:00 +00:00
18
+ date: 2012-05-02 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency