serverkit 0.2.4 → 0.2.5

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: c2ffa547528d62052da5018705e1f1d1e048a586
4
- data.tar.gz: 199bc68d2e3378ff9d5f30c0dcc2fc744ea09053
3
+ metadata.gz: 9c4c6ff6ddcad1fa170004f086a310380bbc9aea
4
+ data.tar.gz: 9e5ec0a8584f01b1478630d124a51b5675afaf5c
5
5
  SHA512:
6
- metadata.gz: 027930d6d1455a60425664686b809f6e428f001c070149e0861019718ae1dd40a5f58bb308a43758d97112d795bf105542a50ef7370da197d036a7279ab36d0d
7
- data.tar.gz: d7ffaf6db341a8b14a65a3283a516806c5de94c9878ba6f0dc6cbcbf9b511b633cd7c69e407ffdae86f95b33e9d7146177ebc5e3fa6aa2bfe7a8b345eb84b28b
6
+ metadata.gz: 15ef8e9c19eb85523f43c01bf70de32d5f82a57b28328a185c72a138d57454f95a0d6b41223582ae621c5c73fd62e8efefc871e5e9683b46ff1fdb20cb90539f
7
+ data.tar.gz: 7b7e70797e2b8f4fe0ce5d4301f4a741f1d8baa01db8c2a54f8bddcc2c7133ea1b86b9d92be04fc54e36efdf183bd9a594f1512acad455d90e134a3ba4ecffac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.5
2
+ - Fix bug on resource with no notify property
3
+
1
4
  ## 0.2.4
2
5
  - Add new feature: Handlers
3
6
  - Add command resource type
