capistrano-magento2 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 548f3c638350c7873876db3869f74c22003c02f7
4
- data.tar.gz: 69a9f0dbe7e4e119b081b5b60d016aef69cb5700
3
+ metadata.gz: 6a81db107c4c34b425b713d6fa60472526266e14
4
+ data.tar.gz: 5a3bf1bb110c1f121a3063a6d67a32a3346cba96
5
5
  SHA512:
6
- metadata.gz: a6b6854c65c9833dc2aef4c6bd4d2f9fdd98c8b0bf6857bd89d88812058e68a98e657d6b3e64dd2fc4a3148918df926867dacb36d2a465b36382893ac55fb79b
7
- data.tar.gz: 1e10f1c370c2f6429dd973e1930740cdb11c2c228c050a613f3a6db2f7b2700bd7a61be5eae259338ac336f3fac96f0b74d4d704d9338bfea6beaec369602a6c
6
+ metadata.gz: 1f4f5c17e3e55132443b1bae1658ef3d09ac434a09b10d14709a23707200a51b1adedff986f1d5ca83f54ff86957b3c84fc12c6ba47082ef924e3b9255295e0c
7
+ data.tar.gz: ea57f3391c18f3ec8388fb5fe96a97c1405c26dad2b62ec87810a014c22dd053eae1c18092acad7f1d5b60db8e4a2fc4fcee40a32e6b2ffeaf4c512ee13641bd
@@ -1,5 +1,14 @@
1
1
  # Capistrano::Magento2 Change Log
2
2
 
