deploify 0.2.5

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 (35) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +36 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +2 -0
  6. data/Rakefile +1 -0
  7. data/deploify.gemspec +29 -0
  8. data/lib/deploify/capistrano_extensions.rb +189 -0
  9. data/lib/deploify/recipes/deploify.rb +171 -0
  10. data/lib/deploify/recipes/mongodb.rb +15 -0
  11. data/lib/deploify/recipes/monit.rb +84 -0
  12. data/lib/deploify/recipes/mysql.rb +85 -0
  13. data/lib/deploify/recipes/nginx.rb +122 -0
  14. data/lib/deploify/recipes/passenger.rb +130 -0
  15. data/lib/deploify/recipes/puma.rb +15 -0
  16. data/lib/deploify/recipes/rails.rb +221 -0
  17. data/lib/deploify/recipes/thin.rb +104 -0
  18. data/lib/deploify/recipes.rb +13 -0
  19. data/lib/deploify/templates/monit/monit.conf.erb +5 -0
  20. data/lib/deploify/templates/nginx/logrotate.conf.erb +12 -0
  21. data/lib/deploify/templates/nginx/vhost_http_force_ssl.conf.erb +79 -0
  22. data/lib/deploify/templates/nginx/vhost_http_only.conf.erb +66 -0
  23. data/lib/deploify/templates/nginx/vhost_http_with_ssl.conf.erb +131 -0
  24. data/lib/deploify/templates/passenger/logrotate.conf.erb +12 -0
  25. data/lib/deploify/templates/passenger/passengerctl-lib.erb +68 -0
  26. data/lib/deploify/templates/passenger/passengerctl.erb +10 -0
  27. data/lib/deploify/templates/thin/logrotate.conf.erb +0 -0
  28. data/lib/deploify/templates/thin/thinctl-lib.erb +84 -0
  29. data/lib/deploify/templates/thin/thinctl.erb +9 -0
  30. data/lib/deploify/version.rb +12 -0
  31. data/lib/deploify.rb +7 -0
  32. data/lib/plugins/all.rb +20 -0
  33. data/lib/plugins/apt.rb +94 -0
  34. data/lib/plugins/std.rb +203 -0
  35. metadata +196 -0
