knife-spork 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +16 -0
- data/README.md +23 -3
- data/knife-spork.gemspec +1 -1
- data/lib/chef/knife/spork-bump.rb +10 -3
- data/lib/chef/knife/spork-databag-fromfile.rb +6 -0
- data/lib/chef/knife/spork-promote.rb +11 -0
- data/lib/chef/knife/spork-role-delete.rb +11 -0
- data/lib/knife-spork/plugins/git.rb +190 -1
- data/lib/knife-spork/plugins/irccat.rb +25 -0
- data/lib/knife-spork/plugins/plugin.rb +8 -0
- data/lib/knife-spork/runner.rb +6 -1
- data/plugins/Git.md +2 -2
- metadata +19 -20
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MTU0NTkzMThmMTBlMTdhZGM3ZDc0YTI2M2JkNDM3YWVhMzM4ZjM2YQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ff8c79e614ce12d680d5aeb4f2f4880db47fef8
|
4
|
+
data.tar.gz: ee66678d1171a4403f5a9c7b1ae853b085dfbd99
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YTRkYTllMDJkY2E5YTIyNzNhNmRmYzU1NDViYTU0NjAxNmMzM2EwYjRjNTY3
|
11
|
-
YmJhNmRlMWYzNGZjOTdmMDM3N2ZjNDA0YjdkOWJhZDhiYWQ2YmU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZjUxODgyMTVhZjc4MmNlM2YyMDcwMjljYmVjODA2OTAxYTQwMmI5ZjQ0YjZh
|
14
|
-
NjZlZTE0NjE4MTRiOTMwN2Q0ZjM4MWEwNGU0MTJhM2VmYmQzOGNlNmE2OWVh
|
15
|
-
MTlmNTc2MjhjOTcyMWY2N2Q1Y2I4MzRjMjViNzQwYjFjMmU3N2E=
|
6
|
+
metadata.gz: 32dd1355f125d3945976867a55e627045a748b793469c9db25a432a204cac61a2d13fba771023e9957e762e22d2390ac42ce718d9a31f5f4ed0fe63a84ef8afb
|
7
|
+
data.tar.gz: 767fc04c9b0efd98add867321d3cee37256c7382bca5ba581924be8dd624e419956fdbcc8c96c02e248b7bc2483fced576e22504c0e356a0d6da594c0a71cf8d
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-1.
|
1
|
+
ruby-2.1.1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 1.6.0(18th August, 2015)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- Optionally print a link to a gist of change diffs on the command line in addition to in plugin notifications (https://github.com/jonlives/knife-spork/issues/183
|
6
|
+
- Display a warning when deleting a role currently in use by nodes on the Chef server (https://github.com/jonlives/knife-spork/issues/184)
|
7
|
+
- Spork bump will now bump in the current directory if no cookbook name is specified and metadata.rb is found (https://github.com/jonlives/knife-spork/issues/186)
|
8
|
+
- Spork promote now prompts for confirmation if a newer version of a cookbook exists on the server than the one being promoted (Thanks to @chazzle https://github.com/jonlives/knife-spork/pull/188)
|
9
|
+
- Significantly refactored git plugin, now supporting optional automatic commit & push (Thanks to @jeunito https://github.com/jonlives/knife-spork/pull/187)
|
10
|
+
|
11
|
+
|
12
|
+
Bugfixes:
|
13
|
+
|
14
|
+
- Correct parameter errors in Slack plugin README.md (Thanks to BarthV https://github.com/jonlives/knife-spork/pull/185)
|
15
|
+
- Spork data bag from file now shows an error if data bag name is missed off (Thanks to @kdaniels https://github.com/jonlives/knife-spork/pull/190)
|
16
|
+
|
1
17
|
## 1.5.1(26th February, 2015)
|
2
18
|
|
3
19
|
Bugfixes:
|
data/README.md
CHANGED
@@ -21,7 +21,9 @@ or install the gem manually:
|
|
21
21
|
gem install knife-spork
|
22
22
|
```
|
23
23
|
|
24
|
-
|
24
|
+
knife-spork is also included in the [Chef Devlopment Kit](https://downloads.chef.io/chef-dk/).
|
25
|
+
|
26
|
+
**Please note**: As of version 1.6.0, knife-spork requires Ruby 2.1.1 or greater and Chef version 11.0.0 or greater. If you're still using < Ruby 2.0 or Chef 11, please continue to use knife-spork 1.5.x
|
25
27
|
Spork Configuration
|
26
28
|
-------------------
|
27
29
|
Out of the box, knife spork will work with no configuration. However, you can optionally enable several features to enhance its functionality.
|
@@ -56,6 +58,8 @@ custom_plugin_path: "/home/me/spork-plugins"
|
|
56
58
|
always_promote_remote: true
|
57
59
|
skip_berkshelf: false
|
58
60
|
role_match_file_name: true
|
61
|
+
role_safe_delete: true
|
62
|
+
stdout_diffs
|
59
63
|
json_options:
|
60
64
|
indent: " "
|
61
65
|
plugins:
|
@@ -102,9 +106,8 @@ plugins:
|
|
102
106
|
eventinator:
|
103
107
|
url: http://eventinator.mydomain.com/events/oneshot
|
104
108
|
slack:
|
105
|
-
|
109
|
+
webhook_url: https://hooks.slack.com/services/ABCD/efgh
|
106
110
|
channel: "#sysops"
|
107
|
-
teamname: myteam
|
108
111
|
username: knife
|
109
112
|
icon_url: http://example.com/image.jpg
|
110
113
|
rubocop:
|
@@ -147,9 +150,16 @@ The `save_environment_on_create` directive allows you to have the ```knife spork
|
|
147
150
|
#### Role Path
|
148
151
|
The `role_path` allows you to specify the path to where you store your chef role json files. If this parameter is not specified, spork will default to using the first element of your cookbook_path, replacing the word "cookbooks" with "roles"
|
149
152
|
|
153
|
+
#### Role Safe Delete
|
154
|
+
The `role_safe_delete` flag will, when you use the spork ```knife spork role delete``` command, check to see if any nodes currently have that role in their runlist and exit with an error message if any are found.
|
155
|
+
|
150
156
|
#### Role Match File Name
|
151
157
|
The `role_match_file_name` flag allows you to check whether the file name that is used to upload a role matches the role name as well. If the parameter is specified, or flag `--match-filename` is set, spork will not let you upload a role from a file unless the name matches the rolename.
|
152
158
|
|
159
|
+
#### Stdout Diffs
|
160
|
+
The `stdout_diffs` flag will cause any diffs generated by knife-spork (for example on events such as data bag uploads, role edits etc) to be displayed on stdout in addition to any notifications generated by plugins.
|
161
|
+
|
162
|
+
|
153
163
|
#### Custom Plugin Path
|
154
164
|
The `custom_plugin_path` allows you to specify an additional directory from which to load knife-spork plugins. If this parameter is not specified or the path set does not exist, only the default plugins shipped with knife-spork will be loaded (if enabled in config)
|
155
165
|
|
@@ -502,3 +512,13 @@ knife spork environment delete
|
|
502
512
|
knife spork environment edit
|
503
513
|
knife spork environment from file
|
504
514
|
```
|
515
|
+
|
516
|
+
Troubleshooting
|
517
|
+
---------------
|
518
|
+
If you get an error when running `knife spork <command>` and the message shown when running with the `-VV` flag contains:
|
519
|
+
```ruby
|
520
|
+
undefined method `gsub' for #<Pathname:0x00000002d3a6b0> (NoMethodError)
|
521
|
+
```
|
522
|
+
...then you are probably using `Librarian::Chef.install_path()` in your `knife.rb` file.
|
523
|
+
|
524
|
+
To fix this you need to call `.to_s` on the install path, i.e. ``Librarian::Chef.install_path().to_s`.
|
data/knife-spork.gemspec
CHANGED
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'knife-spork'
|
5
|
-
gem.version = '1.
|
5
|
+
gem.version = '1.6.0'
|
6
6
|
gem.authors = ["Jon Cowie"]
|
7
7
|
gem.email = 'jonlives@gmail.com'
|
8
8
|
gem.homepage = 'https://github.com/jonlives/knife-spork'
|
@@ -35,10 +35,17 @@ module KnifeSpork
|
|
35
35
|
self.config = Chef::Config.merge!(config)
|
36
36
|
config[:cookbook_path] ||= Chef::Config[:cookbook_path]
|
37
37
|
|
38
|
-
|
38
|
+
cookbook_name = ""
|
39
|
+
|
40
|
+
if @name_args.empty? && File.exists?("#{Dir.pwd}/metadata.rb")
|
41
|
+
cookbook_name = File.read("#{Dir.pwd}/metadata.rb").split("\n").select{|l|l.start_with?("name")}.first.split.last.gsub("\"","")
|
42
|
+
ui.info "Cookbook name omitted, but metadata.rb for cookbook #{cookbook_name} found - bumping that."
|
43
|
+
elsif @name_args.empty?
|
39
44
|
show_usage
|
40
45
|
ui.error("You must specify at least a cookbook name")
|
41
46
|
exit 1
|
47
|
+
else
|
48
|
+
cookbook_name = name_args.first
|
42
49
|
end
|
43
50
|
|
44
51
|
# Temporary fix for #138 to allow Berkshelf functionality
|
@@ -46,12 +53,12 @@ module KnifeSpork
|
|
46
53
|
unload_berkshelf_if_specified
|
47
54
|
|
48
55
|
#First load so plugins etc know what to work with
|
49
|
-
@cookbook = load_cookbook(
|
56
|
+
@cookbook = load_cookbook(cookbook_name)
|
50
57
|
|
51
58
|
run_plugins(:before_bump)
|
52
59
|
|
53
60
|
#Reload cookbook in case a VCS plugin found updates
|
54
|
-
@cookbook = load_cookbook(
|
61
|
+
@cookbook = load_cookbook(cookbook_name)
|
55
62
|
bump
|
56
63
|
run_plugins(:after_bump)
|
57
64
|
end
|
@@ -30,6 +30,12 @@ module KnifeSpork
|
|
30
30
|
self.config = Chef::Config.merge!(config)
|
31
31
|
|
32
32
|
@object_name = @name_args.first
|
33
|
+
# This should be the data bag name. If it isn't, some poor soul forgot the data bag name.
|
34
|
+
# Check to see if there are any more arguments, and if not, warn about usage.
|
35
|
+
if @name_args.drop(1).size == 0
|
36
|
+
print "USAGE: #{banner}"
|
37
|
+
exit(1)
|
38
|
+
end
|
33
39
|
|
34
40
|
if config[:all] == true
|
35
41
|
test = Chef::Knife::DataBagFromFile.new
|
@@ -61,6 +61,7 @@ module KnifeSpork
|
|
61
61
|
@environments, @cookbook = load_environments_and_cookbook
|
62
62
|
|
63
63
|
check_cookbook_uploaded(@cookbook)
|
64
|
+
check_cookbook_latest(@cookbook)
|
64
65
|
|
65
66
|
@environments.each do |e|
|
66
67
|
environment = load_environment_from_file(e)
|
@@ -182,5 +183,15 @@ module KnifeSpork
|
|
182
183
|
exit(1)
|
183
184
|
end
|
184
185
|
end
|
186
|
+
|
187
|
+
def check_cookbook_latest(cookbook_name)
|
188
|
+
validate_version!(config[:version])
|
189
|
+
version = config[:version] || load_cookbook(cookbook_name).version
|
190
|
+
cb_latest = Chef::CookbookVersion.load(cookbook_name).metadata.version
|
191
|
+
# ui.msg "server: #{cb_latest} -- local: #{version}"
|
192
|
+
if cb_latest > version
|
193
|
+
ui.confirm "There is a later verison of #{cookbook_name} on the chef server. Would you still like to promote version #{version}?"
|
194
|
+
end
|
195
|
+
end
|
185
196
|
end
|
186
197
|
end
|
@@ -5,6 +5,7 @@ module KnifeSpork
|
|
5
5
|
|
6
6
|
deps do
|
7
7
|
require 'knife-spork/runner'
|
8
|
+
require 'chef/search/query'
|
8
9
|
end
|
9
10
|
|
10
11
|
banner 'knife spork role delete ROLENAME (options)'
|
@@ -22,6 +23,16 @@ module KnifeSpork
|
|
22
23
|
@object_name = @name_args.first
|
23
24
|
|
24
25
|
run_plugins(:before_roledelete)
|
26
|
+
|
27
|
+
if spork_config.role_safe_delete
|
28
|
+
query = Chef::Search::Query.new
|
29
|
+
nodes = query.search('node', "roles:#{@object_name}").first
|
30
|
+
if nodes.size > 0
|
31
|
+
ui.fatal("#{nodes.size} nodes have been found which still contain the role #{@object_name} in their runlists. Please remove this role from all runlists before deleting it.")
|
32
|
+
exit(1)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
pre_role = load_role(@object_name)
|
26
37
|
role_delete
|
27
38
|
post_role = {}
|
@@ -7,6 +7,138 @@ module KnifeSpork
|
|
7
7
|
|
8
8
|
def perform; end
|
9
9
|
|
10
|
+
# Role Git wrappers
|
11
|
+
def before_rolecreate
|
12
|
+
if config.auto_push
|
13
|
+
if !File.directory?(role_path)
|
14
|
+
ui.error "Role path #{role_path} does not exist"
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
git_pull(role_path)
|
18
|
+
if File.exist?(File.join(role_path, object_name + '.json'))
|
19
|
+
ui.error 'Role already exists in local git, aborting creation'
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def after_rolecreate
|
25
|
+
if config.auto_push
|
26
|
+
if !File.directory?(role_path)
|
27
|
+
ui.error "Role path #{role_path} does not exist"
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
save_role(object_name) unless object_difference == ''
|
31
|
+
end
|
32
|
+
end
|
33
|
+
def before_roleedit
|
34
|
+
if config.auto_push
|
35
|
+
git_pull(role_path)
|
36
|
+
if !File.exist?(File.join(role_path, object_name + '.json'))
|
37
|
+
ui.error 'Role does not exist in git, please create it first with spork'
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
def after_roleedit
|
43
|
+
if config.auto_push
|
44
|
+
save_role(object_name) unless object_difference == ''
|
45
|
+
end
|
46
|
+
end
|
47
|
+
def before_roledelete
|
48
|
+
if config.auto_push
|
49
|
+
git_pull(role_path)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
def after_roledelete
|
53
|
+
if config.auto_push
|
54
|
+
delete_role(object_name)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Environmental Git wrappers
|
59
|
+
def before_environmentcreate
|
60
|
+
if config.auto_push
|
61
|
+
if !File.directory?(environment_path)
|
62
|
+
ui.error "Environment path #{environment_path} does not exist"
|
63
|
+
exit 1
|
64
|
+
end
|
65
|
+
git_pull(environment_path)
|
66
|
+
if File.exist?(File.join(environment_path, object_name + '.json'))
|
67
|
+
ui.error 'Environment already exists in local git, aborting creation'
|
68
|
+
exit 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
def after_environmentcreate
|
73
|
+
if config.auto_push
|
74
|
+
save_environment(object_name) unless object_difference == ''
|
75
|
+
end
|
76
|
+
end
|
77
|
+
def before_environmentedit
|
78
|
+
if config.auto_push
|
79
|
+
git_pull(environment_path)
|
80
|
+
if !File.exist?(File.join(environment_path, object_name + '.json'))
|
81
|
+
ui.error 'Environment does not exist in git, please create it first with spork'
|
82
|
+
exit 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
def after_environmentedit
|
87
|
+
if config.auto_push
|
88
|
+
save_environment(object_name) unless object_difference == ''
|
89
|
+
end
|
90
|
+
end
|
91
|
+
def before_environmentdelete
|
92
|
+
if config.auto_push
|
93
|
+
git_pull(environment_path)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
def after_environmentdelete
|
97
|
+
if config.auto_push
|
98
|
+
delete_environment(object_name)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Node Git wrappers
|
103
|
+
def before_nodecreate
|
104
|
+
if config.auto_push
|
105
|
+
git_pull(node_path)
|
106
|
+
if File.exist?(File.join(node_path, object_name + '.json'))
|
107
|
+
ui.error 'Node already exists in local git, aborting creation'
|
108
|
+
exit 1
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
def after_nodecreate
|
113
|
+
if config.auto_push
|
114
|
+
save_node(object_name) unless object_difference == ''
|
115
|
+
end
|
116
|
+
end
|
117
|
+
def before_nodeedit
|
118
|
+
if config.auto_push
|
119
|
+
git_pull(node_path)
|
120
|
+
if !File.exist?(File.join(node_path, object_name + '.json'))
|
121
|
+
ui.error 'Node does not exist in git, please bootstrap one first'
|
122
|
+
exit 1
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
def after_nodeedit
|
127
|
+
if config.auto_push
|
128
|
+
save_node(object_name) unless object_difference == ''
|
129
|
+
end
|
130
|
+
end
|
131
|
+
def before_nodedelete
|
132
|
+
if config.auto_push
|
133
|
+
git_pull(node_path)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
def after_nodedelete
|
137
|
+
if config.auto_push
|
138
|
+
delete_node(object_name)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
10
142
|
def before_bump
|
11
143
|
git_pull(environment_path) unless cookbook_path.include?(environment_path.gsub"/environments","")
|
12
144
|
git_pull_submodules(environment_path) unless cookbook_path.include?(environment_path.gsub"/environments","")
|
@@ -55,6 +187,50 @@ module KnifeSpork
|
|
55
187
|
git_push(branch)
|
56
188
|
end
|
57
189
|
end
|
190
|
+
|
191
|
+
def save_node(node)
|
192
|
+
json = JSON.pretty_generate(Chef::Node.load(node))
|
193
|
+
node_file = File.expand_path( File.join(node_path, "#{node}.json") )
|
194
|
+
File.open(node_file, 'w'){ |f| f.puts(json) }
|
195
|
+
git_add(node_path, "#{node}.json")
|
196
|
+
git_commit(node_path, "[NODE] Updated #{node}")
|
197
|
+
git_push(branch) if config.auto_push
|
198
|
+
end
|
199
|
+
def delete_node(node)
|
200
|
+
git_rm(node_path, "#{node}.json")
|
201
|
+
git_commit(node_path, "[NODE] Deleted #{node}")
|
202
|
+
git_push(branch) if config.auto_push
|
203
|
+
end
|
204
|
+
|
205
|
+
def save_role(role)
|
206
|
+
json = JSON.pretty_generate(Chef::Role.load(role))
|
207
|
+
role_file = File.expand_path( File.join(role_path, "#{role}.json") )
|
208
|
+
File.open(role_file, 'w'){ |f| f.puts(json) }
|
209
|
+
git_add(role_path, "#{role}.json")
|
210
|
+
git_commit(role_path, "[ROLE] Updated #{role}")
|
211
|
+
git_push(branch)
|
212
|
+
end
|
213
|
+
def delete_role(role)
|
214
|
+
git_rm(role_path, "#{role}.json")
|
215
|
+
if config.auto_push
|
216
|
+
git_commit(role_path, "[ROLE] Deleted #{role}")
|
217
|
+
git_push(branch)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def save_environment(environment)
|
222
|
+
json = JSON.pretty_generate(Chef::Environment.load(environment))
|
223
|
+
environment_file = File.expand_path( File.join(environment_path, "#{environment}.json") )
|
224
|
+
File.open(environment_file, 'w'){ |f| f.puts(json) }
|
225
|
+
git_add(environment_path, "#{environment}.json")
|
226
|
+
git_commit(environment_path, "[ENV] Updated #{environment}")
|
227
|
+
git_push(branch) if config.auto_push
|
228
|
+
end
|
229
|
+
def delete_environment(environment)
|
230
|
+
git_rm(environment_path, "#{environment}.json")
|
231
|
+
git_commit(environment_path, "[ENV] Deleted #{environment}")
|
232
|
+
git_push(branch) if config.auto_push
|
233
|
+
end
|
58
234
|
|
59
235
|
private
|
60
236
|
def git
|
@@ -77,7 +253,7 @@ module KnifeSpork
|
|
77
253
|
def git_pull(path)
|
78
254
|
if is_repo?(path)
|
79
255
|
ui.msg "Git: Pulling latest changes from #{path}"
|
80
|
-
output = IO.popen("git pull 2>&1")
|
256
|
+
output = IO.popen("cd #{path} && git pull 2>&1")
|
81
257
|
Process.wait
|
82
258
|
exit_code = $?
|
83
259
|
if !exit_code.exitstatus == 0
|
@@ -136,6 +312,19 @@ module KnifeSpork
|
|
136
312
|
end
|
137
313
|
end
|
138
314
|
|
315
|
+
def git_rm(filepath, filename)
|
316
|
+
if is_repo?(filepath)
|
317
|
+
ui.msg "Git rm'ing #{filepath}/#{filename}"
|
318
|
+
output = IO.popen("cd #{filepath} && git rm #{filename}")
|
319
|
+
Process.wait
|
320
|
+
exit_code = $?
|
321
|
+
if !exit_code.exitstatus == 0
|
322
|
+
ui.error "#{output.read()}\n"
|
323
|
+
exit 1
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
139
328
|
def git_tag(tag)
|
140
329
|
begin
|
141
330
|
git.add_tag(tag)
|
@@ -44,6 +44,7 @@ module KnifeSpork
|
|
44
44
|
environments.each do |environment|
|
45
45
|
diff = environment_diffs[environment.name]
|
46
46
|
env_gist = env_gist(environment, diff) if config.gist
|
47
|
+
display_gist(env_gist) if env_gist
|
47
48
|
irccat(template(:promote) % {
|
48
49
|
:organization => organization,
|
49
50
|
:current_user => current_user,
|
@@ -56,6 +57,7 @@ module KnifeSpork
|
|
56
57
|
|
57
58
|
def after_environmentfromfile
|
58
59
|
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
60
|
+
display_gist(environment_gist) if environment_gist
|
59
61
|
irccat(template(:environmentfromfile) % {
|
60
62
|
:organization => organization,
|
61
63
|
:current_user => current_user,
|
@@ -66,6 +68,7 @@ module KnifeSpork
|
|
66
68
|
|
67
69
|
def after_environmentedit
|
68
70
|
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
71
|
+
display_gist(environment_gist) if environment_gist
|
69
72
|
irccat(template(:environmentedit) % {
|
70
73
|
:organization => organization,
|
71
74
|
:current_user => current_user,
|
@@ -76,6 +79,7 @@ module KnifeSpork
|
|
76
79
|
|
77
80
|
def after_environmentcreate
|
78
81
|
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
82
|
+
display_gist(environment_gist) if environment_gist
|
79
83
|
irccat(template(:environmentcreate) % {
|
80
84
|
:organization => organization,
|
81
85
|
:current_user => current_user,
|
@@ -86,6 +90,7 @@ module KnifeSpork
|
|
86
90
|
|
87
91
|
def after_environmentdelete
|
88
92
|
environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty?
|
93
|
+
display_gist(environment_gist) if environment_gist
|
89
94
|
irccat(template(:environmentdelete) % {
|
90
95
|
:organization => organization,
|
91
96
|
:current_user => current_user,
|
@@ -96,6 +101,7 @@ module KnifeSpork
|
|
96
101
|
|
97
102
|
def after_rolefromfile
|
98
103
|
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
104
|
+
display_gist(role_gist) if role_gist
|
99
105
|
irccat(template(:rolefromfile) % {
|
100
106
|
:organization => organization,
|
101
107
|
:current_user => current_user,
|
@@ -106,6 +112,7 @@ module KnifeSpork
|
|
106
112
|
|
107
113
|
def after_roleedit
|
108
114
|
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
115
|
+
display_gist(role_gist) if role_gist
|
109
116
|
irccat(template(:roleedit) % {
|
110
117
|
:organization => organization,
|
111
118
|
:current_user => current_user,
|
@@ -116,6 +123,7 @@ module KnifeSpork
|
|
116
123
|
|
117
124
|
def after_rolecreate
|
118
125
|
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
126
|
+
display_gist(role_gist) if role_gist
|
119
127
|
irccat(template(:rolecreate) % {
|
120
128
|
:organization => organization,
|
121
129
|
:current_user => current_user,
|
@@ -126,6 +134,7 @@ module KnifeSpork
|
|
126
134
|
|
127
135
|
def after_roledelete
|
128
136
|
role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty?
|
137
|
+
display_gist(role_gist) if role_gist
|
129
138
|
irccat(template(:roledelete) % {
|
130
139
|
:organization => organization,
|
131
140
|
:current_user => current_user,
|
@@ -136,6 +145,7 @@ module KnifeSpork
|
|
136
145
|
|
137
146
|
def after_databagedit
|
138
147
|
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
148
|
+
display_gist(databag_gist) if databag_gist
|
139
149
|
irccat(template(:databagedit) % {
|
140
150
|
:organization => organization,
|
141
151
|
:current_user => current_user,
|
@@ -147,6 +157,7 @@ module KnifeSpork
|
|
147
157
|
|
148
158
|
def after_databagdelete
|
149
159
|
databag_gist = object_gist("databag item", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
160
|
+
display_gist(databag_gist) if databag_gist
|
150
161
|
irccat(template(:databagdelete) % {
|
151
162
|
:organization => organization,
|
152
163
|
:current_user => current_user,
|
@@ -157,6 +168,7 @@ module KnifeSpork
|
|
157
168
|
|
158
169
|
def after_databagitemdelete
|
159
170
|
databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty?
|
171
|
+
display_gist(databag_gist) if databag_gist
|
160
172
|
irccat(template(:databagitemdelete) % {
|
161
173
|
:organization => organization,
|
162
174
|
:current_user => current_user,
|
@@ -168,6 +180,7 @@ module KnifeSpork
|
|
168
180
|
|
169
181
|
def after_databagcreate
|
170
182
|
databag_gist = object_gist("databag", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
183
|
+
display_gist(databag_gist) if databag_gist
|
171
184
|
irccat(template(:databagcreate) % {
|
172
185
|
:organization => organization,
|
173
186
|
:current_user => current_user,
|
@@ -178,6 +191,7 @@ module KnifeSpork
|
|
178
191
|
|
179
192
|
def after_databagfromfile
|
180
193
|
databag_gist = object_gist("databag", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
194
|
+
display_gist(databag_gist) if databag_gist
|
181
195
|
irccat(template(:databagfromfile) % {
|
182
196
|
:organization => organization,
|
183
197
|
:current_user => current_user,
|
@@ -189,6 +203,7 @@ module KnifeSpork
|
|
189
203
|
|
190
204
|
def after_nodeedit
|
191
205
|
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
206
|
+
display_gist(node_gist) if node_gist
|
192
207
|
irccat(template(:nodeedit) % {
|
193
208
|
:organization => organization,
|
194
209
|
:current_user => current_user,
|
@@ -199,6 +214,7 @@ module KnifeSpork
|
|
199
214
|
|
200
215
|
def after_nodedelete
|
201
216
|
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
217
|
+
display_gist(node_gist) if node_gist
|
202
218
|
irccat(template(:nodedelete) % {
|
203
219
|
:organization => organization,
|
204
220
|
:current_user => current_user,
|
@@ -209,6 +225,7 @@ module KnifeSpork
|
|
209
225
|
|
210
226
|
def after_nodecreate
|
211
227
|
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
228
|
+
display_gist(node_gist) if node_gist
|
212
229
|
irccat(template(:nodecreate) % {
|
213
230
|
:organization => organization,
|
214
231
|
:current_user => current_user,
|
@@ -219,6 +236,7 @@ module KnifeSpork
|
|
219
236
|
|
220
237
|
def after_nodefromfile
|
221
238
|
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
239
|
+
display_gist(node_gist) if node_gist
|
222
240
|
irccat(template(:nodefromfile) % {
|
223
241
|
:organization => organization,
|
224
242
|
:current_user => current_user,
|
@@ -229,6 +247,7 @@ module KnifeSpork
|
|
229
247
|
|
230
248
|
def after_noderunlistadd
|
231
249
|
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
250
|
+
display_gist(node_gist) if node_gist
|
232
251
|
irccat(template(:noderunlistadd) % {
|
233
252
|
:organization => organization,
|
234
253
|
:current_user => current_user,
|
@@ -240,6 +259,7 @@ module KnifeSpork
|
|
240
259
|
|
241
260
|
def after_noderunlistremove
|
242
261
|
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
262
|
+
display_gist(node_gist) if node_gist
|
243
263
|
irccat(template(:noderunlistremove) % {
|
244
264
|
:organization => organization,
|
245
265
|
:current_user => current_user,
|
@@ -251,6 +271,7 @@ module KnifeSpork
|
|
251
271
|
|
252
272
|
def after_noderunlistset
|
253
273
|
node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty?
|
274
|
+
display_gist(node_gist) if node_gist
|
254
275
|
irccat(template(:noderunlistset) % {
|
255
276
|
:organization => organization,
|
256
277
|
:current_user => current_user,
|
@@ -281,6 +302,10 @@ module KnifeSpork
|
|
281
302
|
%x[ echo "#{msg}" | #{config.gist}]
|
282
303
|
end
|
283
304
|
|
305
|
+
def display_gist(gist)
|
306
|
+
ui.info "Gist generated at #{gist}"
|
307
|
+
end
|
308
|
+
|
284
309
|
def object_gist(object_type, object_name, object_diff)
|
285
310
|
msg = "#{object_type.capitalize} #{object_name} changed at #{Time.now.getutc} by #{current_user}\n\nDiff is as follows:\n\n#{object_diff}"
|
286
311
|
%x[ echo "#{msg}" | #{config.gist}]
|
@@ -71,6 +71,14 @@ module KnifeSpork
|
|
71
71
|
@options[:cookbook_path]
|
72
72
|
end
|
73
73
|
|
74
|
+
def role_path
|
75
|
+
File.expand_path(config.role_path.nil? ? "#{cookbook_path}/../roles" : config[:role_path])
|
76
|
+
end
|
77
|
+
|
78
|
+
def node_path
|
79
|
+
File.expand_path(config.role_path.nil? ? "#{cookbook_path}/../nodes" : config[:role_path])
|
80
|
+
end
|
81
|
+
|
74
82
|
def object_name
|
75
83
|
@options[:object_name]
|
76
84
|
end
|
data/lib/knife-spork/runner.rb
CHANGED
@@ -269,7 +269,12 @@ module KnifeSpork
|
|
269
269
|
def json_diff(a, b)
|
270
270
|
pre_json = JSON.parse(a.respond_to?(:to_json) ? a.to_json : a)
|
271
271
|
post_json = JSON.parse(b.respond_to?(:to_json) ? b.to_json : b)
|
272
|
-
Diffy::Diff.new(JSON.pretty_generate(pre_json), JSON.pretty_generate(post_json), :diff=>"-U 3")
|
272
|
+
diff = Diffy::Diff.new(JSON.pretty_generate(pre_json), JSON.pretty_generate(post_json), :diff=>"-U 3")
|
273
|
+
if spork_config.stdout_diffs
|
274
|
+
ui.info "Diff:"
|
275
|
+
ui.info diff.to_s(:color)
|
276
|
+
end
|
277
|
+
return diff.to_s.gsub(/[()]/, '\\\\\0')
|
273
278
|
end
|
274
279
|
|
275
280
|
def hash_diff(hash, other)
|
data/plugins/Git.md
CHANGED
@@ -47,7 +47,7 @@ The git branch to push/pull to/from.
|
|
47
47
|
- Default: `master`
|
48
48
|
|
49
49
|
#### auto_push
|
50
|
-
An optional true / false parameter indicating whether or not
|
50
|
+
An optional true / false parameter indicating whether or not subcommands manipulating environment, role, node, databag files should be automatically comitted and pushed to Git
|
51
51
|
|
52
52
|
- Type: `Boolean`
|
53
|
-
- Default: `false`
|
53
|
+
- Default: `false`
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Cowie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.1.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: chef-zero
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: chef
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 11.0.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 11.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: git
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.2.5
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.2.5
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: app_conf
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.4.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.4.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: diffy
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 3.0.1
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 3.0.1
|
111
111
|
description: KnifeSpork is a workflow plugin for Chef::Knife which helps multiple
|
@@ -206,17 +206,17 @@ require_paths:
|
|
206
206
|
- lib
|
207
207
|
required_ruby_version: !ruby/object:Gem::Requirement
|
208
208
|
requirements:
|
209
|
-
- -
|
209
|
+
- - '>='
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
213
|
requirements:
|
214
|
-
- -
|
214
|
+
- - '>='
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
218
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.
|
219
|
+
rubygems_version: 2.0.14
|
220
220
|
signing_key:
|
221
221
|
specification_version: 4
|
222
222
|
summary: A workflow plugin to help many devs work with the same chef repo/server
|
@@ -232,4 +232,3 @@ test_files:
|
|
232
232
|
- spec/unit/spork_info_spec.rb
|
233
233
|
- spec/unit/spork_promote_spec.rb
|
234
234
|
- spec/unit/spork_upload_spec.rb
|
235
|
-
has_rdoc:
|