1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Add a command line option to control role filtering

The functionality to filter the executing tasks by role (i.e. deploying
only to servers that match the role you specify) already exists. It can
specified either by using the following in your deployment config:

    set :filter, :roles => %w{app web}

Or by setting `ENV['ROLES']`:

    ROLES=app,web cap production deploy

This commit adds a command line switch to set the role filter, which
avoids polluting ENV:

    cap --roles=app,web production deploy
This commit is contained in:
Andy Sykes 2013-11-20 14:17:15 +00:00
parent 9014346664
commit 5a82cdb434
2 changed files with 14 additions and 1 deletions

View file

@ -2,6 +2,10 @@
Reverse Chronological Order: Reverse Chronological Order:
## master
* Add a command line option to control role filter (`--roles`) (@andytinycat)
## `3.1.0` (not released) ## `3.1.0` (not released)
* Tasks `deploy:linked_dirs`, `deploy:make_linked_dirs`, `deploy:linked_files`, `deploy:cleanup_rollback`, * Tasks `deploy:linked_dirs`, `deploy:make_linked_dirs`, `deploy:linked_files`, `deploy:cleanup_rollback`,

View file

@ -13,7 +13,7 @@ module Capistrano
end end
def sort_options(options) def sort_options(options)
options.push(version,dry_run) options.push(version,dry_run,roles)
super super
end end
@ -63,6 +63,15 @@ module Capistrano
} }
] ]
end end
def roles
['--roles ROLES', '-r',
"Filter command to only apply to these roles (separate multiple roles with a comma)",
lambda { |value|
Configuration.env.set(:filter, :roles => value.split(","))
}
]
end
end end
end end