knife-spork 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +18 -0
- data/LICENSE +1 -1
- data/README.md +131 -5
- data/knife-spork.gemspec +3 -2
- data/lib/chef/knife/spork-check.rb +13 -1
- data/lib/chef/knife/spork-databag-create.rb +53 -0
- data/lib/chef/knife/spork-databag-delete.rb +51 -0
- data/lib/chef/knife/spork-databag-edit.rb +54 -0
- data/lib/chef/knife/spork-databag-fromfile.rb +82 -0
- data/lib/chef/knife/spork-node-create.rb +38 -0
- data/lib/chef/knife/spork-node-delete.rb +38 -0
- data/lib/chef/knife/spork-node-edit.rb +45 -0
- data/lib/chef/knife/spork-node-fromfile.rb +43 -0
- data/lib/chef/knife/spork-node-runlistadd.rb +48 -0
- data/lib/chef/knife/spork-node-runlistremove.rb +42 -0
- data/lib/chef/knife/spork-node-runlistset.rb +42 -0
- data/lib/chef/knife/spork-omni.rb +107 -0
- data/lib/chef/knife/spork-promote.rb +2 -6
- data/lib/chef/knife/spork-role-create.rb +43 -0
- data/lib/chef/knife/spork-role-delete.rb +36 -0
- data/lib/chef/knife/spork-role-edit.rb +37 -0
- data/lib/chef/knife/spork-role-fromfile.rb +42 -0
- data/lib/knife-spork/plugins/campfire.rb +128 -0
- data/lib/knife-spork/plugins/eventinator.rb +199 -0
- data/lib/knife-spork/plugins/foodcritic.rb +8 -3
- data/lib/knife-spork/plugins/grove.rb +96 -0
- data/lib/knife-spork/plugins/hipchat.rb +65 -0
- data/lib/knife-spork/plugins/irccat.rb +190 -3
- data/lib/knife-spork/plugins/jabber.rb +64 -0
- data/lib/knife-spork/plugins/plugin.rb +12 -0
- data/lib/knife-spork/plugins/statusnet.rb +64 -0
- data/lib/knife-spork/plugins.rb +3 -0
- data/lib/knife-spork/runner.rb +51 -4
- data/plugins/Foodcritic.md +1 -1
- metadata +36 -4
@@ -15,6 +15,70 @@ module KnifeSpork
|
|
15
15
|
jabber "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
|
16
16
|
end
|
17
17
|
|
18
|
+
def after_rolefromfile
|
19
|
+
jabber "#{organization}#{current_user} uploaded role #{object_name}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def after_roleedit
|
23
|
+
jabber "#{organization}#{current_user} edited role #{object_name}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def after_rolecreate
|
27
|
+
jabber "#{organization}#{current_user} created role #{object_name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def after_roledelete
|
31
|
+
jabber "#{organization}#{current_user} deleted role #{object_name}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def after_databagedit
|
35
|
+
jabber "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def after_databagcreate
|
39
|
+
jabber "#{organization}#{current_user} created data bag #{object_name}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def after_databagdelete
|
43
|
+
jabber "#{organization}#{current_user} deleted data bag #{object_name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def after_databagitemdelete
|
47
|
+
jabber "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def after_databagfromfile
|
51
|
+
jabber "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def after_nodeedit
|
55
|
+
jabber "#{organization}#{current_user} edited node #{object_name}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def after_nodedelete
|
59
|
+
jabber "#{organization}#{current_user} deleted node #{object_name}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def after_nodecreate
|
63
|
+
jabber "#{organization}#{current_user} created node #{object_name}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def after_nodefromfile
|
67
|
+
jabber "#{organization}#{current_user} uploaded node #{object_name}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def after_noderunlistadd
|
71
|
+
jabber "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def after_noderunlistremove
|
75
|
+
jabber "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def after_noderunlistset
|
79
|
+
jabber "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name}"
|
80
|
+
end
|
81
|
+
|
18
82
|
private
|
19
83
|
|
20
84
|
def jabber(message)
|
@@ -71,6 +71,18 @@ module KnifeSpork
|
|
71
71
|
@options[:cookbook_path]
|
72
72
|
end
|
73
73
|
|
74
|
+
def object_name
|
75
|
+
@options[:object_name]
|
76
|
+
end
|
77
|
+
|
78
|
+
def object_secondary_name
|
79
|
+
@options[:object_secondary_name]
|
80
|
+
end
|
81
|
+
|
82
|
+
def object_difference
|
83
|
+
@options[:object_difference]
|
84
|
+
end
|
85
|
+
|
74
86
|
def ui
|
75
87
|
@options[:ui]
|
76
88
|
end
|
@@ -15,6 +15,70 @@ module KnifeSpork
|
|
15
15
|
statusnet "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
|
16
16
|
end
|
17
17
|
|
18
|
+
def after_rolefromfile
|
19
|
+
statusnet "#{organization}#{current_user} uploaded role #{object_name}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def after_roleedit
|
23
|
+
statusnet "#{organization}#{current_user} edited role #{object_name}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def after_rolecreate
|
27
|
+
statusnet "#{organization}#{current_user} created role #{object_name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def after_roledelete
|
31
|
+
statusnet "#{organization}#{current_user} deleted role #{object_name}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def after_databagedit
|
35
|
+
statusnet "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def after_databagcreate
|
39
|
+
statusnet "#{organization}#{current_user} created data bag #{object_name}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def after_databagdelete
|
43
|
+
statusnet "#{organization}#{current_user} deleted data bag #{object_name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def after_databagitemdelete
|
47
|
+
statusnet "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def after_databagfromfile
|
51
|
+
statusnet "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def after_nodeedit
|
55
|
+
statusnet "#{organization}#{current_user} edited node #{object_name}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def after_nodedelete
|
59
|
+
statusnet "#{organization}#{current_user} deleted node #{object_name}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def after_nodecreate
|
63
|
+
statusnet "#{organization}#{current_user} created node #{object_name}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def after_nodefromfile
|
67
|
+
statusnet "#{organization}#{current_user} uploaded node #{object_name}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def after_noderunlistadd
|
71
|
+
statusnet "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def after_noderunlistremove
|
75
|
+
statusnet "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def after_noderunlistset
|
79
|
+
statusnet "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name}"
|
80
|
+
end
|
81
|
+
|
18
82
|
private
|
19
83
|
|
20
84
|
def statusnet(message)
|
data/lib/knife-spork/plugins.rb
CHANGED
@@ -6,6 +6,9 @@ module KnifeSpork
|
|
6
6
|
def self.run(options = {})
|
7
7
|
hook = options[:hook].to_sym
|
8
8
|
|
9
|
+
#Load each of the drop-in plugins specified in the custom plugin path
|
10
|
+
Dir[File.expand_path("#{options[:config][:custom_plugin_path]}/*.rb")].each { |f| require f }
|
11
|
+
|
9
12
|
klasses.each do |klass|
|
10
13
|
plugin = klass.new(options)
|
11
14
|
plugin.send(hook) if plugin.respond_to?(hook) && plugin.enabled?
|
data/lib/knife-spork/runner.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'app_conf'
|
2
|
+
require 'diffy'
|
2
3
|
require 'json'
|
3
4
|
|
4
5
|
require 'chef/cookbook_loader'
|
@@ -26,6 +27,13 @@ module KnifeSpork
|
|
26
27
|
|
27
28
|
def run_plugins(hook)
|
28
29
|
cookbooks = [ @cookbooks || @cookbook ].flatten.compact.collect{|cookbook| cookbook.is_a?(::Chef::CookbookVersion) ? cookbook : load_cookbook(cookbook)}.sort{|a,b| a.name.to_s <=> b.name.to_s}
|
30
|
+
|
31
|
+
# Affects promote only:
|
32
|
+
# Set loaded cookbook version if the -v or --version parameter was specified
|
33
|
+
# Otherwise the version on disk, often more recent will be used.
|
34
|
+
# We know cookbooks will only contain one cookbook in the case of promote.
|
35
|
+
cookbooks.map{|c|c.version = config[:version]} if config[:version]
|
36
|
+
|
29
37
|
environments = [ @environments || @environment ].flatten.compact.collect{|environment| environment.is_a?(::Chef::Environment) ? environment : load_environment(environment)}.sort{|a,b| a.name.to_s <=> b.name.to_s}
|
30
38
|
environment_diffs = @environment_diffs
|
31
39
|
|
@@ -37,6 +45,9 @@ module KnifeSpork
|
|
37
45
|
:environment_diffs => environment_diffs,
|
38
46
|
:environment_path => environment_path,
|
39
47
|
:cookbook_path => cookbook_path,
|
48
|
+
:object_name => @object_name,
|
49
|
+
:object_secondary_name => @object_secondary_name,
|
50
|
+
:object_difference => @object_difference,
|
40
51
|
:ui => ui
|
41
52
|
)
|
42
53
|
end
|
@@ -88,8 +99,12 @@ module KnifeSpork
|
|
88
99
|
end
|
89
100
|
end
|
90
101
|
|
91
|
-
def
|
92
|
-
@
|
102
|
+
def environment_loader
|
103
|
+
@environment_loader ||= Chef::Knife::Core::ObjectLoader.new(::Chef::Environment, ui)
|
104
|
+
end
|
105
|
+
|
106
|
+
def role_loader
|
107
|
+
@role_loader ||= Chef::Knife::Core::ObjectLoader.new(::Chef::Role, ui)
|
93
108
|
end
|
94
109
|
|
95
110
|
# It's not feasible to try and "guess" which cookbook path to use, so we will
|
@@ -103,6 +118,10 @@ module KnifeSpork
|
|
103
118
|
spork_config[:environment_path] || cookbook_path.gsub("/cookbooks","/environments")
|
104
119
|
end
|
105
120
|
|
121
|
+
def role_path
|
122
|
+
spork_config[:role_path] || cookbook_path.gsub("/cookbooks","/roles")
|
123
|
+
end
|
124
|
+
|
106
125
|
def all_cookbooks
|
107
126
|
::Chef::CookbookLoader.new(::Chef::Config.cookbook_path)
|
108
127
|
end
|
@@ -134,7 +153,9 @@ module KnifeSpork
|
|
134
153
|
berksfile.resolve(lockfile.find(name))[:solution].first
|
135
154
|
}
|
136
155
|
|
137
|
-
|
156
|
+
#convert Berkshelf::CachedCookbook to Chef::CookbookVersion
|
157
|
+
::Chef::CookbookLoader.new(File.dirname(cookbook.path))[name]
|
158
|
+
|
138
159
|
end
|
139
160
|
|
140
161
|
# @todo #opensource
|
@@ -148,8 +169,28 @@ module KnifeSpork
|
|
148
169
|
cookbook_names.collect{ |cookbook_name| load_cookbook(cookbook_name) }
|
149
170
|
end
|
150
171
|
|
172
|
+
def load_role_from_file(role_name)
|
173
|
+
role_loader.object_from_file("#{role_path}/#{role_name}.json")
|
174
|
+
end
|
175
|
+
|
176
|
+
def load_role(role_name)
|
177
|
+
Chef::Role.load(role_name)
|
178
|
+
end
|
179
|
+
|
180
|
+
def load_node(node)
|
181
|
+
Chef::Node.load(node)
|
182
|
+
end
|
183
|
+
|
184
|
+
def load_databag(bag)
|
185
|
+
Chef::DataBag.load(bag)
|
186
|
+
end
|
187
|
+
|
188
|
+
def load_databag_item(bag, item_name)
|
189
|
+
Chef::DataBagItem.load(bag, item_name)
|
190
|
+
end
|
191
|
+
|
151
192
|
def load_environment(environment_name)
|
152
|
-
|
193
|
+
environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")
|
153
194
|
end
|
154
195
|
|
155
196
|
def load_remote_environment(environment_name)
|
@@ -167,6 +208,12 @@ module KnifeSpork
|
|
167
208
|
hash_diff remote_environment_versions, local_environment_versions
|
168
209
|
end
|
169
210
|
|
211
|
+
def json_diff(a, b)
|
212
|
+
pre_json = JSON.parse(a.respond_to?(:to_json) ? a.to_json : a)
|
213
|
+
post_json = JSON.parse(b.respond_to?(:to_json) ? b.to_json : b)
|
214
|
+
Diffy::Diff.new(JSON.pretty_generate(pre_json), JSON.pretty_generate(post_json), :diff=>"-U 3")
|
215
|
+
end
|
216
|
+
|
170
217
|
def hash_diff(hash, other)
|
171
218
|
hash.keys.inject({}) do |memo, key|
|
172
219
|
unless hash[key] == other[key]
|
data/plugins/Foodcritic.md
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 11.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 11.0.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: git
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.4.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: diffy
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.0.1
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.0.1
|
62
78
|
description: A workflow plugin to help many devs work with the same chef repo/server
|
63
79
|
email: jonlives@gmail.com
|
64
80
|
executables: []
|
@@ -75,8 +91,24 @@ files:
|
|
75
91
|
- knife-spork.gemspec
|
76
92
|
- lib/chef/knife/spork-bump.rb
|
77
93
|
- lib/chef/knife/spork-check.rb
|
94
|
+
- lib/chef/knife/spork-databag-create.rb
|
95
|
+
- lib/chef/knife/spork-databag-delete.rb
|
96
|
+
- lib/chef/knife/spork-databag-edit.rb
|
97
|
+
- lib/chef/knife/spork-databag-fromfile.rb
|
78
98
|
- lib/chef/knife/spork-info.rb
|
99
|
+
- lib/chef/knife/spork-node-create.rb
|
100
|
+
- lib/chef/knife/spork-node-delete.rb
|
101
|
+
- lib/chef/knife/spork-node-edit.rb
|
102
|
+
- lib/chef/knife/spork-node-fromfile.rb
|
103
|
+
- lib/chef/knife/spork-node-runlistadd.rb
|
104
|
+
- lib/chef/knife/spork-node-runlistremove.rb
|
105
|
+
- lib/chef/knife/spork-node-runlistset.rb
|
106
|
+
- lib/chef/knife/spork-omni.rb
|
79
107
|
- lib/chef/knife/spork-promote.rb
|
108
|
+
- lib/chef/knife/spork-role-create.rb
|
109
|
+
- lib/chef/knife/spork-role-delete.rb
|
110
|
+
- lib/chef/knife/spork-role-edit.rb
|
111
|
+
- lib/chef/knife/spork-role-fromfile.rb
|
80
112
|
- lib/chef/knife/spork-upload.rb
|
81
113
|
- lib/knife-spork.rb
|
82
114
|
- lib/knife-spork/plugins.rb
|