@@ -0,0 +1,203 @@
1
+ # =std.rb: Capistrano Standard Methods
2
+ # Standard library of procedures and functions that you can use with Capistrano.
3
+ #
4
+ # ----
5
+ # Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
6
+ #
7
+ # Licensed under the GNU Public License v2. No warranty is provided.
8
+
9
+ require 'capistrano'
10
+
11
+ # = Purpose
12
+ # Std is a Capistrano plugin that provides a set of standard methods refactored
13
+ # out of several Capistrano task libraries.
14
+ #
15
+ # Installs within Capistrano as the plugin _std_
16
+ #
17
+ # = Usage
18
+ #
19
+ # require 'vmbuilder_plugins/std'
20
+ #
21
+ # Prefix all calls to the library with <tt>std.</tt>
22
+ module Std
23
+
24
+ begin
25
+ # Use the Mmap class if it is available
26
+ # http://moulon.inra.fr/ruby/mmap.html
27
+ require 'mmap'
28
+ MMAP=true #:nodoc:
29
+ rescue LoadError
30
+ # no MMAP class, use normal reads instead
31
+ MMAP=false #:nodoc:
32
+ end
33
+
34
+ # Copies the files specified by +file_pattern+ to +destination+
35
+ #
36
+ # Error checking is minimal - a pattern onto a single file will result in +destination+
37
+ # containing the data from the last file only.
38
+ #
39
+ # Installs via *sudo*, +options+ are as for *put*.
40
+ def fput(file_pattern, destination, options={})
41
+ logger.info file_pattern
42
+ Dir.glob(file_pattern) do |fname|
43
+ if File.readable?(fname) then
44
+ if MMAP
45
+ logger.debug "Using Memory Mapped File Upload"
46
+ fdata=Mmap.new(fname,"r", Mmap::MAP_SHARED, :advice => Mmap::MADV_SEQUENTIAL)
47
+ else
48
+ fdata=File.open(fname).read
49
+ end
50
+ su_put(fdata, destination, File.join('/tmp',File.basename(fname)), options)
51
+ else
52
+ logger.error "Unable to read file #{fname}"
53
+ end
54
+ end
55
+ end
56
+
57
+ # Upload +data+ to +temporary_area+ before installing it in
58
+ # +destination+ using sudo.
59
+ #
60
+ # +options+ are as for *put*
61
+ #
62
+ def su_put(data, destination, temporary_area='/tmp', options={})
63
+ temporary_area = File.join(temporary_area,"#{File.basename(destination)}-$CAPISTRANO:HOST$")
64
+ put(data, temporary_area, options)
65
+ send run_method, <<-CMD
66
+ sh -c "install -m#{sprintf("%3o",options[:mode]||0755)} #{temporary_area} #{destination} &&
67
+ rm -f #{temporary_area}"
68
+ CMD
69
+ end
70
+
71
+ # Copies the +file_pattern+, which is assumed to be a tar
72
+ # file of some description (gzipped or plain), and unpacks it into
73
+ # +destination+.
74
+ def unzip(file_pattern, destination, options={})
75
+ Dir.glob(file_pattern) do |fname|
76
+ if File.readable?(fname) then
77
+ target="/tmp/#{File.basename(fname)}"
78
+ if MMAP
79
+ logger.debug "Using Memory Mapped File Upload"
80
+ fdata=Mmap.new(fname,"r", Mmap::MAP_SHARED, :advice => Mmap::MADV_SEQUENTIAL)
81
+ else
82
+ fdata=File.open(fname).read
83
+ end
84
+ put(fdata, target, options)
85
+ send run_method, <<-CMD
86
+ sh -c "cd #{destination} &&
87
+ zcat -f #{target} | tar xvf - &&
88
+ rm -f #{target}"
89
+ CMD
90
+ end
91
+ end
92
+ end
93
+
94
+ # Wrap this around your task calls to catch the no servers error and
95
+ # ignore it
96
+ #
97
+ # std.ignore_no_servers_error do
98
+ # activate_mysql
99
+ # end
100
+ #
101
+ def ignore_no_servers_error (&block)
102
+ begin
103
+ yield
104
+ rescue RuntimeError => failure
105
+ if failure.message =~ /no servers matched/
106
+ logger.debug "Ignoring 'no servers matched' error in task #{current_task.name}"
107
+ else
108
+ raise
109
+ end
110
+ end
111
+ end
112
+
113
+ # Wrap this around your task to force a connection as root.
114
+ # Flushes the session cache before and after the connection.
115
+ #
116
+ # std.connect_as_root do
117
+ # install_sudo
118
+ # end
119
+ #
120
+ def connect_as_root (&block)
121
+ begin
122
+ tempuser = user
123
+ set :user, "root"
124
+ actor.sessions.delete_if { true }
125
+ yield tempuser
126
+ ensure
127
+ set :user, tempuser if tempuser
128
+ actor.sessions.delete_if { true }
129
+ end
130
+ end
131
+
132
+ #Returns a random string of alphanumeric characters of size +size+
133
+ #Useful for passwords, usernames and the like.
134
+ def random_string(size=10)
135
+ s = ""
136
+ size.times { s << (i = rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
137
+ s
138
+ end
139
+
140
+
141
+ # Return a relative path from the destination directory +from_str+
142
+ # to the target file/directory +to_str+. Used to create relative
143
+ # symbolic link paths.
144
+ def relative_path (from_str, to_str)
145
+ require 'pathname'
146
+ Pathname.new(to_str).relative_path_from(Pathname.new(from_str)).to_s
147
+ end
148
+
149
+ # Run a ruby command file on the servers
150
+ #
151
+ def ruby(cmd, options={}, &block)
152
+ temp_name = random_string + ".rb"
153
+ begin
154
+ put(cmd, temp_name, :mode => 0700)
155
+ send(run_method, "ruby #{temp_name}", options, &block)
156
+ ensure
157
+ delete temp_name
158
+ end
159
+ end
160
+
161
+ # Run a patchfile on the servers
162
+ # Ignores reverses and rejects.
163
+ #
164
+ def patch(patchfile, level = '0', where = '/')
165
+ temp_name = random_string
166
+ begin
167
+ fput(patchfile, temp_name, :mode => 0600)
168
+ send(run_method, %{
169
+ patch -p#{level} -tNd #{where} -r /dev/null < #{temp_name} || true
170
+ })
171
+ ensure
172
+ delete temp_name
173
+ end
174
+ end
175
+
176
+ # Deletes the given file(s) from all servers targetted by the current
177
+ # task, but runs the +delete+ command according to the current setting
178
+ # of <tt>:use_sudo</tt>.
179
+ #
180
+ # If <tt>:recursive => true</tt> is specified, it may be used to remove
181
+ # directories.
182
+ def su_delete(path, options={})
183
+ cmd = "rm -%sf #{path}" % (options[:recursive] ? "r" : "")
184
+ send(run_method, cmd, options)
185
+ end
186
+
187
+ # Render a template file and upload it to the servers
188
+ #
189
+ def put_template(template, destination, options={})
190
+ if MMAP
191
+ logger.debug "Using Memory Mapped File Upload"
192
+ fdata=Mmap.new(template,"r", Mmap::MAP_SHARED, :advice => Mmap::MADV_SEQUENTIAL)
193
+ else
194
+ fdata=File.read(template)
195
+ end
196
+ put(render(:template => fdata), destination, options)
197
+ end
198
+
199
+ end
200
+
201
+ Capistrano.plugin :std, Std
202
+
203
+ # vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby:
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deploify
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 5
10
+ version: 0.2.5
11
+ platform: ruby
12
+ authors:
13
+ - "Richard R\xCC\x8Ci\xCC\x81man"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-12-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bundler
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 61
29
+ segments:
30
+ - 1
31
+ - 0
32
+ - 21
33
+ version: 1.0.21
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: capistrano
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 49
45
+ segments:
46
+ - 2
47
+ - 13
48
+ - 5
49
+ version: 2.13.5
50
+ type: :development
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rvm-capistrano
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 17
61
+ segments:
62
+ - 1
63
+ - 2
64
+ - 7
65
+ version: 1.2.7
66
+ type: :development
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: bundler
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 61
77
+ segments:
78
+ - 1
79
+ - 0
80
+ - 21
81
+ version: 1.0.21
82
+ type: :runtime
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: capistrano
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 49
93
+ segments:
94
+ - 2
95
+ - 13
96
+ - 5
97
+ version: 2.13.5
98
+ type: :runtime
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ name: rvm-capistrano
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ~>
107
+ - !ruby/object:Gem::Version
108
+ hash: 17
109
+ segments:
110
+ - 1
111
+ - 2
112
+ - 7
113
+ version: 1.2.7
114
+ type: :runtime
115
+ version_requirements: *id006
116
+ description: deploify - capistrano based and deprec inspired deploy solution served as a gem
117
+ email:
118
+ - riman.richard@gmail.com
119
+ executables: []
120
+
121
+ extensions: []
122
+
123
+ extra_rdoc_files: []
124
+
125
+ files:
126
+ - .gitignore
127
+ - Gemfile
128
+ - Gemfile.lock
129
+ - LICENSE.txt
130
+ - README.md
131
+ - Rakefile
132
+ - deploify.gemspec
133
+ - lib/deploify.rb
134
+ - lib/deploify/capistrano_extensions.rb
135
+ - lib/deploify/recipes.rb
136
+ - lib/deploify/recipes/deploify.rb
137
+ - lib/deploify/recipes/mongodb.rb
138
+ - lib/deploify/recipes/monit.rb
139
+ - lib/deploify/recipes/mysql.rb
140
+ - lib/deploify/recipes/nginx.rb
141
+ - lib/deploify/recipes/passenger.rb
142
+ - lib/deploify/recipes/puma.rb
143
+ - lib/deploify/recipes/rails.rb
144
+ - lib/deploify/recipes/thin.rb
145
+ - lib/deploify/templates/monit/monit.conf.erb
146
+ - lib/deploify/templates/nginx/logrotate.conf.erb
147
+ - lib/deploify/templates/nginx/vhost_http_force_ssl.conf.erb
148
+ - lib/deploify/templates/nginx/vhost_http_only.conf.erb
149
+ - lib/deploify/templates/nginx/vhost_http_with_ssl.conf.erb
150
+ - lib/deploify/templates/passenger/logrotate.conf.erb
151
+ - lib/deploify/templates/passenger/passengerctl-lib.erb
152
+ - lib/deploify/templates/passenger/passengerctl.erb
153
+ - lib/deploify/templates/thin/logrotate.conf.erb
154
+ - lib/deploify/templates/thin/thinctl-lib.erb
155
+ - lib/deploify/templates/thin/thinctl.erb
156
+ - lib/deploify/version.rb
157
+ - lib/plugins/all.rb
158
+ - lib/plugins/apt.rb
159
+ - lib/plugins/std.rb
160
+ homepage: https://github.com/richardriman/deploify
161
+ licenses: []
162
+
163
+ post_install_message:
164
+ rdoc_options: []
165
+
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ hash: 57
174
+ segments:
175
+ - 1
176
+ - 8
177
+ - 7
178
+ version: 1.8.7
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ none: false
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ hash: 3
185
+ segments:
186
+ - 0
187
+ version: "0"
188
+ requirements: []
189
+
190
+ rubyforge_project:
191
+ rubygems_version: 1.8.24
192
+ signing_key:
193
+ specification_version: 3
194
+ summary: capistrano based and deprec inspired deploy gem
195
+ test_files: []
196
+