itamae 1.1.18 → 1.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/itamae/cli.rb +5 -1
- data/lib/itamae/notification.rb +19 -0
- data/lib/itamae/resource/base.rb +27 -9
- data/lib/itamae/runner.rb +3 -2
- data/lib/itamae/version.txt +1 -1
- data/spec/integration/recipes/default.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc2771249661bde6dc39318b631d963a7697ebc
|
4
|
+
data.tar.gz: e0daf9fcefe8de50700be1bd21a5e6d2713a514a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 554595b1b3c7a10964e2d087d3b1a8194f1baab016fd4e6408dea6ab920d671d64744b1a19f2ec488e835d9072eb980dca6b24677c3c99bae1a5c55162dd9d44
|
7
|
+
data.tar.gz: 7b245129c145755de0ff1751c9fe275be4bb30532540269be2c6e0300d376af02fc3b1ef063153b9a32b08f409ada0228a3c21705c4ceef13b6777e827745d5a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## v1.1.19
|
2
|
+
|
3
|
+
Features
|
4
|
+
|
5
|
+
- `verify` attribute
|
6
|
+
- command will be executed after running resource action.
|
7
|
+
- If it fails, Itamae will abort (notifications will not be executed)
|
8
|
+
|
9
|
+
Improvements
|
10
|
+
|
11
|
+
- [`--vagrant` option without `--host` assumes the VM name `default` (by @muratayusuke)](https://github.com/itamae-kitchen/itamae/pull/91)
|
12
|
+
- `delayed` is a valid notification timing.
|
13
|
+
- same as Chef
|
14
|
+
- If invalid notification timing is provided, an error will be raised.
|
15
|
+
|
1
16
|
## v1.1.18
|
2
17
|
|
3
18
|
Improvements
|
data/lib/itamae/cli.rb
CHANGED
@@ -33,7 +33,7 @@ module Itamae
|
|
33
33
|
option :node_json, type: :string, aliases: ['-j']
|
34
34
|
option :node_yaml, type: :string, aliases: ['-y']
|
35
35
|
option :dry_run, type: :boolean, aliases: ['-n']
|
36
|
-
option :host,
|
36
|
+
option :host, type: :string, aliases: ['-h']
|
37
37
|
option :user, type: :string, aliases: ['-u']
|
38
38
|
option :key, type: :string, aliases: ['-i']
|
39
39
|
option :port, type: :numeric, aliases: ['-p']
|
@@ -46,6 +46,10 @@ module Itamae
|
|
46
46
|
raise "Please specify recipe files."
|
47
47
|
end
|
48
48
|
|
49
|
+
unless options[:host] || options[:vagrant]
|
50
|
+
raise "Please set '-h <hostname>' or '--vagrant'"
|
51
|
+
end
|
52
|
+
|
49
53
|
Runner.run(recipe_files, :ssh, options)
|
50
54
|
end
|
51
55
|
|
data/lib/itamae/notification.rb
CHANGED
@@ -2,6 +2,10 @@ require 'itamae'
|
|
2
2
|
|
3
3
|
module Itamae
|
4
4
|
class Notification < Struct.new(:defined_in_resource, :action, :target_resource_desc, :timing)
|
5
|
+
def self.create(*args)
|
6
|
+
self.new(*args).tap(&:validate!)
|
7
|
+
end
|
8
|
+
|
5
9
|
def resource
|
6
10
|
runner.children.find_resource_by_description(target_resource_desc)
|
7
11
|
end
|
@@ -17,6 +21,21 @@ module Itamae
|
|
17
21
|
def runner
|
18
22
|
defined_in_resource.recipe.runner
|
19
23
|
end
|
24
|
+
|
25
|
+
def delayed?
|
26
|
+
[:delay, :delayed].include?(timing)
|
27
|
+
end
|
28
|
+
|
29
|
+
def immediately?
|
30
|
+
timing == :immediately
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate!
|
34
|
+
unless [:delay, :delayed, :immediately].include?(timing)
|
35
|
+
Logger.error "'#{timing}' is not valid notification timing. (Valid option is delayed or immediately)"
|
36
|
+
abort
|
37
|
+
end
|
38
|
+
end
|
20
39
|
end
|
21
40
|
|
22
41
|
class Subscription < Notification
|
data/lib/itamae/resource/base.rb
CHANGED
@@ -9,6 +9,7 @@ module Itamae
|
|
9
9
|
attr_reader :attributes
|
10
10
|
attr_reader :notifications
|
11
11
|
attr_reader :subscriptions
|
12
|
+
attr_reader :verify_commands
|
12
13
|
attr_reader :only_if_command
|
13
14
|
attr_reader :not_if_command
|
14
15
|
|
@@ -18,6 +19,7 @@ module Itamae
|
|
18
19
|
@attributes = Hashie::Mash.new
|
19
20
|
@notifications = []
|
20
21
|
@subscriptions = []
|
22
|
+
@verify_commands = []
|
21
23
|
end
|
22
24
|
|
23
25
|
def respond_to_missing?(method, include_private = false)
|
@@ -39,11 +41,11 @@ module Itamae
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def notifies(action, resource_desc, timing = :delay)
|
42
|
-
@notifications << Notification.
|
44
|
+
@notifications << Notification.create(@resource, action, resource_desc, timing)
|
43
45
|
end
|
44
46
|
|
45
47
|
def subscribes(action, resource_desc, timing = :delay)
|
46
|
-
@subscriptions << Subscription.
|
48
|
+
@subscriptions << Subscription.create(@resource, action, resource_desc, timing)
|
47
49
|
end
|
48
50
|
|
49
51
|
def only_if(command)
|
@@ -57,6 +59,11 @@ module Itamae
|
|
57
59
|
def node
|
58
60
|
@resource.recipe.runner.node
|
59
61
|
end
|
62
|
+
|
63
|
+
# Experimental
|
64
|
+
def verify(command)
|
65
|
+
@verify_commands << command
|
66
|
+
end
|
60
67
|
end
|
61
68
|
|
62
69
|
@defined_attributes ||= {}
|
@@ -102,6 +109,7 @@ module Itamae
|
|
102
109
|
@subscriptions = context.subscriptions
|
103
110
|
@only_if_command = context.only_if_command
|
104
111
|
@not_if_command = context.not_if_command
|
112
|
+
@verify_commands = context.verify_commands
|
105
113
|
end
|
106
114
|
|
107
115
|
process_attributes
|
@@ -123,6 +131,7 @@ module Itamae
|
|
123
131
|
run_action(action, options)
|
124
132
|
end
|
125
133
|
|
134
|
+
verify unless options[:dry_run]
|
126
135
|
notify(options) if updated?
|
127
136
|
end
|
128
137
|
rescue Backend::CommandExecutionError
|
@@ -326,10 +335,9 @@ module Itamae
|
|
326
335
|
(notifications + recipe.children.subscribing(self)).each do |notification|
|
327
336
|
message = "Notifying #{notification.action} to #{notification.action_resource.resource_type} resource '#{notification.action_resource.resource_name}'"
|
328
337
|
|
329
|
-
|
330
|
-
when :delay
|
338
|
+
if notification.delayed?
|
331
339
|
message << " (delayed)"
|
332
|
-
|
340
|
+
elsif notification.immediately?
|
333
341
|
message << " (immediately)"
|
334
342
|
end
|
335
343
|
|
@@ -339,11 +347,21 @@ module Itamae
|
|
339
347
|
Logger.info "(because it subscribes this resource)"
|
340
348
|
end
|
341
349
|
|
342
|
-
|
343
|
-
when :immediately
|
344
|
-
notification.run(options)
|
345
|
-
when :delay
|
350
|
+
if notification.delayed?
|
346
351
|
@recipe.delayed_notifications << notification
|
352
|
+
elsif notification.immediately?
|
353
|
+
notification.run(options)
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
def verify
|
359
|
+
return if @verify_commands.empty?
|
360
|
+
|
361
|
+
Logger.info "Verifying..."
|
362
|
+
Logger.formatter.indent do
|
363
|
+
@verify_commands.each do |command|
|
364
|
+
run_command(command)
|
347
365
|
end
|
348
366
|
end
|
349
367
|
end
|
data/lib/itamae/runner.rb
CHANGED
@@ -69,8 +69,9 @@ module Itamae
|
|
69
69
|
|
70
70
|
if options[:vagrant]
|
71
71
|
config = Tempfile.new('', Dir.tmpdir)
|
72
|
-
|
73
|
-
|
72
|
+
hostname = opts[:host] || 'default'
|
73
|
+
`vagrant ssh-config #{hostname} > #{config.path}`
|
74
|
+
opts.merge!(Net::SSH::Config.for(hostname, [config.path]))
|
74
75
|
opts[:host] = opts.delete(:host_name)
|
75
76
|
end
|
76
77
|
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.19
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
226
|
rubyforge_project:
|
227
|
-
rubygems_version: 2.
|
227
|
+
rubygems_version: 2.4.5
|
228
228
|
signing_key:
|
229
229
|
specification_version: 4
|
230
230
|
summary: Simple Configuration Management Tool
|