obbistrano 1.1.80 → 1.1.81
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.
- data/lib/obbistrano_tasks.rb +83 -103
- data/obbistrano.gemspec +1 -1
- metadata +2 -2
data/lib/obbistrano_tasks.rb
CHANGED
|
@@ -47,6 +47,14 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
|
+
|
|
51
|
+
def remote_file_exists?(full_path)
|
|
52
|
+
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def remote_command_exists?(command)
|
|
56
|
+
'true' == capture("if [ -x \"$(which #{command})\" ]; then echo 'true'; fi").strip
|
|
57
|
+
end
|
|
50
58
|
|
|
51
59
|
|
|
52
60
|
#### Performs the initial setup for tasks ####
|
|
@@ -57,107 +65,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
|
57
65
|
end
|
|
58
66
|
|
|
59
67
|
|
|
60
|
-
#### Slicehost Namespace.... Allows Auto Creation of DNS ####
|
|
61
|
-
|
|
62
|
-
namespace :slicehost do
|
|
63
|
-
|
|
64
|
-
desc "Sets up slicehost DNS for each of the servers specified with a role of web."
|
|
65
|
-
task :setup do
|
|
66
|
-
pretty_print "*** You need to set a Slicehost API key in /etc/capistrano.conf to run this operation" if !defined? SLICEHOST_API_PASSWORD
|
|
67
|
-
exit if !defined? SLICEHOST_API_PASSWORD
|
|
68
|
-
get_slice_ip
|
|
69
|
-
servers = find_servers :roles => :web
|
|
70
|
-
servers.each do |s|
|
|
71
|
-
if !zone = Zone.find(:first, :params => {:origin => "#{s}."})
|
|
72
|
-
zone = Zone.new(:origin => s, :ttl => TTL)
|
|
73
|
-
zone.save
|
|
74
|
-
end
|
|
75
|
-
recordOne = Record.new(:record_type => 'A', :zone_id => zone.id, :name => 'www', :data => "#{slice_ip}")
|
|
76
|
-
recordTwo = Record.new(:record_type => 'A', :zone_id => zone.id, :name => '@', :data => "#{slice_ip}")
|
|
77
|
-
recordThree = Record.new(:record_type => 'A', :zone_id => zone.id, :name => 'beta', :data => "#{slice_ip}")
|
|
78
|
-
recordFour = Record.new(:record_type => 'A', :zone_id => zone.id, :name => zone.origin, :data => "#{slice_ip}")
|
|
79
|
-
recordFive = Record.new(:record_type => 'NS', :zone_id => zone.id, :name => zone.origin, :data => 'ns1.slicehost.net.')
|
|
80
|
-
recordSix = Record.new(:record_type => 'NS', :zone_id => zone.id, :name => zone.origin, :data => 'ns2.slicehost.net.')
|
|
81
|
-
recordSeven = Record.new(:record_type => 'NS', :zone_id => zone.id, :name => zone.origin, :data => 'ns3.slicehost.net.')
|
|
82
|
-
[recordOne, recordTwo, recordThree, recordFour, recordFive, recordSix, recordSeven].each {|r| r.save}
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
task :get_slice_ip do
|
|
87
|
-
set :slice_ip, get_ip(fetch("host", false))
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
desc "Sets up slicehost DNS for Google Apps usage on each of the servers specified with a role of web."
|
|
91
|
-
task :googleapps do
|
|
92
|
-
pretty_print "*** You need to set a Slicehost API key in /etc/capistrano.conf to run this operation" if !defined? SLICEHOST_API_PASSWORD
|
|
93
|
-
exit if !defined? SLICEHOST_API_PASSWORD
|
|
94
|
-
SLICEHOST_API_PASSWORD = "#{slicehost_api_key}"
|
|
95
|
-
mx_records = <<-RECORD
|
|
96
|
-
ASPMX.L.GOOGLE.COM.
|
|
97
|
-
ALT1.ASPMX.L.GOOGLE.COM.
|
|
98
|
-
ALT2.ASPMX.L.GOOGLE.COM.
|
|
99
|
-
ASPMX2.GOOGLEMAIL.COM.
|
|
100
|
-
ASPMX3.GOOGLEMAIL.COM.
|
|
101
|
-
RECORD
|
|
102
|
-
servers = find_servers :roles => :web
|
|
103
|
-
servers.each do |s|
|
|
104
|
-
mx_aux = %w[5 10 10 20 20 30 ]
|
|
105
|
-
aux_count = 0
|
|
106
|
-
zone = Zone.find(:first, :params => {:origin => "#{s}."})
|
|
107
|
-
mx_records.each do |rec|
|
|
108
|
-
r = Record.new(:record_type => 'MX', :zone_id => zone.id, :name => "#{s}." , :data => "#{rec}", :aux => mx_aux[aux_count])
|
|
109
|
-
r.save
|
|
110
|
-
aux_count =+ 1
|
|
111
|
-
end
|
|
112
|
-
recordOne = Record.new(:record_type => 'CNAME', :zone_id => zone.id, :name => 'mail', :data => "ghs.google.com.")
|
|
113
|
-
recordTwo = Record.new(:record_type => 'CNAME', :zone_id => zone.id, :name => 'docs', :data => "ghs.google.com.")
|
|
114
|
-
[recordOne, recordTwo].each {|r| r.save}
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
#### Github Namespace.... Allows Auto Creation of Repository, ssh keys and Repo permissions ####
|
|
122
|
-
|
|
123
|
-
namespace :github do
|
|
124
|
-
|
|
125
|
-
task :init do
|
|
126
|
-
pretty_print "*** You need to specify a github login and token to run this operation" if !defined? "#{github_login}" || !defined? "#{github_token}"
|
|
127
|
-
exit if !defined? "#{github_login}" || !defined? "#{github_token}"
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
desc "Sets up a Github Project and allows access for the devs at One Black Bear"
|
|
131
|
-
task :setup do
|
|
132
|
-
init
|
|
133
|
-
api = GithubApi.new("#{github_login}", "#{github_token}")
|
|
134
|
-
params = {
|
|
135
|
-
:name =>"#{application}",
|
|
136
|
-
:body =>"Project for #{application}",
|
|
137
|
-
:public =>0
|
|
138
|
-
}
|
|
139
|
-
api.create_repo(params)
|
|
140
|
-
api.repo = "#{application}"
|
|
141
|
-
api.add_collaborator("rossriley")
|
|
142
|
-
api.add_collaborator("Sheldon")
|
|
143
|
-
api.add_collaborator("charlesmarshall")
|
|
144
|
-
api.add_collaborator("MichalNoskovic")
|
|
145
|
-
github:key
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
desc "Grabs the SSH key from the server and adds it to the Github deploy keys"
|
|
149
|
-
task :key do
|
|
150
|
-
init
|
|
151
|
-
api = GithubApi.new("#{github_login}", "#{github_token}")
|
|
152
|
-
app:ssh_key
|
|
153
|
-
server_ssh_key = capture("cat .ssh/id_rsa.pub")
|
|
154
|
-
server_ssh_key
|
|
155
|
-
api.add_key({:title=>"#{host}",:key=>server_ssh_key})
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
end
|
|
160
|
-
|
|
161
68
|
namespace :app do
|
|
162
69
|
|
|
163
70
|
# =============================================================================
|
|
@@ -624,13 +531,13 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
|
624
531
|
if defined? "#{newdeploy}" then
|
|
625
532
|
if defined? "#{plugins}"
|
|
626
533
|
plugins.each do |plugin|
|
|
627
|
-
|
|
534
|
+
puts "plugin: #{plugin}\n".green
|
|
628
535
|
paths << "#{build_to}/plugins/#{plugin}/resources/public/javascripts"
|
|
629
536
|
end
|
|
630
537
|
end
|
|
631
538
|
puts "--"
|
|
632
539
|
paths.each do |path|
|
|
633
|
-
puts "folders: #{path}\n"
|
|
540
|
+
puts "folders: #{path}\n".green
|
|
634
541
|
end
|
|
635
542
|
Dir.mkdir("#{build_to}/public/javascripts/build") rescue ""
|
|
636
543
|
paths.each do |bundle_directory|
|
|
@@ -695,6 +602,79 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
|
695
602
|
end
|
|
696
603
|
|
|
697
604
|
end
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
namespace :composer do
|
|
608
|
+
desc "Gets composer and installs it"
|
|
609
|
+
task :get, :roles => :app, :except => { :no_release => true } do
|
|
610
|
+
if !remote_file_exists?("#{deploy_to}/composer.phar")
|
|
611
|
+
pretty_print "--> Downloading Composer"
|
|
612
|
+
|
|
613
|
+
run "#{try_sudo} sh -c 'cd #{deploy_to} && curl -s http://getcomposer.org/installer | #{php_bin}'"
|
|
614
|
+
else
|
|
615
|
+
pretty_print "--> Updating Composer"
|
|
616
|
+
|
|
617
|
+
run "#{try_sudo} sh -c 'cd #{deploy_to} && #{php_bin} composer.phar self-update'"
|
|
618
|
+
end
|
|
619
|
+
puts_ok
|
|
620
|
+
end
|
|
621
|
+
|
|
622
|
+
desc "Updates composer"
|
|
623
|
+
task :self_update, :roles => :app, :except => { :no_release => true } do
|
|
624
|
+
pretty_print "--> Updating Composer"
|
|
625
|
+
run "#{try_sudo} sh -c 'cd #{deploy_to} && #{composer_bin} self-update'"
|
|
626
|
+
puts_ok
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
desc "Runs composer to install vendors from composer.lock file"
|
|
630
|
+
task :install, :roles => :app, :except => { :no_release => true } do
|
|
631
|
+
if composer_bin
|
|
632
|
+
composer.self_update
|
|
633
|
+
else
|
|
634
|
+
composer.get
|
|
635
|
+
set :composer_bin, "#{php_bin} composer.phar"
|
|
636
|
+
end
|
|
637
|
+
|
|
638
|
+
pretty_print "--> Installing Composer dependencies"
|
|
639
|
+
run "#{try_sudo} sh -c 'cd #{deploy_to} && #{composer_bin} install #{composer_options}'"
|
|
640
|
+
puts_ok
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
desc "Runs composer to update vendors, and composer.lock file"
|
|
644
|
+
task :update, :roles => :app, :except => { :no_release => true } do
|
|
645
|
+
if composer_bin
|
|
646
|
+
composer.self_update
|
|
647
|
+
else
|
|
648
|
+
composer.get
|
|
649
|
+
set :composer_bin, "#{php_bin} composer.phar"
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
pretty_print "--> Updating Composer dependencies"
|
|
653
|
+
run "#{try_sudo} sh -c 'cd #{deploy_to} && #{composer_bin} update #{composer_options}'"
|
|
654
|
+
puts_ok
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
desc "Dumps an optimized autoloader"
|
|
658
|
+
task :dump_autoload, :roles => :app, :except => { :no_release => true } do
|
|
659
|
+
if composer_bin
|
|
660
|
+
composer.self_update
|
|
661
|
+
else
|
|
662
|
+
composer.get
|
|
663
|
+
set :composer_bin, "#{php_bin} composer.phar"
|
|
664
|
+
end
|
|
665
|
+
|
|
666
|
+
pretty_print "--> Dumping an optimized autoloader"
|
|
667
|
+
run "#{try_sudo} sh -c 'cd #{deploy_to} && #{composer_bin} dump-autoload --optimize'"
|
|
668
|
+
puts_ok
|
|
669
|
+
end
|
|
670
|
+
|
|
671
|
+
task :copy_vendors, :except => { :no_release => true } do
|
|
672
|
+
pretty_print "--> Copying vendors from previous release"
|
|
673
|
+
|
|
674
|
+
run "vendorDir=#{current_path}/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir #{deploy_to}/vendor; fi;"
|
|
675
|
+
puts_ok
|
|
676
|
+
end
|
|
677
|
+
end
|
|
698
678
|
|
|
699
679
|
|
|
700
680
|
|
data/obbistrano.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{obbistrano}
|
|
5
|
-
s.version = "1.1.
|
|
5
|
+
s.version = "1.1.81"
|
|
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=
|