chef-apply 0.2.8 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +84 -63
- data/README.md +6 -0
- data/chef-apply.gemspec +1 -0
- data/i18n/errors/en.yml +11 -10
- data/lib/chef_apply/action/base.rb +0 -84
- data/lib/chef_apply/action/converge_target.rb +60 -24
- data/lib/chef_apply/action/install_chef.rb +99 -10
- data/lib/chef_apply/cli.rb +19 -1
- data/lib/chef_apply/config.rb +1 -0
- data/lib/chef_apply/error.rb +1 -0
- data/lib/chef_apply/errors/ccr_failure_mapper.rb +2 -2
- data/lib/chef_apply/target_host.rb +113 -73
- data/lib/chef_apply/target_host/linux.rb +63 -0
- data/lib/chef_apply/target_host/windows.rb +62 -0
- data/lib/chef_apply/version.rb +1 -1
- data/spec/integration/fixtures/chef_help.out +1 -0
- data/spec/unit/action/base_spec.rb +0 -30
- data/spec/unit/action/converge_target_spec.rb +130 -73
- data/spec/unit/action/install_chef_spec.rb +118 -23
- data/spec/unit/cli_spec.rb +32 -4
- data/spec/unit/target_host/linux_spec.rb +57 -0
- data/spec/unit/target_host/windows_spec.rb +43 -0
- data/spec/unit/target_host_spec.rb +130 -135
- data/spec/unit/ui/error_printer_spec.rb +1 -1
- metadata +27 -8
- data/lib/chef_apply/action/install_chef/base.rb +0 -117
- data/lib/chef_apply/action/install_chef/linux.rb +0 -37
- data/lib/chef_apply/action/install_chef/windows.rb +0 -54
- data/spec/unit/action/install_chef/base_spec.rb +0 -168
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07ef8ad757564bff3e3578079d19bbb8b50ec44e3f58ac627046a54b9b26e92e
|
4
|
+
data.tar.gz: 26cd6927e33f4c97f1809518c69455517570983b4f493c6fe99af8ebd43b2952
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c85c8f263f8d0c6a1546bc1d6ad96cdd6d4ca4ab2bc94dd6dad26b2d8ab1c52a740fbae0384a846d668a4c52cda165966534f9c49d87e22e49cefd0ee2727e
|
7
|
+
data.tar.gz: 82c8fad2e537f69bd539c757522e5aee9315d727391233538b3870eff4b2302fc93a4240ca9c04d801320f97472e999029e59d5650855b367ec616cde7e4bfff
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
chef-apply (0.2.
|
4
|
+
chef-apply (0.2.13)
|
5
5
|
chef (>= 14.0)
|
6
6
|
chef-dk (>= 3.0)
|
7
7
|
chef-telemetry
|
8
|
+
license-acceptance (~> 1.0, >= 1.0.11)
|
8
9
|
mixlib-cli
|
9
10
|
mixlib-config
|
10
11
|
mixlib-install
|
@@ -21,28 +22,20 @@ GEM
|
|
21
22
|
addressable (2.5.2)
|
22
23
|
public_suffix (>= 2.0.2, < 4.0)
|
23
24
|
ast (2.4.0)
|
24
|
-
|
25
|
-
aws-sdk-resources (= 2.11.212)
|
26
|
-
aws-sdk-core (2.11.212)
|
27
|
-
aws-sigv4 (~> 1.0)
|
28
|
-
jmespath (~> 1.0)
|
29
|
-
aws-sdk-resources (2.11.212)
|
30
|
-
aws-sdk-core (= 2.11.212)
|
31
|
-
aws-sigv4 (1.0.3)
|
32
|
-
azure_graph_rbac (0.17.0)
|
25
|
+
azure_graph_rbac (0.17.1)
|
33
26
|
ms_rest_azure (~> 0.11.0)
|
34
|
-
azure_mgmt_key_vault (0.17.
|
27
|
+
azure_mgmt_key_vault (0.17.4)
|
35
28
|
ms_rest_azure (~> 0.11.0)
|
36
|
-
azure_mgmt_resources (0.17.
|
29
|
+
azure_mgmt_resources (0.17.4)
|
37
30
|
ms_rest_azure (~> 0.11.0)
|
38
31
|
binding_of_caller (0.8.0)
|
39
32
|
debug_inspector (>= 0.0.1)
|
40
33
|
builder (3.2.3)
|
41
|
-
byebug (
|
42
|
-
chef (14.9
|
34
|
+
byebug (11.0.1)
|
35
|
+
chef (14.12.9)
|
43
36
|
addressable
|
44
37
|
bundler (>= 1.10)
|
45
|
-
chef-config (= 14.9
|
38
|
+
chef-config (= 14.12.9)
|
46
39
|
chef-zero (>= 13.0)
|
47
40
|
diff-lcs (~> 1.2, >= 1.2.4)
|
48
41
|
erubis (~> 2.7)
|
@@ -52,9 +45,9 @@ GEM
|
|
52
45
|
iniparse (~> 1.4)
|
53
46
|
mixlib-archive (>= 0.4, < 2.0)
|
54
47
|
mixlib-authentication (~> 2.1)
|
55
|
-
mixlib-cli (
|
56
|
-
mixlib-log (
|
57
|
-
mixlib-shellout (
|
48
|
+
mixlib-cli (>= 1.7, < 3.0)
|
49
|
+
mixlib-log (>= 2.0.3, < 4.0)
|
50
|
+
mixlib-shellout (>= 2.4, < 4.0)
|
58
51
|
net-sftp (~> 2.1, >= 2.1.2)
|
59
52
|
net-ssh (~> 4.2)
|
60
53
|
net-ssh-multi (~> 1.2, >= 1.2.1)
|
@@ -69,13 +62,13 @@ GEM
|
|
69
62
|
specinfra (~> 2.10)
|
70
63
|
syslog-logger (~> 1.6)
|
71
64
|
uuidtools (~> 2.1.5)
|
72
|
-
chef-config (14.9
|
65
|
+
chef-config (14.12.9)
|
73
66
|
addressable
|
74
67
|
fuzzyurl
|
75
|
-
mixlib-config (>= 2.2.12, <
|
76
|
-
mixlib-shellout (
|
68
|
+
mixlib-config (>= 2.2.12, < 4.0)
|
69
|
+
mixlib-shellout (>= 2.0, < 4.0)
|
77
70
|
tomlrb (~> 1.2)
|
78
|
-
chef-dk (3.
|
71
|
+
chef-dk (3.8.14)
|
79
72
|
addressable (>= 2.3.5, < 2.6)
|
80
73
|
chef (~> 14.0)
|
81
74
|
chef-provisioning (~> 2.0)
|
@@ -87,7 +80,7 @@ GEM
|
|
87
80
|
mixlib-shellout (~> 2.0)
|
88
81
|
paint (~> 1.0)
|
89
82
|
solve (> 2.0, < 5.0)
|
90
|
-
chef-provisioning (2.7.
|
83
|
+
chef-provisioning (2.7.6)
|
91
84
|
cheffish (>= 4.0, < 15.0)
|
92
85
|
inifile (>= 2.0.2)
|
93
86
|
mixlib-install (>= 1.0)
|
@@ -102,10 +95,10 @@ GEM
|
|
102
95
|
concurrent-ruby (~> 1.0)
|
103
96
|
ffi-yajl (~> 2.2)
|
104
97
|
http (~> 2.2)
|
105
|
-
chef-zero (14.0.
|
98
|
+
chef-zero (14.0.12)
|
106
99
|
ffi-yajl (~> 2.2)
|
107
100
|
hashie (>= 2.0, < 4.0)
|
108
|
-
mixlib-log (
|
101
|
+
mixlib-log (>= 2.0, < 4.0)
|
109
102
|
rack (~> 2.0, >= 2.0.6)
|
110
103
|
uuidtools (~> 2.1)
|
111
104
|
cheffish (14.0.4)
|
@@ -115,9 +108,9 @@ GEM
|
|
115
108
|
rubocop (= 0.62.0)
|
116
109
|
citrus (3.0.2)
|
117
110
|
coderay (1.1.2)
|
118
|
-
concurrent-ruby (1.1.
|
119
|
-
cookbook-omnifetch (0.8.
|
120
|
-
mixlib-archive (
|
111
|
+
concurrent-ruby (1.1.5)
|
112
|
+
cookbook-omnifetch (0.8.1)
|
113
|
+
mixlib-archive (>= 0.4, < 2.0)
|
121
114
|
debug_inspector (0.0.3)
|
122
115
|
declarative (0.0.10)
|
123
116
|
declarative-option (0.1.0)
|
@@ -130,7 +123,7 @@ GEM
|
|
130
123
|
unf (>= 0.0.5, < 1.0.0)
|
131
124
|
equatable (0.5.0)
|
132
125
|
erubis (2.7.0)
|
133
|
-
excon (0.
|
126
|
+
excon (0.64.0)
|
134
127
|
faraday (0.15.4)
|
135
128
|
multipart-post (>= 1.2, < 3)
|
136
129
|
faraday-cookie_jar (0.0.6)
|
@@ -155,7 +148,7 @@ GEM
|
|
155
148
|
multi_json (~> 1.11)
|
156
149
|
os (>= 0.9, < 2.0)
|
157
150
|
signet (~> 0.7)
|
158
|
-
gssapi (1.
|
151
|
+
gssapi (1.3.0)
|
159
152
|
ffi (>= 1.0.1)
|
160
153
|
gyoku (1.3.1)
|
161
154
|
builder (>= 2.1.2)
|
@@ -175,10 +168,14 @@ GEM
|
|
175
168
|
iniparse (1.4.4)
|
176
169
|
ipaddress (0.8.3)
|
177
170
|
jaro_winkler (1.5.2)
|
178
|
-
|
179
|
-
json (2.1.0)
|
171
|
+
json (2.2.0)
|
180
172
|
jwt (2.1.0)
|
181
173
|
libyajl2 (1.2.0)
|
174
|
+
license-acceptance (1.0.11)
|
175
|
+
pastel (~> 0.7)
|
176
|
+
tomlrb (~> 1.2)
|
177
|
+
tty-box (~> 0.3)
|
178
|
+
tty-prompt (~> 0.18)
|
182
179
|
little-plugger (1.1.4)
|
183
180
|
logging (2.2.2)
|
184
181
|
little-plugger (~> 1.1)
|
@@ -187,33 +184,35 @@ GEM
|
|
187
184
|
method_source (0.9.2)
|
188
185
|
mime-types (3.2.2)
|
189
186
|
mime-types-data (~> 3.2015)
|
190
|
-
mime-types-data (3.
|
187
|
+
mime-types-data (3.2019.0331)
|
191
188
|
minitar (0.8)
|
192
|
-
mixlib-archive (0.
|
189
|
+
mixlib-archive (1.0.1)
|
193
190
|
mixlib-log
|
194
191
|
mixlib-authentication (2.1.1)
|
195
192
|
mixlib-cli (1.7.0)
|
196
|
-
mixlib-config (
|
193
|
+
mixlib-config (3.0.1)
|
197
194
|
tomlrb
|
198
|
-
mixlib-install (3.11.
|
195
|
+
mixlib-install (3.11.18)
|
199
196
|
mixlib-shellout
|
200
197
|
mixlib-versioning
|
201
198
|
thor
|
202
|
-
mixlib-log (
|
199
|
+
mixlib-log (3.0.1)
|
203
200
|
mixlib-shellout (2.4.4)
|
204
201
|
mixlib-versioning (1.2.7)
|
205
202
|
molinillo (0.6.6)
|
206
|
-
ms_rest (0.7.
|
203
|
+
ms_rest (0.7.4)
|
207
204
|
concurrent-ruby (~> 1.0)
|
208
205
|
faraday (~> 0.9)
|
209
|
-
timeliness (~> 0.3)
|
210
|
-
ms_rest_azure (0.11.
|
206
|
+
timeliness (~> 0.3.10)
|
207
|
+
ms_rest_azure (0.11.1)
|
211
208
|
concurrent-ruby (~> 1.0)
|
212
209
|
faraday (~> 0.9)
|
213
210
|
faraday-cookie_jar (~> 0.0.6)
|
214
|
-
ms_rest (~> 0.7.
|
211
|
+
ms_rest (~> 0.7.4)
|
212
|
+
unf_ext (= 0.0.7.2)
|
215
213
|
multi_json (1.13.1)
|
216
|
-
multipart-post (2.
|
214
|
+
multipart-post (2.1.1)
|
215
|
+
necromancer (0.4.0)
|
217
216
|
net-scp (1.2.1)
|
218
217
|
net-ssh (>= 2.6.5)
|
219
218
|
net-sftp (2.1.2)
|
@@ -226,22 +225,22 @@ GEM
|
|
226
225
|
net-ssh-gateway (>= 1.2.0)
|
227
226
|
net-telnet (0.1.1)
|
228
227
|
nori (2.6.0)
|
229
|
-
ohai (14.8.
|
228
|
+
ohai (14.8.12)
|
230
229
|
chef-config (>= 12.8, < 15)
|
231
230
|
ffi (~> 1.9)
|
232
231
|
ffi-yajl (~> 2.2)
|
233
232
|
ipaddress
|
234
233
|
mixlib-cli (>= 1.7.0)
|
235
|
-
mixlib-config (
|
236
|
-
mixlib-log (
|
237
|
-
mixlib-shellout (
|
234
|
+
mixlib-config (>= 2.0, < 4.0)
|
235
|
+
mixlib-log (>= 2.0.1, < 4.0)
|
236
|
+
mixlib-shellout (>= 2.0, < 4.0)
|
238
237
|
plist (~> 3.1)
|
239
238
|
systemu (~> 2.6.4)
|
240
239
|
wmi-lite (~> 1.0)
|
241
|
-
os (1.0.
|
240
|
+
os (1.0.1)
|
242
241
|
paint (1.0.1)
|
243
|
-
parallel (1.
|
244
|
-
parser (2.6.
|
242
|
+
parallel (1.17.0)
|
243
|
+
parser (2.6.3.0)
|
245
244
|
ast (~> 2.4.0)
|
246
245
|
pastel (0.7.2)
|
247
246
|
equatable (~> 0.5.0)
|
@@ -252,8 +251,8 @@ GEM
|
|
252
251
|
pry (0.12.2)
|
253
252
|
coderay (~> 1.1.0)
|
254
253
|
method_source (~> 0.9.0)
|
255
|
-
pry-byebug (3.
|
256
|
-
byebug (~>
|
254
|
+
pry-byebug (3.7.0)
|
255
|
+
byebug (~> 11.0)
|
257
256
|
pry (~> 0.10)
|
258
257
|
pry-stack_explorer (0.4.9.3)
|
259
258
|
binding_of_caller (>= 0.7)
|
@@ -262,7 +261,7 @@ GEM
|
|
262
261
|
r18n-core (3.2.0)
|
263
262
|
r18n-desktop (3.2.0)
|
264
263
|
r18n-core (= 3.2.0)
|
265
|
-
rack (2.0.
|
264
|
+
rack (2.0.7)
|
266
265
|
rainbow (3.0.0)
|
267
266
|
rake (12.3.2)
|
268
267
|
representable (3.0.4)
|
@@ -276,10 +275,10 @@ GEM
|
|
276
275
|
rspec-mocks (~> 3.8.0)
|
277
276
|
rspec-core (3.8.0)
|
278
277
|
rspec-support (~> 3.8.0)
|
279
|
-
rspec-expectations (3.8.
|
278
|
+
rspec-expectations (3.8.3)
|
280
279
|
diff-lcs (>= 1.2.0, < 2.0)
|
281
280
|
rspec-support (~> 3.8.0)
|
282
|
-
rspec-its (1.
|
281
|
+
rspec-its (1.3.0)
|
283
282
|
rspec-core (>= 3.0.0)
|
284
283
|
rspec-expectations (>= 3.0.0)
|
285
284
|
rspec-mocks (3.8.0)
|
@@ -320,20 +319,25 @@ GEM
|
|
320
319
|
solve (4.0.2)
|
321
320
|
molinillo (~> 0.6)
|
322
321
|
semverse (>= 1.1, < 4.0)
|
323
|
-
specinfra (2.
|
322
|
+
specinfra (2.77.2)
|
324
323
|
net-scp
|
325
324
|
net-ssh (>= 2.7)
|
326
325
|
net-telnet (= 0.1.1)
|
327
326
|
sfl
|
327
|
+
strings (0.1.4)
|
328
|
+
strings-ansi (~> 0.1.0)
|
329
|
+
unicode-display_width (~> 1.4.0)
|
330
|
+
unicode_utils (~> 1.4.0)
|
331
|
+
strings-ansi (0.1.0)
|
328
332
|
syslog-logger (1.6.8)
|
329
333
|
systemu (2.6.5)
|
330
334
|
thor (0.20.3)
|
331
|
-
timeliness (0.3.
|
335
|
+
timeliness (0.3.10)
|
336
|
+
timers (4.3.0)
|
332
337
|
toml-rb (1.1.2)
|
333
338
|
citrus (~> 3.0, > 3.0)
|
334
339
|
tomlrb (1.2.8)
|
335
|
-
train (1.
|
336
|
-
aws-sdk (~> 2)
|
340
|
+
train (2.1.2)
|
337
341
|
azure_graph_rbac (~> 0.16)
|
338
342
|
azure_mgmt_key_vault (~> 0.17)
|
339
343
|
azure_mgmt_resources (~> 0.15)
|
@@ -342,22 +346,38 @@ GEM
|
|
342
346
|
googleauth (~> 0.6.6)
|
343
347
|
inifile
|
344
348
|
json (>= 1.8, < 3.0)
|
345
|
-
mixlib-shellout (>= 2.0)
|
346
|
-
net-scp (
|
349
|
+
mixlib-shellout (>= 2.0, < 4.0)
|
350
|
+
net-scp (>= 1.2, < 3.0)
|
347
351
|
net-ssh (>= 2.9, < 6.0)
|
348
352
|
winrm (~> 2.0)
|
349
353
|
winrm-fs (~> 1.0)
|
354
|
+
tty-box (0.3.0)
|
355
|
+
pastel (~> 0.7.2)
|
356
|
+
strings (~> 0.1.4)
|
357
|
+
tty-cursor (~> 0.6.0)
|
350
358
|
tty-color (0.4.3)
|
351
|
-
tty-cursor (0.6.
|
359
|
+
tty-cursor (0.6.1)
|
360
|
+
tty-prompt (0.18.1)
|
361
|
+
necromancer (~> 0.4.0)
|
362
|
+
pastel (~> 0.7.0)
|
363
|
+
timers (~> 4.0)
|
364
|
+
tty-cursor (~> 0.6.0)
|
365
|
+
tty-reader (~> 0.5.0)
|
366
|
+
tty-reader (0.5.0)
|
367
|
+
tty-cursor (~> 0.6.0)
|
368
|
+
tty-screen (~> 0.6.4)
|
369
|
+
wisper (~> 2.0.0)
|
370
|
+
tty-screen (0.6.5)
|
352
371
|
tty-spinner (0.9.0)
|
353
372
|
tty-cursor (~> 0.6.0)
|
354
373
|
uber (0.1.0)
|
355
374
|
unf (0.1.4)
|
356
375
|
unf_ext
|
357
|
-
unf_ext (0.0.7.
|
376
|
+
unf_ext (0.0.7.2)
|
358
377
|
unicode-display_width (1.4.1)
|
378
|
+
unicode_utils (1.4.0)
|
359
379
|
uuidtools (2.1.5)
|
360
|
-
winrm (2.3.
|
380
|
+
winrm (2.3.2)
|
361
381
|
builder (>= 2.1.2)
|
362
382
|
erubis (~> 2.7)
|
363
383
|
gssapi (~> 1.2)
|
@@ -374,6 +394,7 @@ GEM
|
|
374
394
|
logging (>= 1.6.1, < 3.0)
|
375
395
|
rubyzip (~> 1.1)
|
376
396
|
winrm (~> 2.0)
|
397
|
+
wisper (2.0.0)
|
377
398
|
wmi-lite (1.0.2)
|
378
399
|
|
379
400
|
PLATFORMS
|
data/README.md
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
|
4
4
|
The ad-hoc execution tool for the Chef ecosystem.
|
5
5
|
|
6
|
+
**Umbrella Project**: [Workstation](https://github.com/chef/chef-oss-practices/blob/master/projects/chef-workstation.md)
|
7
|
+
|
8
|
+
* **[Project State](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md):** Active
|
9
|
+
* **Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md):** 14 days
|
10
|
+
* **Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md):** 14 days
|
11
|
+
|
6
12
|
## Installation
|
7
13
|
|
8
14
|
Add this line to your application's Gemfile:
|
data/chef-apply.gemspec
CHANGED
@@ -54,6 +54,7 @@ Gem::Specification.new do |spec|
|
|
54
54
|
spec.add_dependency "chef", ">= 14.0" # Needed to load cookbooks
|
55
55
|
spec.add_dependency "chef-dk", ">= 3.0"
|
56
56
|
spec.add_dependency "chef-telemetry"
|
57
|
+
spec.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.11"
|
57
58
|
|
58
59
|
spec.add_development_dependency "bundler"
|
59
60
|
spec.add_development_dependency "rake"
|
data/i18n/errors/en.yml
CHANGED
@@ -58,6 +58,14 @@ errors:
|
|
58
58
|
display: { stack: true, log: true }
|
59
59
|
text: An unknown error has occurred.
|
60
60
|
|
61
|
+
# Failure to accept the chef license
|
62
|
+
CHEFLIC001:
|
63
|
+
display: { log: true, stack: true }
|
64
|
+
text: |
|
65
|
+
You must accept the Chef Infra Client license locally in order
|
66
|
+
to manage a remote host. Accepting the license locally will pass
|
67
|
+
through the acceptance to the remote host.
|
68
|
+
|
61
69
|
# Installer action errors
|
62
70
|
CHEFINS002:
|
63
71
|
text: |
|
@@ -114,18 +122,11 @@ errors:
|
|
114
122
|
text: |
|
115
123
|
Could not determine reason for converge failure.
|
116
124
|
|
117
|
-
STDOUT (may be blank)
|
118
|
-
|
119
|
-
%1
|
120
|
-
|
121
|
-
STDERR (may be blank)
|
122
|
-
|
123
|
-
%2
|
124
|
-
|
125
125
|
An error occurred while converging the remote host.
|
126
126
|
I was unable to retrieve the log file which would allow
|
127
|
-
me to provide more information.
|
128
|
-
|
127
|
+
me to provide more information. Here's where I looked:
|
128
|
+
|
129
|
+
%1
|
129
130
|
|
130
131
|
CHEFCCR002:
|
131
132
|
text: |
|
@@ -38,77 +38,6 @@ module ChefApply
|
|
38
38
|
@config = c
|
39
39
|
end
|
40
40
|
|
41
|
-
run_report = "$env:APPDATA/chef-workstation/cache/run-report.json"
|
42
|
-
PATH_MAPPING = {
|
43
|
-
chef_client: {
|
44
|
-
windows: "cmd /c C:/opscode/chef/bin/chef-client",
|
45
|
-
other: "/opt/chef/bin/chef-client",
|
46
|
-
},
|
47
|
-
cache_path: {
|
48
|
-
windows: '#{ENV[\'APPDATA\']}/chef-workstation',
|
49
|
-
other: "/var/chef-workstation",
|
50
|
-
},
|
51
|
-
read_chef_report: {
|
52
|
-
windows: "type #{run_report}",
|
53
|
-
other: "cat /var/chef-workstation/cache/run-report.json",
|
54
|
-
},
|
55
|
-
delete_chef_report: {
|
56
|
-
windows: "If (Test-Path #{run_report}){ Remove-Item -Force -Path #{run_report} }",
|
57
|
-
other: "rm -f /var/chef-workstation/cache/run-report.json",
|
58
|
-
},
|
59
|
-
tempdir: {
|
60
|
-
windows: "%TEMP%",
|
61
|
-
other: "$TMPDIR",
|
62
|
-
},
|
63
|
-
delete_folder: {
|
64
|
-
windows: "Remove-Item -Recurse -Force –Path",
|
65
|
-
other: "rm -rf",
|
66
|
-
},
|
67
|
-
}.freeze
|
68
|
-
|
69
|
-
# TODO - I'd like to consider PATH_MAPPING in action::base
|
70
|
-
# to platform subclasses/mixins for target_host. This way our 'target host'
|
71
|
-
# which reprsents a node, the data and actions we can perform on it
|
72
|
-
# knows how to `read_chef_report`, `mkdir`, etc.
|
73
|
-
# -mp 2018-10-17
|
74
|
-
|
75
|
-
PATH_MAPPING.keys.each do |m|
|
76
|
-
define_method(m) { PATH_MAPPING[m][family] }
|
77
|
-
end
|
78
|
-
|
79
|
-
# Chef will try 'downloading' the policy from the internet unless we pass it a valid, local file
|
80
|
-
# in the working directory. By pointing it at a local file it will just copy it instead of trying
|
81
|
-
# to download it.
|
82
|
-
#
|
83
|
-
# Chef 13 on Linux requires full path specifiers for --config and --recipe-url while on Chef 13 and 14 on
|
84
|
-
# Windows must use relative specifiers to prevent URI from causing an error
|
85
|
-
# (https://github.com/chef/chef/pull/7223/files).
|
86
|
-
def run_chef(working_dir, config_file, policy)
|
87
|
-
case family
|
88
|
-
when :windows
|
89
|
-
"Set-Location -Path #{working_dir}; " +
|
90
|
-
# We must 'wait' for chef-client to finish before changing directories and Out-Null does that
|
91
|
-
"chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)} | Out-Null; " +
|
92
|
-
# We have to leave working dir so we don't hold a lock on it, which allows us to delete this tempdir later
|
93
|
-
"Set-Location C:/; " +
|
94
|
-
"exit $LASTEXITCODE"
|
95
|
-
else
|
96
|
-
# cd is shell a builtin, so much call bash. This also means all commands are executed
|
97
|
-
# with sudo (as long as we are hardcoding our sudo use)
|
98
|
-
"bash -c 'cd #{working_dir}; chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)}'"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# Trying to perform File or Pathname operations on a Windows path with '\'
|
103
|
-
# characters in it fails. So lets convert them to '/' which these libraries
|
104
|
-
# handle better.
|
105
|
-
def escape_windows_path(p)
|
106
|
-
if family == :windows
|
107
|
-
p = p.tr("\\", "/")
|
108
|
-
end
|
109
|
-
p
|
110
|
-
end
|
111
|
-
|
112
41
|
def run(&block)
|
113
42
|
@notification_handler = block
|
114
43
|
Telemeter.timed_action_capture(self) do
|
@@ -139,19 +68,6 @@ module ChefApply
|
|
139
68
|
ChefApply::Log.debug("[#{self.class.name}] Action: #{action}, Action Data: #{args}")
|
140
69
|
@notification_handler.call(action, args) if @notification_handler
|
141
70
|
end
|
142
|
-
|
143
|
-
private
|
144
|
-
|
145
|
-
def family
|
146
|
-
@family ||= begin
|
147
|
-
f = target_host.platform.family
|
148
|
-
if f == "windows"
|
149
|
-
:windows
|
150
|
-
else
|
151
|
-
:other
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
71
|
end
|
156
72
|
end
|
157
73
|
end
|