kitchen_hooks 1.5.5 → 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/kitchen_hooks/app.rb +3 -3
- data/lib/kitchen_hooks/helpers.rb +43 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a1d5107cae4e7385d9eaedc0b4d03ee1214d254
|
4
|
+
data.tar.gz: 99d466d56fbfe8364614ca8e46c8c3ac9890bf31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9b299caa2e7b337ca016f0bd2a04d61e7010ce3767c31f8c6ff9976891ec000620e6e2dfae902867245fc6c1370bdeba13b6f9088a1ae9cc60f89b78474f609
|
7
|
+
data.tar.gz: 87f4f6ea67fd3ffc02c8fcc597ff6c96041303f07729f29575b9d97a9d070de9213963fbc422e97789f590efefa8ef064d0228bb9a7299cf753f104606de2f7b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.6
|
data/lib/kitchen_hooks/app.rb
CHANGED
@@ -128,7 +128,7 @@ module KitchenHooks
|
|
128
128
|
possible_error = begin
|
129
129
|
perform_kitchen_upload event, knives
|
130
130
|
rescue Exception => e
|
131
|
-
report_error e, 'Could not perform kitchen upload: <i>%s</i>' % e.message
|
131
|
+
report_error e, 'Could not perform kitchen upload: <i>%s</i>' % e.message.lines.first
|
132
132
|
end
|
133
133
|
mark event, 'kitchen upload', possible_error
|
134
134
|
end
|
@@ -138,7 +138,7 @@ module KitchenHooks
|
|
138
138
|
possible_error = begin
|
139
139
|
perform_cookbook_upload event, knives
|
140
140
|
rescue Exception => e
|
141
|
-
report_error e, 'Could not perform cookbook upload: <i>%s</i>' % e.message
|
141
|
+
report_error e, 'Could not perform cookbook upload: <i>%s</i>' % e.message.lines.first
|
142
142
|
end
|
143
143
|
mark event, 'cookbook upload', possible_error
|
144
144
|
end
|
@@ -148,7 +148,7 @@ module KitchenHooks
|
|
148
148
|
possible_error = begin
|
149
149
|
perform_constraint_application event, knives
|
150
150
|
rescue Exception => e
|
151
|
-
report_error e, 'Could not apply constraints: <i>%s</i>' % e.message
|
151
|
+
report_error e, 'Could not apply constraints: <i>%s</i>' % e.message.lines.first
|
152
152
|
end
|
153
153
|
mark event, 'constraint application', possible_error
|
154
154
|
end
|
@@ -57,10 +57,10 @@ module KitchenHooks
|
|
57
57
|
tmp_clone event, :latest_commit do |clone|
|
58
58
|
Dir.chdir clone do
|
59
59
|
logger.info 'Uploading data_bags'
|
60
|
-
|
60
|
+
with_each_knife_do 'upload data_bags --chef-repo-path .', knives
|
61
61
|
|
62
62
|
logger.info 'Uploading roles'
|
63
|
-
|
63
|
+
with_each_knife_do 'upload roles --chef-repo-path .', knives
|
64
64
|
|
65
65
|
logger.info 'Uploading environments'
|
66
66
|
Dir['environments/*'].each do |e|
|
@@ -90,7 +90,7 @@ module KitchenHooks
|
|
90
90
|
end
|
91
91
|
|
92
92
|
logger.info 'Uploading cookbook'
|
93
|
-
|
93
|
+
with_each_knife_do "cookbook upload #{cookbook_name event} -o .. --freeze", knives
|
94
94
|
end
|
95
95
|
|
96
96
|
berksfile = File::join clone, 'Berksfile'
|
@@ -109,22 +109,45 @@ module KitchenHooks
|
|
109
109
|
end
|
110
110
|
|
111
111
|
|
112
|
+
def berkshelf_config knife
|
113
|
+
ridley = Ridley::from_chef_config knife
|
114
|
+
config = {
|
115
|
+
chef: {
|
116
|
+
node_name: ridley.client_name,
|
117
|
+
client_key: ridley.client_key,
|
118
|
+
chef_server_url: ridley.server_url
|
119
|
+
},
|
120
|
+
ssl: {
|
121
|
+
verify: false
|
122
|
+
}
|
123
|
+
}
|
124
|
+
config_path = File.join tmp, "#{SecureRandom.hex}-berkshelf.json"
|
125
|
+
File.open(config_path, 'w') do |f|
|
126
|
+
f.puts JSON::pretty_generate config
|
127
|
+
end
|
128
|
+
return config_path
|
129
|
+
end
|
130
|
+
|
131
|
+
|
112
132
|
def berks_upload berksfile, knife, options={}
|
113
133
|
logger.debug 'started berks_upload berksfile=%s, knife=%s' % [
|
114
134
|
berksfile.inspect, knife.inspect
|
115
135
|
]
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
136
|
+
config_path = berkshelf_config(knife)
|
137
|
+
|
138
|
+
cmd = "berks install --debug --berksfile %s" % [
|
139
|
+
Shellwords::escape(berksfile)
|
140
|
+
]
|
141
|
+
logger.debug "berks_install: %s" % cmd
|
142
|
+
system cmd
|
143
|
+
|
144
|
+
cmd = "berks upload --debug --berksfile %s --config %s" % [
|
145
|
+
Shellwords::escape(berksfile), Shellwords::escape(config_path)
|
146
|
+
]
|
147
|
+
logger.debug "berks_upload: %s" % cmd
|
148
|
+
system cmd
|
149
|
+
|
150
|
+
FileUtils.rm_rf config_path
|
128
151
|
logger.debug 'finished berks_upload: %s' % berksfile
|
129
152
|
end
|
130
153
|
|
@@ -155,9 +178,13 @@ module KitchenHooks
|
|
155
178
|
end
|
156
179
|
|
157
180
|
|
181
|
+
def with_each_knife_do command, knives
|
182
|
+
with_each_knife "knife #{command} --config %{knife}", knives
|
183
|
+
end
|
184
|
+
|
158
185
|
def with_each_knife command, knives
|
159
186
|
knives.map do |k|
|
160
|
-
cmd =
|
187
|
+
cmd = command % { knife: Shellwords::escape(k) }
|
161
188
|
logger.debug 'with_each_knife: %s' % cmd
|
162
189
|
`#{cmd}`
|
163
190
|
end
|