serverkit 0.0.5 → 0.0.6
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +93 -23
- data/lib/readable_validator.rb +1 -1
- data/lib/serverkit/actions/base.rb +4 -0
- data/lib/serverkit/actions/inspect.rb +16 -0
- data/lib/serverkit/actions/validate.rb +1 -1
- data/lib/serverkit/command.rb +15 -17
- data/lib/serverkit/recipe.rb +5 -0
- data/lib/serverkit/resources/base.rb +1 -1
- data/lib/serverkit/resources/package.rb +1 -1
- data/lib/serverkit/resources/recipe.rb +5 -1
- data/lib/serverkit/version.rb +1 -1
- data/serverkit.gemspec +12 -11
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 656a155cfa4b8c499bafcfdbda76075bb28d1570
|
4
|
+
data.tar.gz: adc66fb429d351629b872e61dcfc8ad2d11c40ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a21e147dcf7e37feae2c6eec67242cec814353bb4583df2b02698c9498546dc476f419574c67214c453e7173db3896c91a413c9ef503f2c130bf23cc70303af1
|
7
|
+
data.tar.gz: c4f77002e8336a5a635d2d8516d9db3522fc6a596eaf95d0c7dcc758ef9de439f0d72334ce4d0d24b9f76ce9f0b926de871ea5b2cecabd0d5b9c1892532f3b67
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,15 +2,85 @@
|
|
2
2
|
Configuration management toolkit for IT automation.
|
3
3
|
|
4
4
|
## Usage
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
serverkit
|
13
|
-
|
5
|
+
Write a recipe, then run `serverkit` executable to validate, inspect, check, and apply the recipe.
|
6
|
+
|
7
|
+
### serverkit validate
|
8
|
+
Validates recipe schema, resources, and attributes.
|
9
|
+
For instance, it shows validation error if `source` attributes is missing in `file` resource.
|
10
|
+
|
11
|
+
```
|
12
|
+
$ serverkit validate --recipe=recipe.yml
|
13
|
+
Error: source attribute is required in file resource
|
14
|
+
Error: path attribute can't be unreadable path in recipe resource
|
15
|
+
```
|
16
|
+
|
17
|
+
### serverkit inspect
|
18
|
+
Shows fully-expanded recipe data in JSON format.
|
19
|
+
|
20
|
+
```
|
21
|
+
$ serverkit inspect --recipe=recipe.yml
|
22
|
+
{
|
23
|
+
"resources": [
|
24
|
+
{
|
25
|
+
"id": "install_mysql",
|
26
|
+
"type": "homebrew",
|
27
|
+
"name": "mysql"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"id": "install_redis",
|
31
|
+
"type": "homebrew",
|
32
|
+
"name": "redis"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"id": "install_licecap",
|
36
|
+
"type": "homebrew_cask",
|
37
|
+
"name": "licecap"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"id": "install_alfred",
|
41
|
+
"type": "homebrew_cask",
|
42
|
+
"name": "alfred"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"id": "clone_dotfiles",
|
46
|
+
"type": "git",
|
47
|
+
"repository": "git@github.com:r7kamura/dotfiles.git",
|
48
|
+
"path": "/Users/r7kamura/src/github.com/r7kamura/dotfiles"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"id": "symlink_zshrc",
|
52
|
+
"type": "symlink",
|
53
|
+
"source": "/Users/r7kamura/.zshrc",
|
54
|
+
"destination": "/Users/r7kamura/src/github.com/r7kamura/dotfiles/linked/.zshrc"
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
### serverkit check
|
61
|
+
Shows the difference between your recipe and the state of the target host.
|
62
|
+
|
63
|
+
```
|
64
|
+
$ serverkit check --recipe=recipe.yml
|
65
|
+
[OK] install_mysql
|
66
|
+
[OK] install_redis
|
67
|
+
[OK] install_licecap
|
68
|
+
[OK] install_alfred
|
69
|
+
[NG] clone_dotfiles
|
70
|
+
[NG] symlink_zshrc
|
71
|
+
```
|
72
|
+
|
73
|
+
### serverkit apply
|
74
|
+
Executes migration process to fill-in the gaps.
|
75
|
+
|
76
|
+
```
|
77
|
+
$ serverkit apply --recipe=recipe.yml
|
78
|
+
[SKIP] install_mysql
|
79
|
+
[SKIP] install_redis
|
80
|
+
[SKIP] install_licecap
|
81
|
+
[SKIP] install_alfred
|
82
|
+
[DONE] clone_dotfiles
|
83
|
+
[DONE] symlink_zshrc
|
14
84
|
```
|
15
85
|
|
16
86
|
## Recipe
|
@@ -26,26 +96,26 @@ A recipe can be specified as a path to one of the following patterns:
|
|
26
96
|
- Executable to output JSON
|
27
97
|
- Directory including recipe files recursively
|
28
98
|
|
29
|
-
```
|
30
|
-
serverkit apply --recipe=recipe
|
31
|
-
serverkit apply --recipe=recipe.json
|
32
|
-
serverkit apply --recipe=recipe.json.erb
|
33
|
-
serverkit apply --recipe=recipe.json.erb --variables=variables
|
34
|
-
serverkit apply --recipe=recipe.json.erb --variables=variables.json
|
35
|
-
serverkit apply --recipe=recipe.json.erb --variables=variables.json.erb
|
36
|
-
serverkit apply --recipe=recipe.json.erb --variables=variables.yml
|
37
|
-
serverkit apply --recipe=recipe.json.erb --variables=variables.yml.erb
|
38
|
-
serverkit apply --recipe=recipe.json.erb --variables=variables/
|
39
|
-
serverkit apply --recipe=recipe.yml
|
40
|
-
serverkit apply --recipe=recipe.yml.erb
|
41
|
-
serverkit apply --recipe=recipes/
|
99
|
+
```
|
100
|
+
$ serverkit apply --recipe=recipe
|
101
|
+
$ serverkit apply --recipe=recipe.json
|
102
|
+
$ serverkit apply --recipe=recipe.json.erb
|
103
|
+
$ serverkit apply --recipe=recipe.json.erb --variables=variables
|
104
|
+
$ serverkit apply --recipe=recipe.json.erb --variables=variables.json
|
105
|
+
$ serverkit apply --recipe=recipe.json.erb --variables=variables.json.erb
|
106
|
+
$ serverkit apply --recipe=recipe.json.erb --variables=variables.yml
|
107
|
+
$ serverkit apply --recipe=recipe.json.erb --variables=variables.yml.erb
|
108
|
+
$ serverkit apply --recipe=recipe.json.erb --variables=variables/
|
109
|
+
$ serverkit apply --recipe=recipe.yml
|
110
|
+
$ serverkit apply --recipe=recipe.yml.erb
|
111
|
+
$ serverkit apply --recipe=recipes/
|
42
112
|
```
|
43
113
|
|
44
114
|
### Variables
|
45
115
|
When using ERB recipe, you can also give optional variables file
|
46
116
|
that defines configurations in a Hash object for ERB template.
|
47
117
|
It supports similar format variation with Recipe.
|
48
|
-
In ERB template, you can
|
118
|
+
In ERB template, you can use given variables via `variables` method.
|
49
119
|
|
50
120
|
### Example
|
51
121
|
This is an example recipe to install some packages, clone a git repository, and create a symlink.
|
data/lib/readable_validator.rb
CHANGED
@@ -3,7 +3,7 @@ require "active_model"
|
|
3
3
|
class ReadableValidator < ActiveModel::EachValidator
|
4
4
|
def validate_each(record, attribute, value)
|
5
5
|
unless File.readable?(value)
|
6
|
-
record.errors.add(attribute, "
|
6
|
+
record.errors.add(attribute, "can't be unreadable path")
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
data/lib/serverkit/command.rb
CHANGED
@@ -1,33 +1,30 @@
|
|
1
1
|
require "serverkit/actions/apply"
|
2
2
|
require "serverkit/actions/check"
|
3
|
+
require "serverkit/actions/inspect"
|
3
4
|
require "serverkit/actions/validate"
|
4
5
|
require "slop"
|
5
6
|
|
6
7
|
module Serverkit
|
7
8
|
class Command
|
8
|
-
ACTION_NAMES = %w(
|
9
|
-
apply
|
10
|
-
check
|
11
|
-
validate
|
12
|
-
)
|
13
|
-
|
14
9
|
# @param [Array<String>] argv
|
15
10
|
def initialize(argv)
|
16
11
|
@argv = argv
|
17
12
|
end
|
18
13
|
|
19
14
|
def call
|
20
|
-
case
|
21
|
-
when
|
15
|
+
case action_name
|
16
|
+
when nil
|
22
17
|
abort_for_missing_action_name
|
23
|
-
when
|
24
|
-
abort_for_unknown_action_name
|
25
|
-
when action_name == "apply"
|
18
|
+
when "apply"
|
26
19
|
apply
|
27
|
-
when
|
20
|
+
when "check"
|
28
21
|
check
|
29
|
-
when
|
22
|
+
when "inspect"
|
23
|
+
_inspect
|
24
|
+
when "validate"
|
30
25
|
validate
|
26
|
+
else
|
27
|
+
abort_for_unknown_action_name
|
31
28
|
end
|
32
29
|
rescue Slop::MissingOptionError => exception
|
33
30
|
abort "Error: #{exception}"
|
@@ -56,14 +53,15 @@ module Serverkit
|
|
56
53
|
Actions::Check.new(options).call
|
57
54
|
end
|
58
55
|
|
59
|
-
def has_no_action_name?
|
60
|
-
action_name.nil?
|
61
|
-
end
|
62
|
-
|
63
56
|
def has_unknown_action_name?
|
64
57
|
!ACTION_NAMES.include?(action_name)
|
65
58
|
end
|
66
59
|
|
60
|
+
# @note #inspect is reserved ;(
|
61
|
+
def _inspect
|
62
|
+
Actions::Inspect.new(options).call
|
63
|
+
end
|
64
|
+
|
67
65
|
# @return [Hash] Command-line options
|
68
66
|
def options
|
69
67
|
@options ||= Slop.parse!(@argv) do
|
data/lib/serverkit/recipe.rb
CHANGED
data/lib/serverkit/version.rb
CHANGED
data/serverkit.gemspec
CHANGED
@@ -3,17 +3,18 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require "serverkit/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
10
|
-
spec.summary
|
11
|
-
spec.homepage
|
12
|
-
spec.license
|
13
|
-
spec.files
|
14
|
-
spec.bindir
|
15
|
-
spec.executables
|
16
|
-
spec.require_paths
|
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 IT automation."
|
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
|
+
spec.required_ruby_version = ">= 2.0.0"
|
17
18
|
|
18
19
|
spec.add_runtime_dependency "activemodel"
|
19
20
|
spec.add_runtime_dependency "activesupport"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- lib/serverkit/actions/apply.rb
|
168
168
|
- lib/serverkit/actions/base.rb
|
169
169
|
- lib/serverkit/actions/check.rb
|
170
|
+
- lib/serverkit/actions/inspect.rb
|
170
171
|
- lib/serverkit/actions/validate.rb
|
171
172
|
- lib/serverkit/command.rb
|
172
173
|
- lib/serverkit/errors/attribute_validation_error.rb
|
@@ -205,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
206
|
requirements:
|
206
207
|
- - ">="
|
207
208
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
209
|
+
version: 2.0.0
|
209
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
211
|
requirements:
|
211
212
|
- - ">="
|