itrigga-cap_deploy 0.1.7 → 0.2.2
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/VERSION +1 -1
- data/lib/itrigga/cap_deploy/cap_tasks.rb +64 -40
- data/lib/itrigga/cap_deploy/filesystem_utils.rb +9 -0
- metadata +5 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.2
|
@@ -4,14 +4,23 @@ configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
|
4
4
|
|
5
5
|
configuration.load do
|
6
6
|
def with_role(role, &block)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
if role_defined?(role)
|
8
|
+
original, ENV['HOSTS'] = ENV['HOSTS'], find_servers(:roles =>role).map{|d| d.host}.join(",")
|
9
|
+
begin
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
ENV['HOSTS'] = original
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
17
|
+
#
|
18
|
+
# Returns true if at least 1 server has been assigned to the role
|
19
|
+
#
|
20
|
+
def role_defined?(role)
|
21
|
+
find_servers(:roles => role).count > 0
|
22
|
+
end
|
23
|
+
|
15
24
|
task :symlink_init_d_script do
|
16
25
|
puts "ensuring init_d script is symlinked"
|
17
26
|
run "test -L /etc/init.d/#{application_stub} || #{sudo} ln -s #{script_path}/init_d /etc/init.d/#{application_stub}"
|
@@ -73,22 +82,28 @@ configuration.load do
|
|
73
82
|
symlink_dir("#{shared_dir}/cache","#{web_dir}/tmp/cache")
|
74
83
|
|
75
84
|
end
|
76
|
-
|
85
|
+
|
77
86
|
task :regenerate_monit do
|
78
87
|
puts "regenerating monit config file(s)"
|
79
|
-
|
80
|
-
|
81
|
-
run "cd #{web_dir} &&
|
88
|
+
run "test -d #{shared_dir}/templates || mkdir -p #{shared_dir}/templates"
|
89
|
+
|
90
|
+
run "cd #{web_dir} && #{sudo} rake itrigga:generator PATTERN=monit TEMPLATE_DIR=#{web_dir}/script/templates OUTPUT_DIR=#{shared_dir}/templates CONFIG_FILE=`readlink /etc/#{config_file_name}` BASE_DIR=#{shared_dir}"
|
82
91
|
puts "setting permissions & ownership on monit config files"
|
83
|
-
set_permissions_on_files_in_dir( :dir=>"#{
|
92
|
+
set_permissions_on_files_in_dir( :dir=>"#{shared_dir}/templates", :ownership=>"root", :permissions=>"0700")
|
93
|
+
|
84
94
|
end
|
85
95
|
|
86
|
-
task :resymlink_monit do
|
87
|
-
|
88
|
-
|
89
|
-
puts "re-symlinking monit config"
|
90
|
-
|
91
|
-
|
96
|
+
task :resymlink_monit do
|
97
|
+
remove_dir_if_exists("/etc/monit/conf.d/#{application_stub}")
|
98
|
+
sudo "mkdir /etc/monit/conf.d/#{application_stub}"
|
99
|
+
puts "re-symlinking monit config files"
|
100
|
+
symlink_files_in_dir_by_regex("#{shared_dir}/templates","/etc/monit/conf.d/#{application_stub}",".*monit$")
|
101
|
+
|
102
|
+
# overwrite the default monit monitrc file to just have the includes for the conf.d dir
|
103
|
+
run "(test -f /etc/monit/monitrc && #{sudo} rm -f /etc/monit/monitrc) || echo no existing monitrc file"
|
104
|
+
sudo "echo \"echo 'include /etc/monit/conf.d/**/*' > /etc/monit/monitrc\" | #{sudo} bash"
|
105
|
+
run "#{sudo} chown root:root /etc/monit/monitrc && #{sudo} chmod 0700 /etc/monit/monitrc"
|
106
|
+
|
92
107
|
end
|
93
108
|
|
94
109
|
task :reload_monit do
|
@@ -97,14 +112,15 @@ configuration.load do
|
|
97
112
|
|
98
113
|
task :regenerate_logrotate do
|
99
114
|
puts "regenerating logrotate config file"
|
100
|
-
|
101
|
-
|
115
|
+
run "test -d #{shared_dir}/templates || mkdir -p #{shared_dir}/templates"
|
116
|
+
|
117
|
+
run "cd #{web_dir} && #{sudo} rake itrigga:generator PATTERN=logrotate TEMPLATE_DIR=#{web_dir}/script/templates OUTPUT_DIR=#{shared_dir}/templates CONFIG_FILE=false BASE_DIR=#{shared_dir}"
|
102
118
|
puts "setting permissions & ownership on logrotate config files"
|
103
|
-
set_permissions_on_files_in_dir( :dir=>"#{
|
119
|
+
set_permissions_on_files_in_dir( :dir=>"#{shared_dir}/templates", :ownership=>"root", :permissions=>"0700" )
|
104
120
|
end
|
105
121
|
|
106
122
|
task :resymlink_logrotate do
|
107
|
-
logrotate_config_file = "#{
|
123
|
+
logrotate_config_file = "#{shared_dir}/templates/logrotate"
|
108
124
|
std_logrotate_file = "/etc/logrotate.d/#{application_stub}"
|
109
125
|
puts "re-symlinking logrotate config"
|
110
126
|
run "(test -L #{std_logrotate_file} && #{sudo} rm #{std_logrotate_file}) || echo nothing to remove"
|
@@ -118,39 +134,47 @@ configuration.load do
|
|
118
134
|
|
119
135
|
task :regenerate_db_scripts do
|
120
136
|
puts "regenerating db scripts"
|
121
|
-
|
122
|
-
remove_dir_if_exists( "#{web_dir}/script/db" )
|
123
|
-
run "cd #{web_dir} && ruby script/generate db"
|
124
|
-
|
125
|
-
puts "setting permissions & ownership on cron and db scripts"
|
126
|
-
set_permissions_on_files_in_dir( :dir=>"#{web_dir}/script/db", :ownership=>"root", :permissions=>"0700" )
|
127
137
|
end
|
128
138
|
|
129
139
|
task :regenerate_cron_scripts do
|
130
140
|
puts "regenerating cron scripts"
|
141
|
+
run "test -d #{shared_dir}/templates || mkdir -p #{shared_dir}/templates"
|
131
142
|
|
132
|
-
|
133
|
-
|
143
|
+
with_role :solr do
|
144
|
+
solr_lockfile_script_path = File.join(shared_dir,"templates","solr_lockfile_check.script")
|
145
|
+
run "cd #{web_dir} && #{sudo} rake itrigga:generator PATTERN=solr_lockfile_check.cron TEMPLATE_DIR=#{web_dir}/script/templates OUTPUT_DIR=#{shared_dir}/templates CONFIG_FILE=false SOLR_LOCKFILE_SCRIPT_PATH=#{solr_lockfile_script_path}"
|
146
|
+
end
|
134
147
|
|
135
148
|
puts "setting permissions & ownership on cron scripts"
|
136
|
-
|
149
|
+
set_permissions_on_files_in_dir( :dir=>"#{shared_dir}/templates", :ownership=>"root", :permissions=>"0700" )
|
137
150
|
end
|
138
151
|
|
139
|
-
task :
|
140
|
-
puts "
|
141
|
-
run "cd #{web_dir} && ruby script/generate scripting -f"
|
152
|
+
task :symlink_cron_scripts do
|
153
|
+
puts "symlinking any cron scripts in scripts/cron into /etc/cron.d/"
|
142
154
|
|
143
|
-
|
144
|
-
|
155
|
+
sudo "rm -f /etc/cron.d/solr_lockfile_check"
|
156
|
+
symlink_files_in_dir_by_regex("#{shared_dir}/templates","/etc/cron.d",".*cron$")
|
157
|
+
|
158
|
+
# because cron is stupid any symlinks in /etc/cron.d/ that end in .cron will *not* be run. Not at all. So lets fix those up
|
159
|
+
# removes the .cron from the end of any symlinks on /etc/cron.d/
|
160
|
+
run "echo 'for f in `find /etc/cron.d/ -type l -name '*.cron'`;do ln -s `readlink $f` ${f/.cron/} && rm $f; done' | #{sudo} bash"
|
145
161
|
|
162
|
+
# give cron a kick to pick up the new changes
|
163
|
+
sudo "service cron reload"
|
146
164
|
end
|
147
165
|
|
148
|
-
|
149
|
-
puts "
|
166
|
+
task :regenerate_monitoring_scripts do
|
167
|
+
puts "regenerating monitoring scripts"
|
168
|
+
run "test -d #{shared_dir}/templates || mkdir -p #{shared_dir}/templates"
|
150
169
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
170
|
+
with_role :solr do
|
171
|
+
solr_lockfile_path = File.join(shared_dir,"solr","data","index","*.lock")
|
172
|
+
run "cd #{web_dir} && #{sudo} rake itrigga:generator PATTERN=solr_lockfile_check.script TEMPLATE_DIR=#{web_dir}/script/templates OUTPUT_DIR=#{shared_dir}/templates CONFIG_FILE=false SOLR_LOCKFILE_PATH=#{solr_lockfile_path} SOLR_TIMEOUT=900"
|
173
|
+
end
|
174
|
+
|
175
|
+
puts "setting permissions and ownership for solr_lockfile check script"
|
176
|
+
set_permissions_on_files_in_dir( :dir=>"#{shared_dir}/templates", :ownership=>"root", :permissions=>"0700" )
|
155
177
|
end
|
178
|
+
|
179
|
+
|
156
180
|
end
|
@@ -12,6 +12,15 @@
|
|
12
12
|
|
13
13
|
run "(#{sudo} test -d #{from_dir} && ( find #{from_dir}/ -mindepth 1 -print | xargs --verbose #{sudo} ln -s -f -t #{to_dir} ) ) || echo 'nothing to link'"
|
14
14
|
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Symlinks the files in from_dir matching the regex into the to_dir
|
18
|
+
#
|
19
|
+
def symlink_files_in_dir_by_regex(from_dir,to_dir,regex)
|
20
|
+
delete_files_from_dir1_which_exist_in_dir2(to_dir, from_dir)
|
21
|
+
|
22
|
+
run "(#{sudo} test -d #{from_dir} && ( find #{from_dir}/ -mindepth 1 -regex '#{regex}' -print | xargs --verbose #{sudo} ln -s -f -t #{to_dir} ) ) || echo 'nothing to link'"
|
23
|
+
end
|
15
24
|
|
16
25
|
def mkdir_unless_exists( dir )
|
17
26
|
run "test -d #{dir} || #{sudo} mkdir -p #{dir}"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itrigga-cap_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Al Davidson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-10-05 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|