3
+ 0.5.3
4
+ ==========
5
+
6
+ * Added setting `:magento_deploy_cache_shared` for targeting cache related tasks (issue #33)
7
+ * Added setting `:magento_deploy_setup_role` for targeting setup related tasks (issue #33)
8
+ * Fixed magento setup, cache, index commands to only run on appropriate node(s) in multi-node deploys (issue #33).
9
+ * Fixed capistrano-pending support to play nicely with multiple hosts. Now only performs check on a single host.
10
+ * Updated `magento:deploy:verify` output with host specific messaging on configuration errors.
11
+
3
12
  0.5.2
4
13
  ==========
5
14
 
data/README.md CHANGED
@@ -109,17 +109,19 @@ Before you can use Capistrano to deploy, you must configure the `config/deploy.r
109
109
 
110
110
  ### Magento Deploy Settings
111
111
 
112
- | setting | default | what it does
113
- | ----------------------------- | ------- | ---
114
- | `:magento_deploy_languages` | `['en_US']` | Array of languages passed to static content deploy routine
115
- | `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy routine (Magento 2.1+ only)
116
- | `:magento_deploy_composer` | `true` | Enables composer install behaviour in the built-in deploy routine
117
- | `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation
118
- | `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs
119
- | `:magento_deploy_confirm` | `[]` | Used to require confirmation of deployment to a set of capistrano stages
120
- | `:magento_deploy_chmod_d` | `2770` | Default permissions applied to all directories in the release path
121
- | `:magento_deploy_chmod_f` | `0660` | Default permissions applied to all non-executable files in the release path
122
- | `:magento_deploy_chmod_x` | `['bin/magento']` | Default list of files in release path to set executable bit on
112
+ | setting | default | what it does
113
+ | ------------------------------ | ------- | ---
114
+ | `:magento_deploy_setup_role` | `:all` | Role from which primary host is chosen to run things like setup:upgrade on
115
+ | `:magento_deploy_cache_shared` | `true` | If true, cache operations are restricted to the primary node in setup role
116
+ | `:magento_deploy_languages` | `['en_US']` | Array of languages passed to static content deploy routine
117
+ | `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy routine (Magento 2.1+ only)
118
+ | `:magento_deploy_composer` | `true` | Enables composer install behaviour in the built-in deploy routine
119
+ | `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation
120
+ | `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs
121
+ | `:magento_deploy_confirm` | `[]` | Used to require confirmation of deployment to a set of capistrano stages
122
+ | `:magento_deploy_chmod_d` | `2770` | Default permissions applied to all directories in the release path
123
+ | `:magento_deploy_chmod_f` | `0660` | Default permissions applied to all non-executable files in the release path
124
+ | `:magento_deploy_chmod_x` | `['bin/magento']` | Default list of files in release path to set executable bit on
123
125
 
124
126
  #### Example Usage
125
127
 
@@ -7,4 +7,12 @@
7
7
  # http://davidalger.com/contact/
8
8
  ##
9
9
 
10
+ module Capistrano
11
+ class Magento2
12
+ def self.cache_hosts
13
+ return fetch(:magento_deploy_cache_shared) ? (primary fetch :magento_deploy_setup_role) : (release_roles :all)
14
+ end
15
+ end
16
+ end
17
+
10
18
  load File.expand_path('../tasks/magento.rake', __FILE__)
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Capistrano
11
11
  module Magento2
12
- VERSION = '0.5.2'
12
+ VERSION = '0.5.3'
13
13
  end
14
14
  end
@@ -19,47 +19,36 @@ namespace :deploy do
19
19
  end
20
20
 
21
21
  task :updated do
22
+ invoke 'magento:deploy:verify'
23
+ invoke 'magento:composer:install' if fetch(:magento_deploy_composer)
24
+ invoke 'magento:setup:permissions'
25
+ if fetch(:magento_deploy_production)
26
+ invoke 'magento:setup:static-content:deploy'
27
+ invoke 'magento:setup:di:compile'
28
+ end
29
+ invoke 'magento:setup:permissions'
30
+ invoke 'magento:maintenance:enable' if fetch(:magento_deploy_maintenance)
31
+
22
32
  on release_roles :all do
23
- invoke 'magento:deploy:verify'
24
- invoke 'magento:composer:install' if fetch(:magento_deploy_composer)
25
- invoke 'magento:setup:permissions'
26
- if fetch(:magento_deploy_production)
27
- invoke 'magento:setup:static-content:deploy'
28
- invoke 'magento:setup:di:compile'
29
- end
30
- invoke 'magento:setup:permissions'
31
- invoke 'magento:maintenance:enable' if fetch(:magento_deploy_maintenance)
32
33
  if test "[ -f #{current_path}/bin/magento ]"
33
34
  within current_path do
34
35
  execute :magento, 'maintenance:enable' if fetch(:magento_deploy_maintenance)
35
36
  end
36
37
  end
37
- invoke 'magento:setup:upgrade'
38
38
  end
39
+
40
+ invoke 'magento:setup:upgrade'
39
41
  end
40
42
 
41
43
  task :published do
42
- on release_roles :all do
43
- invoke 'magento:cache:flush'
44
- invoke 'magento:cache:varnish:ban'
45
- invoke 'magento:maintenance:disable' if fetch(:magento_deploy_maintenance)
46
- end
44
+ invoke 'magento:cache:flush'
45
+ invoke 'magento:cache:varnish:ban'
46
+ invoke 'magento:maintenance:disable' if fetch(:magento_deploy_maintenance)
47
47
  end
48
48
 
49
49
  task :reverted do
50
- on release_roles :all do
51
- invoke 'magento:maintenance:disable' if fetch(:magento_deploy_maintenance)
52
- invoke 'magento:cache:flush'
53
- invoke 'magento:cache:varnish:ban'
54
- end
55
- end
56
- end
57
-
58
- namespace :load do
59
- task :defaults do
60
- set :magento_deploy_composer, fetch(:magento_deploy_composer, true)
61
- set :magento_deploy_confirm, fetch(:magento_deploy_confirm, [])
62
- set :magento_deploy_maintenance, fetch(:magento_deploy_maintenance, true)
63
- set :magento_deploy_production, fetch(:magento_deploy_production, true)
50
+ invoke 'magento:maintenance:disable' if fetch(:magento_deploy_maintenance)
51
+ invoke 'magento:cache:flush'
52
+ invoke 'magento:cache:varnish:ban'
64
53
  end
65
54
  end
@@ -12,7 +12,7 @@ namespace :magento do
12
12
  namespace :cache do
13
13
  desc 'Flush Magento cache storage'
14
14
  task :flush do
15
- on release_roles :all do
15
+ on Capistrano::Magento2.cache_hosts do
16
16
  within release_path do
17
17
  execute :magento, 'cache:flush'
18
18
  end
@@ -21,7 +21,7 @@ namespace :magento do
21
21
 
22
22
  desc 'Clean Magento cache by types'
23
23
  task :clean do
24
- on release_roles :all do
24
+ on Capistrano::Magento2.cache_hosts do
25
25
  within release_path do
26
26
  execute :magento, 'cache:clean'
27
27
  end
@@ -30,7 +30,7 @@ namespace :magento do
30
30
 
31
31
  desc 'Enable Magento cache'
32
32
  task :enable do
33
- on release_roles :all do
33
+ on Capistrano::Magento2.cache_hosts do
34
34
  within release_path do
35
35
  execute :magento, 'cache:enable'
36
36
  end
@@ -39,7 +39,7 @@ namespace :magento do
39
39
 
40
40
  desc 'Disable Magento cache'
41
41
  task :disable do
42
- on release_roles :all do
42
+ on Capistrano::Magento2.cache_hosts do
43
43
  within release_path do
44
44
  execute :magento, 'cache:disable'
45
45
  end
@@ -48,7 +48,7 @@ namespace :magento do
48
48
 
49
49
  desc 'Check Magento cache enabled status'
50
50
  task :status do
51
- on release_roles :all do
51
+ on Capistrano::Magento2.cache_hosts do
52
52
  within release_path do
53
53
  execute :magento, 'cache:status'
54
54
  end
@@ -59,7 +59,7 @@ namespace :magento do
59
59
  # TODO: Document what the magento:cache:varnish:ban task is for and how to use it. See also magento/magento2#4106
60
60
  desc 'Add ban to Varnish for url(s)'
61
61
  task :ban do
62
- on release_roles :all do
62
+ on primary fetch(:magento_deploy_setup_role) do
63
63
  # TODO: Document use of :ban_pools and :varnish_cache_hosts in project config file
64
64
  next unless any? :ban_pools
65
65
  next unless any? :varnish_cache_hosts
@@ -124,27 +124,30 @@ namespace :magento do
124
124
  end
125
125
 
126
126
  task :verify do
127
+ is_err = false
127
128
  on release_roles :all do
128
129
  unless test "[ -f #{release_path}/app/etc/config.php ]"
129
- error "The repository is missing app/etc/config.php. Please install the application and retry!"
130
- exit 1
130
+ error "\e[0;31mThe repository is missing app/etc/config.php. Please install the application and retry!\e[0m"
131
+ exit 1 # only need to check the repo once, so we immediately exit
131
132
  end
132
133
 
133
134
  unless test %Q[#{SSHKit.config.command_map[:php]} -r '
134
135
  $cfg = include "#{release_path}/app/etc/env.php";
135
136
  exit((int)!isset($cfg["install"]["date"]));
136
137
  ']
137
- error "No environment configuration could be found. Please configure app/etc/env.php and retry!"
138
- exit 1
138
+ error "\e[0;31mError on #{host}:\e[0m No environment configuration could be found." +
139
+ " Please configure app/etc/env.php and retry!"
140
+ is_err = true
139
141
  end
140
142
  end
143
+ exit 1 if is_err
141
144
  end
142
145
  end
143
146
 
144
147
  namespace :setup do
145
148
  desc 'Run the Magento upgrade process'
146
149
  task :upgrade do
147
- on release_roles :all do
150
+ on primary fetch(:magento_deploy_setup_role) do
148
151
  within release_path do
149
152
  execute :magento, 'setup:upgrade --keep-generated'
150
153
  end
@@ -280,7 +283,7 @@ namespace :magento do
280
283
  namespace :indexer do
281
284
  desc 'Reindex data by all indexers'
282
285
  task :reindex do
283
- on release_roles :all do
286
+ on primary fetch(:magento_deploy_setup_role) do
284
287
  within release_path do
285
288
  execute :magento, 'indexer:reindex'
286
289
  end
@@ -289,7 +292,7 @@ namespace :magento do
289
292
 
290
293
  desc 'Shows allowed indexers'
291
294
  task :info do
292
- on release_roles :all do
295
+ on primary fetch(:magento_deploy_setup_role) do
293
296
  within release_path do
294
297
  execute :magento, 'indexer:info'
295
298
  end
@@ -298,7 +301,7 @@ namespace :magento do
298
301
 
299
302
  desc 'Shows status of all indexers'
300
303
  task :status do
301
- on release_roles :all do
304
+ on primary fetch(:magento_deploy_setup_role) do
302
305
  within release_path do
303
306
  execute :magento, 'indexer:status'
304
307
  end
@@ -307,7 +310,7 @@ namespace :magento do
307
310
 
308
311
  desc 'Shows mode of all indexers'
309
312
  task 'show-mode', :index do |t, args|
310
- on release_roles :all do
313
+ on primary fetch(:magento_deploy_setup_role) do
311
314
  within release_path do
312
315
  execute :magento, 'indexer:show-mode', args[:index]
313
316
  end
@@ -316,14 +319,13 @@ namespace :magento do
316
319
 
317
320
  desc 'Sets mode of all indexers'
318
321
  task 'set-mode', :mode, :index do |t, args|
319
- on release_roles :all do
322
+ on primary fetch(:magento_deploy_setup_role) do
320
323
  within release_path do
321
324
  execute :magento, 'indexer:set-mode', args[:mode], args[:index]
322
325
  end
323
326
  end
324
327
  end
325
328
  end
326
-
327
329
  end
328
330
 
329
331
  namespace :load do
@@ -356,10 +358,21 @@ namespace :load do
356
358
  'var/tmp'
357
359
  )
358
360
 
359
- set :magento_deploy_languages, fetch(:magento_deploy_languages, ['en_US'])
360
- set :magento_deploy_themes, fetch(:magento_deploy_themes, [])
361
+ # deploy permissions defaults
361
362
  set :magento_deploy_chmod_d, fetch(:magento_deploy_chmod_d, '2770')
362
363
  set :magento_deploy_chmod_f, fetch(:magento_deploy_chmod_f, '0660')
363
364
  set :magento_deploy_chmod_x, fetch(:magento_deploy_chmod_x, ['bin/magento'])
365
+
366
+ # deploy configuration defaults
367
+ set :magento_deploy_composer, fetch(:magento_deploy_composer, true)
368
+ set :magento_deploy_confirm, fetch(:magento_deploy_confirm, [])
369
+ set :magento_deploy_languages, fetch(:magento_deploy_languages, ['en_US'])
370
+ set :magento_deploy_maintenance, fetch(:magento_deploy_maintenance, true)
371
+ set :magento_deploy_production, fetch(:magento_deploy_production, true)
372
+ set :magento_deploy_themes, fetch(:magento_deploy_themes, [])
373
+
374
+ # deploy targetting defaults
375
+ set :magento_deploy_setup_role, fetch(:magento_deploy_setup_role, :all)
376
+ set :magento_deploy_cache_shared, fetch(:magento_deploy_cache_shared, true)
364
377
  end
365
378
  end
@@ -11,11 +11,12 @@ require 'capistrano-pending'
11
11
 
12
12
  before :deploy, 'deploy:pending:check_changes'
13
13
  namespace :deploy do
14
-
14
+
15
+ # Check for pending changes on the primary node and then notify user of any incoming
16
+ # changes and/or warn that there is nothing to deploy
15
17
  namespace :pending do
16
- # Check for pending changes and notify user of incoming changes or warn them that there are no changes
17
18
  task :check_changes do
18
- on roles fetch(:capistrano_pending_role, :app) do |host|
19
+ on primary fetch(:magento_deploy_setup_role) do
19
20
  # check for pending changes only if REVISION file exists to prevent error
20
21
  if test "[ -f #{current_path}/REVISION ]"
21
22
  invoke 'deploy:pending:setup'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-magento2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Alger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2016-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano