serverkit 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +56 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +7 -0
- data/bin/serverkit +6 -0
- data/examples/recipe.yml +30 -0
- data/lib/serverkit/actions/apply.rb +23 -0
- data/lib/serverkit/actions/base.rb +38 -0
- data/lib/serverkit/actions/check.rb +18 -0
- data/lib/serverkit/command.rb +71 -0
- data/lib/serverkit/recipe.rb +49 -0
- data/lib/serverkit/resources/base.rb +39 -0
- data/lib/serverkit/resources/file.rb +84 -0
- data/lib/serverkit/resources/git.rb +79 -0
- data/lib/serverkit/resources/homebrew.rb +9 -0
- data/lib/serverkit/resources/homebrew_cask.rb +23 -0
- data/lib/serverkit/resources/package.rb +23 -0
- data/lib/serverkit/resources/symlink.rb +28 -0
- data/lib/serverkit/version.rb +3 -0
- data/lib/serverkit.rb +2 -0
- data/serverkit.gemspec +26 -0
- metadata +183 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a46215c909742a449201656305440413650b941f
|
4
|
+
data.tar.gz: 1e23e1ae21759a680affbdf69389e1900d59e8d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea78669c98502fea368c1f8c9042249190b988c8a12e82400276f82c396c9edc38db5fd4d3f4dc6a791091d07fd172bb57fcd16bb7349ee7d6030cb4ac910ec3
|
7
|
+
data.tar.gz: 1d4a29c33da839040b7ce029047a7f2f14d1d64663cd028505e98051c0b3f58b9695b661c52079376d97e26250edfad0e0c511b5d8502aec14598fd4ae7fd6ca
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Lint/UnusedBlockArgument:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Lint/UnusedMethodArgument:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Metrics/AbcSize:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/ClassLength:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/CyclomaticComplexity:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Metrics/LineLength:
|
17
|
+
Max: 120
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/PerceivedComplexity:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/Documentation:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/DoubleNegation:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/FormatString:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Style/MultilineBlockChain:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Style/PercentLiteralDelimiters:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/PredicateName:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Style/RegexpLiteral:
|
44
|
+
MaxSlashes: 0
|
45
|
+
|
46
|
+
Style/SignalException:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Style/StringLiterals:
|
50
|
+
EnforcedStyle: double_quotes
|
51
|
+
|
52
|
+
Style/TrailingComma:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
Style/TrivialAccessors:
|
56
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Ryo Nakamura
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Serverkit [](https://travis-ci.org/r7kamura/serverkit) [](https://codeclimate.com/github/r7kamura/serverkit)
|
2
|
+
Configuration management toolkit for building servers.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
```sh
|
6
|
+
# Write your recipe
|
7
|
+
vi recipe.yml
|
8
|
+
|
9
|
+
# Check
|
10
|
+
bundle exec serverkit check --recipe=recipe.yml
|
11
|
+
|
12
|
+
# Apply
|
13
|
+
bundle exec serverkit apply --recipe=recipe.yml
|
14
|
+
```
|
15
|
+
|
16
|
+
### Example
|
17
|
+
```yaml
|
18
|
+
# recipe.yml
|
19
|
+
resources:
|
20
|
+
- name: install_mysql
|
21
|
+
type: homebrew
|
22
|
+
package: mysql
|
23
|
+
- name: install_redis
|
24
|
+
type: homebrew
|
25
|
+
package: redis
|
26
|
+
- name: install_licecap
|
27
|
+
type: homebrew_cask
|
28
|
+
package: licecap
|
29
|
+
- name: install_alfred
|
30
|
+
type: homebrew_cask
|
31
|
+
package: alfred
|
32
|
+
- name: clone_dotfiles
|
33
|
+
type: git
|
34
|
+
repository: git@github.com:r7kamura/dotfiles.git
|
35
|
+
path: /Users/r7kamura/src/github.com/r7kamura/dotfiles
|
36
|
+
- name: symlink_zshrc
|
37
|
+
type: symlink
|
38
|
+
source: /Users/r7kamura/.zshrc
|
39
|
+
destination: /Users/r7kamura/src/github.com/r7kamura/dotfiles/linked/.zshrc
|
40
|
+
```
|
data/Rakefile
ADDED
data/bin/serverkit
ADDED
data/examples/recipe.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
hosts:
|
2
|
+
- localhost
|
3
|
+
ssh: false
|
4
|
+
resources:
|
5
|
+
- name: install_mysql
|
6
|
+
type: homebrew
|
7
|
+
package: mysql
|
8
|
+
- name: install_redis
|
9
|
+
type: homebrew
|
10
|
+
package: redis
|
11
|
+
- name: install_licecap
|
12
|
+
type: homebrew_cask
|
13
|
+
package: licecap
|
14
|
+
- name: install_alfred
|
15
|
+
type: homebrew_cask
|
16
|
+
package: alfred
|
17
|
+
- name: clone_dotfiles
|
18
|
+
type: git
|
19
|
+
repository: git@github.com:r7kamura/dotfiles.git
|
20
|
+
path: /Users/r7kamura/src/github.com/r7kamura/dotfiles
|
21
|
+
- name: symlink_zshrc
|
22
|
+
type: symlink
|
23
|
+
source: /Users/r7kamura/.zshrc
|
24
|
+
destination: /Users/r7kamura/src/github.com/r7kamura/dotfiles/linked/.zshrc
|
25
|
+
- name: put_zshrc
|
26
|
+
type: file
|
27
|
+
source: /Users/r7kamura/src/github.com/r7kamura/dotfiles/linked/.zshrc
|
28
|
+
destination: /Users/r7kamura/src/github.com/r7kamura/dotfiles/linked/.zshrc
|
29
|
+
user: r7kamura
|
30
|
+
group: staff
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "serverkit/actions/base"
|
2
|
+
|
3
|
+
module Serverkit
|
4
|
+
module Actions
|
5
|
+
class Apply < Base
|
6
|
+
def call
|
7
|
+
recipe.resources.each do |resource|
|
8
|
+
resource.backend = backend
|
9
|
+
if resource.check
|
10
|
+
puts "[SKIP] #{resource.name}"
|
11
|
+
else
|
12
|
+
resource.apply
|
13
|
+
if resource.check
|
14
|
+
puts "[DONE] #{resource.name}"
|
15
|
+
else
|
16
|
+
puts "[FAIL] #{resource.name}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "serverkit/recipe"
|
2
|
+
require "specinfra"
|
3
|
+
|
4
|
+
module Serverkit
|
5
|
+
module Actions
|
6
|
+
class Base
|
7
|
+
# @param [Hash] options
|
8
|
+
def initialize(options)
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# @return [Specinfra::Backend::Base]
|
19
|
+
def backend
|
20
|
+
@backend ||= backend_class.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Class]
|
24
|
+
def backend_class
|
25
|
+
if recipe.ssh?
|
26
|
+
Specinfra::Backend::Ssh
|
27
|
+
else
|
28
|
+
Specinfra::Backend::Exec
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Serverkit::Recipe]
|
33
|
+
def recipe
|
34
|
+
@recipe ||= Recipe.load_from_path(@options[:recipe])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "serverkit/actions/base"
|
2
|
+
|
3
|
+
module Serverkit
|
4
|
+
module Actions
|
5
|
+
class Check < Base
|
6
|
+
def call
|
7
|
+
recipe.resources.each do |resource|
|
8
|
+
resource.backend = backend
|
9
|
+
if resource.check
|
10
|
+
puts "[OK] #{resource.name}"
|
11
|
+
else
|
12
|
+
puts "[NG] #{resource.name}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "serverkit/actions/apply"
|
2
|
+
require "serverkit/actions/check"
|
3
|
+
require "slop"
|
4
|
+
|
5
|
+
module Serverkit
|
6
|
+
class Command
|
7
|
+
ACTION_NAMES = %w(
|
8
|
+
apply
|
9
|
+
check
|
10
|
+
)
|
11
|
+
|
12
|
+
# @param [Array<String>] argv
|
13
|
+
def initialize(argv)
|
14
|
+
@argv = argv
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
case
|
19
|
+
when has_no_action_name?
|
20
|
+
abort_for_missing_action_name
|
21
|
+
when has_unknown_action_name?
|
22
|
+
abort_for_unknown_action_name
|
23
|
+
when action_name == "apply"
|
24
|
+
apply
|
25
|
+
when action_name == "check"
|
26
|
+
check
|
27
|
+
end
|
28
|
+
rescue Slop::MissingOptionError => exception
|
29
|
+
abort "Error: #{exception}"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def abort_for_missing_action_name
|
35
|
+
abort "Error: Missing action name"
|
36
|
+
end
|
37
|
+
|
38
|
+
def abort_for_unknown_action_name
|
39
|
+
abort "Error: Unknown action name `#{action_name}`"
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [String, nil]
|
43
|
+
def action_name
|
44
|
+
ARGV.first
|
45
|
+
end
|
46
|
+
|
47
|
+
def apply
|
48
|
+
Actions::Apply.new(options).call
|
49
|
+
end
|
50
|
+
|
51
|
+
def check
|
52
|
+
Actions::Check.new(options).call
|
53
|
+
end
|
54
|
+
|
55
|
+
def has_no_action_name?
|
56
|
+
action_name.nil?
|
57
|
+
end
|
58
|
+
|
59
|
+
def has_unknown_action_name?
|
60
|
+
!ACTION_NAMES.include?(action_name)
|
61
|
+
end
|
62
|
+
|
63
|
+
# @return [Hash] Command-line options
|
64
|
+
def options
|
65
|
+
@options ||= Slop.parse!(@argv) do
|
66
|
+
banner "Usage: serverkit ACTION [options]"
|
67
|
+
on "-r", "--recipe=", "Path to recipe file", required: true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "active_support/core_ext/string/inflections"
|
2
|
+
require "serverkit/resources/file"
|
3
|
+
require "serverkit/resources/git"
|
4
|
+
require "serverkit/resources/homebrew"
|
5
|
+
require "serverkit/resources/homebrew_cask"
|
6
|
+
require "serverkit/resources/symlink"
|
7
|
+
require "yaml"
|
8
|
+
|
9
|
+
module Serverkit
|
10
|
+
class Recipe
|
11
|
+
class << self
|
12
|
+
# @param [String] path
|
13
|
+
def load_from_path(path)
|
14
|
+
raw_recipe = YAML.load_file(path)
|
15
|
+
new(raw_recipe)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [Hash] raw_recipe
|
20
|
+
def initialize(raw_recipe)
|
21
|
+
@raw_recipe = raw_recipe
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Array<Serverkit::Resources::Base>]
|
25
|
+
# @todo Delegate to resource builder
|
26
|
+
def resources
|
27
|
+
@resources ||= resource_properties.map do |properties|
|
28
|
+
Resources.const_get(properties["type"].camelize, false).new(properties)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Array<String>]
|
33
|
+
def hosts
|
34
|
+
@raw_recipe["hosts"]
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [true, false] Flag to use SSH (default: true)
|
38
|
+
def ssh?
|
39
|
+
@raw_recipe["ssh"] != false
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# @return [Array<String>]
|
45
|
+
def resource_properties
|
46
|
+
@raw_recipe["resources"] || []
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Serverkit
|
2
|
+
module Resources
|
3
|
+
class Base
|
4
|
+
attr_accessor :backend
|
5
|
+
|
6
|
+
# @param [Hash] properties
|
7
|
+
def initialize(properties)
|
8
|
+
@properties = properties
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [String]
|
12
|
+
def name
|
13
|
+
@properties["name"]
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# @return [true, false]
|
19
|
+
def check_command(*args)
|
20
|
+
run_command(*args).success?
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [true, false]
|
24
|
+
def check_command_from_identifier(*args)
|
25
|
+
run_command_from_identifier(*args).success?
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Specinfra::CommandResult]
|
29
|
+
def run_command(*args)
|
30
|
+
backend.run_command(*args)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [Specinfra::CommandResult]
|
34
|
+
def run_command_from_identifier(*args)
|
35
|
+
run_command(backend.command.get(*args))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require "digest"
|
2
|
+
require "serverkit/resources/base"
|
3
|
+
|
4
|
+
module Serverkit
|
5
|
+
module Resources
|
6
|
+
class File < Base
|
7
|
+
def apply
|
8
|
+
send_file if file_sendable?
|
9
|
+
change_group unless has_valid_group?
|
10
|
+
change_owner unless has_valid_owner?
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [true, false]
|
14
|
+
def check
|
15
|
+
has_file? && has_same_content? && has_valid_group? && has_valid_owner?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def change_group
|
21
|
+
run_command_from_identifier(:change_file_group, destination, group)
|
22
|
+
end
|
23
|
+
|
24
|
+
def change_owner
|
25
|
+
run_command_from_identifier(:change_file_owner, destination, owner)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [String]
|
29
|
+
def destination
|
30
|
+
@properties["destination"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def file_sendable?
|
34
|
+
!has_file? || !has_same_content?
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String]
|
38
|
+
def group
|
39
|
+
@properties["group"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def has_file?
|
43
|
+
check_command_from_identifier(:check_file_is_file, destination)
|
44
|
+
end
|
45
|
+
|
46
|
+
def has_same_content?
|
47
|
+
remote_file_sha256sum == local_file_sha256sum
|
48
|
+
end
|
49
|
+
|
50
|
+
def has_valid_group?
|
51
|
+
group.nil? || check_command_from_identifier(:check_file_is_grouped, destination, group)
|
52
|
+
end
|
53
|
+
|
54
|
+
def has_valid_owner?
|
55
|
+
owner.nil? || check_command_from_identifier(:check_file_is_owned_by, destination, owner)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @todo Rescue Errno::ENOENT from File.read
|
59
|
+
# @return [String]
|
60
|
+
def local_file_sha256sum
|
61
|
+
::Digest::SHA256.hexdigest(::File.read(source))
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [String]
|
65
|
+
def owner
|
66
|
+
@properties["owner"]
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [String]
|
70
|
+
def remote_file_sha256sum
|
71
|
+
run_command_from_identifier(:get_file_sha256sum, destination).stdout.rstrip
|
72
|
+
end
|
73
|
+
|
74
|
+
def send_file
|
75
|
+
run_command_from_identifier(:send_file, source, destination)
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [String]
|
79
|
+
def source
|
80
|
+
@properties["source"]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "serverkit/resources/base"
|
2
|
+
|
3
|
+
module Serverkit
|
4
|
+
module Resources
|
5
|
+
class Git < Base
|
6
|
+
DEFAULT_STATUS = "cloned"
|
7
|
+
|
8
|
+
def apply
|
9
|
+
clone if clonable?
|
10
|
+
update if updatable?
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [true, false]
|
14
|
+
def check
|
15
|
+
has_git? && cloned? && !updatable?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def clonable?
|
21
|
+
!cloned?
|
22
|
+
end
|
23
|
+
|
24
|
+
def clone
|
25
|
+
run_command("git clone #{repository} #{path}")
|
26
|
+
end
|
27
|
+
|
28
|
+
def cloned?
|
29
|
+
check_command_from_identifier(:check_file_is_directory, git_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [String] Path to .git directory in the cloned repository
|
33
|
+
def git_path
|
34
|
+
::File.join(path, ".git")
|
35
|
+
end
|
36
|
+
|
37
|
+
def has_git?
|
38
|
+
check_command("which git")
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [String]
|
42
|
+
def local_head_revision
|
43
|
+
run_command("cd #{path} && git rev-parse HEAD").stdout.rstrip
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [String]
|
47
|
+
def origin_head_revision
|
48
|
+
run_command("cd #{path} && git ls-remote origin HEAD").stdout.split.first
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [String] Where to locate cloned repository
|
52
|
+
def path
|
53
|
+
@properties["path"]
|
54
|
+
end
|
55
|
+
|
56
|
+
# @return [String] Git repository URL
|
57
|
+
def repository
|
58
|
+
@properties["repository"]
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [String]
|
62
|
+
def status
|
63
|
+
@properties["status"] || DEFAULT_STATUS
|
64
|
+
end
|
65
|
+
|
66
|
+
def updatable?
|
67
|
+
status == "updated" && !updated?
|
68
|
+
end
|
69
|
+
|
70
|
+
def update
|
71
|
+
run_command("cd #{path} && git fetch origin && git reset --hard origin/master")
|
72
|
+
end
|
73
|
+
|
74
|
+
def updated?
|
75
|
+
local_head_revision == origin_head_revision
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "serverkit/resources/base"
|
2
|
+
|
3
|
+
module Serverkit
|
4
|
+
module Resources
|
5
|
+
class HomebrewCask < Base
|
6
|
+
def apply
|
7
|
+
run_command("brew cask install #{package}")
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [true, false]
|
11
|
+
def check
|
12
|
+
check_command("/usr/local/bin/brew cask list -1 | grep -E '^#{package}$'")
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
def package
|
19
|
+
@properties["package"]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "serverkit/resources/base"
|
2
|
+
|
3
|
+
module Serverkit
|
4
|
+
module Resources
|
5
|
+
class Package < Base
|
6
|
+
def apply
|
7
|
+
run_command_from_identifier(:install, package)
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [true, false]
|
11
|
+
def check
|
12
|
+
check_command_from_identifier(:check_package_is_installed, package)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
def package
|
19
|
+
@properties["package"]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "serverkit/resources/base"
|
2
|
+
|
3
|
+
module Serverkit
|
4
|
+
module Resources
|
5
|
+
class Symlink < Base
|
6
|
+
def apply
|
7
|
+
run_command_from_identifier(:link_file_to, source, destination)
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [true, false]
|
11
|
+
def check
|
12
|
+
check_command_from_identifier(:check_file_is_linked_to, source, destination)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
def destination
|
19
|
+
@properties["destination"]
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [String]
|
23
|
+
def source
|
24
|
+
@properties["source"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/serverkit.rb
ADDED
data/serverkit.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "serverkit/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "serverkit"
|
7
|
+
spec.version = Serverkit::VERSION
|
8
|
+
spec.authors = ["Ryo Nakamura"]
|
9
|
+
spec.email = ["r7kamura@gmail.com"]
|
10
|
+
spec.summary = "Configuration management toolkit for building servers."
|
11
|
+
spec.homepage = "https://github.com/r7kamura/serverkit"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
14
|
+
spec.bindir = "bin"
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_runtime_dependency "activesupport"
|
19
|
+
spec.add_runtime_dependency "slop", "~> 3.4"
|
20
|
+
spec.add_runtime_dependency "specinfra"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "pry", "0.10.1"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "3.2.0"
|
25
|
+
spec.add_development_dependency "rubocop", "0.29.1"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: serverkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryo Nakamura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: specinfra
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.10.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.10.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.2.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.2.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.29.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.29.1
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- r7kamura@gmail.com
|
128
|
+
executables:
|
129
|
+
- serverkit
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- ".travis.yml"
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- bin/serverkit
|
142
|
+
- examples/recipe.yml
|
143
|
+
- lib/serverkit.rb
|
144
|
+
- lib/serverkit/actions/apply.rb
|
145
|
+
- lib/serverkit/actions/base.rb
|
146
|
+
- lib/serverkit/actions/check.rb
|
147
|
+
- lib/serverkit/command.rb
|
148
|
+
- lib/serverkit/recipe.rb
|
149
|
+
- lib/serverkit/resources/base.rb
|
150
|
+
- lib/serverkit/resources/file.rb
|
151
|
+
- lib/serverkit/resources/git.rb
|
152
|
+
- lib/serverkit/resources/homebrew.rb
|
153
|
+
- lib/serverkit/resources/homebrew_cask.rb
|
154
|
+
- lib/serverkit/resources/package.rb
|
155
|
+
- lib/serverkit/resources/symlink.rb
|
156
|
+
- lib/serverkit/version.rb
|
157
|
+
- serverkit.gemspec
|
158
|
+
homepage: https://github.com/r7kamura/serverkit
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
metadata: {}
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
requirements: []
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 2.4.5
|
179
|
+
signing_key:
|
180
|
+
specification_version: 4
|
181
|
+
summary: Configuration management toolkit for building servers.
|
182
|
+
test_files: []
|
183
|
+
has_rdoc:
|