data/README.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Serverkit [![Build Status](https://travis-ci.org/r7kamura/serverkit.svg)](https://travis-ci.org/r7kamura/serverkit) [![Code Climate](https://codeclimate.com/github/r7kamura/serverkit/badges/gpa.svg)](https://codeclimate.com/github/r7kamura/serverkit)
2
2
  Configuration management toolkit for IT automation.
3
3
 
4
+ - [Usage](#usage)
5
+ - [serverkit validate](#serverkit-validate)
6
+ - [serverkit inspect](#serverkit-inspect)
7
+ - [serverkit check](#serverkit-check)
8
+ - [serverkit apply](#serverkit-apply)
9
+ - [SSH support](#ssh-support)
10
+ - [Recipe](#recipe)
11
+ - [Format](#format)
12
+ - [Variables](#variables)
13
+ - [Example](#example)
14
+ - [Resource](#resource)
15
+ - [Type](#type)
16
+ - [Example](#example-1)
17
+ - [Handlers](#handlers)
18
+ - [Plug-in](#plug-in)
19
+
4
20
  ## Usage
5
21
  Write a recipe, then run `serverkit` executable to validate, inspect, check, and apply the recipe.
6
22
 
@@ -56,12 +72,12 @@ Shows the difference between your recipe and the state of the target host.
56
72
 
57
73
  ```
58
74
  $ serverkit check recipe.yml
59
- [ OK ] install_mysql
60
- [ OK ] install_redis
61
- [ OK ] install_licecap
62
- [ OK ] install_alfred
63
- [ NG ] clone_dotfiles
64
- [ NG ] symlink_zshrc
75
+ [ OK ] homebrew mysql on localhost
76
+ [ OK ] homebrew redis on localhost
77
+ [ OK ] homebrew_cask licecap on localhost
78
+ [ OK ] homebrew_cask alfred on localhost
79
+ [ NG ] git git@github.com:r7kamura/dotfiles.git on localhost
80
+ [ NG ] symlink /Users/r7kamura/src/github.com/r7kamura/dotfiles/linked/.zshrc on localhost
65
81
  ```
66
82
 
67
83
  ### serverkit apply
@@ -69,12 +85,12 @@ Executes migration process to fill-in the gaps.
69
85
 
70
86
  ```
71
87
  $ serverkit apply recipe.yml
72
- [SKIP] install_mysql
73
- [SKIP] install_redis
74
- [SKIP] install_licecap
75
- [SKIP] install_alfred
76
- [DONE] clone_dotfiles
77
- [DONE] symlink_zshrc
88
+ [SKIP] homebrew mysql on localhost
89
+ [SKIP] homebrew redis on localhost
90
+ [SKIP] homebrew_cask licecap on localhost
91
+ [SKIP] homebrew_cask alfred on localhost
92
+ [DONE] git git@github.com:r7kamura/dotfiles.git on localhost
93
+ [DONE] symlink /Users/r7kamura/src/github.com/r7kamura/dotfiles/linked/.zshrc on localhost
78
94
  ```
79
95
 
80
96
  ### SSH support
@@ -149,7 +165,7 @@ resources:
149
165
  A resource is a statement of configuration policy that describes the desired state for an item.
150
166
 
151
167
  ### Type
152
- A resource must have a type property. Currently the following types are available:
168
+ A resource must have a type attribute. Currently the following types are available:
153
169
 
154
170
  - command
155
171
  - file
@@ -161,8 +177,6 @@ A resource must have a type property. Currently the following types are availabl
161
177
  - recipe
162
178
  - service
163
179
  - symlink
164
- - [defaults](https://github.com/r7kamura/serverkit-defaults)
165
- - [rbenv_ruby](https://github.com/r7kamura/serverkit-rbenv)
166
180
 
167
181
  ### Example
168
182
  An example package resource that has type and name attributes.
@@ -174,7 +188,7 @@ resources:
174
188
  ```
175
189
 
176
190
  ## Handlers
177
- When any changes are successfully applied to a resource and it has notify property,
191
+ When any changes are successfully applied to a resource and it has notify attribute,
178
192
  it notifies handlers that are referenced by their id.
179
193
  The notified handlers will run only once after all resources finished their applications.
180
194
  Here's an example of restarting Dock on Mac OS X when its preferences change.
@@ -187,8 +201,7 @@ resources:
187
201
  value: 1
188
202
  notify:
189
203
  - restart_dock
190
- - id: empty_dock
191
- type: defaults
204
+ - type: defaults
192
205
  domain: com.apple.dock
193
206
  key: persistent-apps
194
207
  value: []
@@ -199,3 +212,20 @@ handlers:
199
212
  type: command
200
213
  script: killall Dock
201
214
  ```
215
+
216
+ ## Plug-in
217
+ A plug-in is provided as a gem.
218
+ Serverkit calls `Bundler.require(:default)` before running an action,
219
+ so you can add any behaviors to serverkit via gems defined in Gemfile.
220
+ For example, [serverkit-rbenv](https://github.com/r7kamura/serverkit-rbenv) gem
221
+ adds a custom resource type named `rbenv_ruby` by defining `Serverkit::Resources::RbenvRuby` class.
222
+ Serverkit finds `Serverkit::Resources::FooBar` resource class from `type: "foo_bar"`.
223
+
224
+ - [serverkit-defaults](https://github.com/r7kamura/serverkit-defaults)
225
+ - [serverkit-rbenv](https://github.com/r7kamura/serverkit-rbenv)
226
+
227
+ ```rb
228
+ # Gemfile
229
+ gem "serverkit"
230
+ gem "serverkit-rbenv"
231
+ ```
@@ -11,6 +11,10 @@ resources:
11
11
  - type: nothing
12
12
  notify:
13
13
  - handler_test
14
+ - type: command
15
+ check_script: "false"
16
+ script: echo test
17
+ recheck_script: "true"
14
18
  handlers:
15
19
  - id: handler_test
16
20
  type: nothing
@@ -59,7 +59,7 @@ module Serverkit
59
59
 
60
60
  # @return [Hash] Fully-expanded recipe data
61
61
  def to_hash
62
- { "resources" => resources.map(&:attributes) }
62
+ @recipe_data.merge("resources" => resources.map(&:attributes))
63
63
  end
64
64
 
65
65
  def valid?
@@ -43,7 +43,7 @@ module Serverkit
43
43
 
44
44
  # @return [Array<Serverkit::Resource>]
45
45
  def handlers
46
- @handlers ||= notify.map do |id|
46
+ @handlers ||= Array(notify).map do |id|
47
47
  recipe.handlers.find do |handler|
48
48
  handler.id == id
49
49
  end
@@ -3,7 +3,9 @@ require "serverkit/resources/base"
3
3
  module Serverkit
4
4
  module Resources
5
5
  class Command < Base
6
+ attribute :check_script, type: String
6
7
  attribute :script, required: true, type: String
8
+ attribute :recheck_script, type: String
7
9
 
8
10
  # @note Override
9
11
  def apply
@@ -12,12 +14,29 @@ module Serverkit
12
14
 
13
15
  # @note Override
14
16
  def check
15
- false
17
+ if check_script
18
+ check_command(check_script)
19
+ else
20
+ false
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def default_id
27
+ script
16
28
  end
17
29
 
18
30
  # @note Override
19
31
  def recheck
20
- true
32
+ case
33
+ when recheck_script
34
+ check_command(recheck_script)
35
+ when check_script
36
+ check_command(check_script)
37
+ else
38
+ true
39
+ end
21
40
  end
22
41
  end
23
42
  end
@@ -1,3 +1,3 @@
1
1
  module Serverkit
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura