capistrano_users 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +1 -0
- data/capistrano_users.gemspec +22 -0
- data/lib/capistrano_users.rb +2 -0
- data/lib/capistrano_users/capistrano_integration.rb +65 -0
- data/lib/capistrano_users/version.rb +3 -0
- metadata +87 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kalys Osmonov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# CapistranoUsers
|
2
|
+
|
3
|
+
Recipies allow to manage groups of deploy user.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano_users'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install capistrano_users
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
The following tasks are supported:
|
22
|
+
|
23
|
+
```
|
24
|
+
cap users:add_to_group # Add user to group, 'cap users:add_to_group GROUP=developers'.
|
25
|
+
cap users:groups # Get groups that deploy user belongs to
|
26
|
+
cap users:remove_from_group # Remove user from group, 'cap users:remove_from_group GROUP=developers'
|
27
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano_users/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "capistrano_users"
|
8
|
+
gem.version = CapistranoUsers::VERSION
|
9
|
+
gem.authors = ["Kalys Osmonov"]
|
10
|
+
gem.email = ["kalys@osmonov.com"]
|
11
|
+
gem.description = %q{Gem contains capistrano recipies for managing groups.}
|
12
|
+
gem.summary = %q{The following tasks are supported: cap users:add_to_group, cap users:groups, cap users:remove_from_group.}
|
13
|
+
gem.homepage = "https://github.com/kalys/capistrano_users"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'capistrano'
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
module CapistranoUsers
|
5
|
+
class CapistranoIntegration
|
6
|
+
TASKS = [
|
7
|
+
'users:groups',
|
8
|
+
'users:add_to_group',
|
9
|
+
'users:remove_from_group',
|
10
|
+
'users:add_to_admin_group',
|
11
|
+
'users:remove_from_admin_group'
|
12
|
+
]
|
13
|
+
|
14
|
+
def self.load_into(capistrano_config)
|
15
|
+
capistrano_config.load do
|
16
|
+
|
17
|
+
# Fetches groups that deploy user belongs to
|
18
|
+
#
|
19
|
+
def groups_command
|
20
|
+
"groups #{user}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_to_group_command to_group
|
24
|
+
"#{try_sudo} usermod -a -G #{to_group} #{user}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def remove_from_group_command from_group
|
28
|
+
"#{try_sudo} deluser #{user} #{from_group}"
|
29
|
+
end
|
30
|
+
|
31
|
+
namespace :users do
|
32
|
+
desc "Get groups that deploy user belongs to"
|
33
|
+
task :groups do
|
34
|
+
run groups_command
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Add user to group, 'cap users:add_to_group GROUP=developers'."
|
38
|
+
task :add_to_group do
|
39
|
+
if ENV['GROUP']
|
40
|
+
run add_to_group_command(ENV['GROUP'])
|
41
|
+
run "id #{user}"
|
42
|
+
else
|
43
|
+
raise "Usage: 'cap users:add_to_group GROUP=developers'"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Remove user from group, 'cap users:remove_from_group GROUP=developers'"
|
48
|
+
task :remove_from_group do
|
49
|
+
if ENV['GROUP']
|
50
|
+
run remove_from_group_command(ENV['GROUP'])
|
51
|
+
run "id #{user}"
|
52
|
+
else
|
53
|
+
raise "Usage: 'cap users:remove_from_group_command GROUP=developers'"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if Capistrano::Configuration.instance
|
64
|
+
CapistranoUsers::CapistranoIntegration.load_into(Capistrano::Configuration.instance)
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano_users
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kalys Osmonov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Gem contains capistrano recipies for managing groups.
|
47
|
+
email:
|
48
|
+
- kalys@osmonov.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- capistrano_users.gemspec
|
59
|
+
- lib/capistrano_users.rb
|
60
|
+
- lib/capistrano_users/capistrano_integration.rb
|
61
|
+
- lib/capistrano_users/version.rb
|
62
|
+
homepage: https://github.com/kalys/capistrano_users
|
63
|
+
licenses: []
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.25
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: ! 'The following tasks are supported: cap users:add_to_group, cap users:groups,
|
86
|
+
cap users:remove_from_group.'
|
87
|
+
test_files: []
|