xolo-server 1.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +42 -4
- data/bin/xoloserver +3 -0
- data/data/client/xolo +1233 -0
- data/lib/optimist_with_insert_blanks.rb +1216 -0
- data/lib/xolo/core/base_classes/configuration.rb +238 -0
- data/lib/xolo/core/base_classes/server_object.rb +112 -0
- data/lib/xolo/core/base_classes/title.rb +884 -0
- data/lib/xolo/core/base_classes/version.rb +641 -0
- data/lib/xolo/core/constants.rb +85 -0
- data/lib/xolo/core/exceptions.rb +52 -0
- data/lib/xolo/core/json_wrappers.rb +43 -0
- data/lib/xolo/core/loading.rb +59 -0
- data/lib/xolo/core/output.rb +292 -0
- data/lib/xolo/core/security_cmd.rb +128 -0
- data/lib/xolo/core/version.rb +21 -0
- data/lib/xolo/core.rb +47 -0
- data/lib/xolo/server/app.rb +7 -0
- data/lib/xolo/server/configuration.rb +243 -38
- data/lib/xolo/server/constants.rb +10 -0
- data/lib/xolo/server/helpers/auth.rb +19 -2
- data/lib/xolo/server/helpers/autopkg.rb +157 -0
- data/lib/xolo/server/helpers/client_data.rb +90 -60
- data/lib/xolo/server/helpers/file_transfers.rb +412 -82
- data/lib/xolo/server/helpers/jamf_pro.rb +31 -7
- data/lib/xolo/server/helpers/log.rb +2 -0
- data/lib/xolo/server/helpers/maintenance.rb +1 -0
- data/lib/xolo/server/helpers/notification.rb +4 -3
- data/lib/xolo/server/helpers/pkg_signing.rb +16 -12
- data/lib/xolo/server/helpers/progress_streaming.rb +9 -12
- data/lib/xolo/server/helpers/subscriptions.rb +119 -0
- data/lib/xolo/server/helpers/titles.rb +27 -3
- data/lib/xolo/server/helpers/versions.rb +23 -11
- data/lib/xolo/server/mixins/changelog.rb +9 -16
- data/lib/xolo/server/mixins/title_jamf_access.rb +375 -390
- data/lib/xolo/server/mixins/title_ted_access.rb +50 -8
- data/lib/xolo/server/mixins/version_jamf_access.rb +118 -129
- data/lib/xolo/server/mixins/version_ted_access.rb +34 -4
- data/lib/xolo/server/object_locks.rb +2 -1
- data/lib/xolo/server/routes/auth.rb +2 -2
- data/lib/xolo/server/routes/jamf_pro.rb +11 -1
- data/lib/xolo/server/routes/maint.rb +2 -1
- data/lib/xolo/server/routes/subscriptions.rb +126 -0
- data/lib/xolo/server/routes/title_editor.rb +1 -1
- data/lib/xolo/server/routes/titles.rb +26 -11
- data/lib/xolo/server/routes/uploads.rb +0 -14
- data/lib/xolo/server/routes/versions.rb +14 -13
- data/lib/xolo/server/routes.rb +15 -23
- data/lib/xolo/server/title.rb +100 -77
- data/lib/xolo/server/version.rb +178 -18
- data/lib/xolo/server.rb +8 -0
- metadata +20 -11
|
@@ -65,6 +65,11 @@ module Xolo
|
|
|
65
65
|
# @return [Windoo::SoftwareTitle]
|
|
66
66
|
##########################
|
|
67
67
|
def create_title_in_ted
|
|
68
|
+
if subscribed?
|
|
69
|
+
log_debug "Title Editor: SoftwareTitle '#{title}' is subscribed, skipping Title Editor creation"
|
|
70
|
+
return
|
|
71
|
+
end
|
|
72
|
+
|
|
68
73
|
# delete an old one if its there
|
|
69
74
|
ted_title&.delete if Windoo::SoftwareTitle.all_ids(cnx: ted_cnx).include? title
|
|
70
75
|
|
|
@@ -86,8 +91,10 @@ module Xolo
|
|
|
86
91
|
sleep 2
|
|
87
92
|
|
|
88
93
|
# re-fetch the title from ted and enable it
|
|
94
|
+
progress "Title Editor: Enabling SoftwareTitle '#{title}'", log: :info
|
|
89
95
|
ted_title(refresh: true).enable
|
|
90
96
|
|
|
97
|
+
# cache the new title object id
|
|
91
98
|
self.ted_id_number = ted_title.softwareTitleId
|
|
92
99
|
end
|
|
93
100
|
|
|
@@ -171,6 +178,10 @@ module Xolo
|
|
|
171
178
|
# @return [void]
|
|
172
179
|
##########################
|
|
173
180
|
def update_title_in_ted
|
|
181
|
+
if subscribed?
|
|
182
|
+
log_debug "Title Editor: SoftwareTitle '#{title}' is subscribed, skipping Title Editor update"
|
|
183
|
+
return
|
|
184
|
+
end
|
|
174
185
|
return unless changes_for_update
|
|
175
186
|
|
|
176
187
|
unless any_ted_changes?
|
|
@@ -197,6 +208,9 @@ module Xolo
|
|
|
197
208
|
# This will also apply the changes to all patch component criteria
|
|
198
209
|
apply_requirement_changes
|
|
199
210
|
|
|
211
|
+
# re-enable all patches, after any change, which might have disabled them
|
|
212
|
+
reenable_all_ted_patches
|
|
213
|
+
|
|
200
214
|
# mucking with the patches often disables the title, make sure its enabled.
|
|
201
215
|
enable_ted_title
|
|
202
216
|
|
|
@@ -212,10 +226,12 @@ module Xolo
|
|
|
212
226
|
req_change = requirement_change
|
|
213
227
|
return unless req_change
|
|
214
228
|
|
|
215
|
-
new_app_name = changes_for_update.dig :app_name, :new
|
|
216
|
-
new_app_bundle_id = changes_for_update.dig :app_bundle_id, :new
|
|
217
229
|
new_ea_script = changes_for_update.dig :version_script, :new
|
|
218
230
|
|
|
231
|
+
# if either of these are nil in changes, then use the existing value
|
|
232
|
+
new_app_name = changes_for_update.dig(:app_name, :new) || app_name
|
|
233
|
+
new_app_bundle_id = changes_for_update.dig(:app_bundle_id, :new) || app_bundle_id
|
|
234
|
+
|
|
219
235
|
case req_change
|
|
220
236
|
when :app_to_ea
|
|
221
237
|
# create the ea
|
|
@@ -236,6 +252,7 @@ module Xolo
|
|
|
236
252
|
when :update_app
|
|
237
253
|
# set the requirement to use the new app data
|
|
238
254
|
set_ted_title_requirement app_name: new_app_name, app_bundle_id: new_app_bundle_id
|
|
255
|
+
|
|
239
256
|
# for all versions, update the patch compotent criteria to use the new app data
|
|
240
257
|
set_ted_patch_component_criteria_after_update app_name: new_app_name, app_bundle_id: new_app_bundle_id
|
|
241
258
|
|
|
@@ -287,11 +304,19 @@ module Xolo
|
|
|
287
304
|
end
|
|
288
305
|
end
|
|
289
306
|
|
|
307
|
+
# In the TitleEditor, the version script is
|
|
308
|
+
# stored as an Extension Attribute - each title can
|
|
309
|
+
# only have one.
|
|
310
|
+
# and it needs a 'key', which is the name used to indicate the
|
|
311
|
+
# EA in various criteria, and is the EA name in Jamf Patch.
|
|
312
|
+
# The key is jamf_obj_name_pfx on the title
|
|
313
|
+
# so for title 'foobar', it is 'xolo-foobar' or 'xolotest-foobar' for test servers
|
|
314
|
+
# That value is also used as the display name
|
|
290
315
|
# @return [String] The key and display name of a version script stored
|
|
291
316
|
# in the title editor as the ExtAttr for this title
|
|
292
317
|
#####################
|
|
293
318
|
def ted_ea_key
|
|
294
|
-
@ted_ea_key ||=
|
|
319
|
+
@ted_ea_key ||= "#{jamf_obj_name_pfx_base}#{title}"
|
|
295
320
|
end
|
|
296
321
|
|
|
297
322
|
# Create the EA in the Title Editor
|
|
@@ -416,6 +441,8 @@ module Xolo
|
|
|
416
441
|
#
|
|
417
442
|
# Re-enable the title in ted after updating any patches
|
|
418
443
|
#
|
|
444
|
+
# TODO: Now that we are using stub patches, do we need the loop?
|
|
445
|
+
#
|
|
419
446
|
# @return [void]
|
|
420
447
|
##############################
|
|
421
448
|
def enable_ted_title
|
|
@@ -430,10 +457,10 @@ module Xolo
|
|
|
430
457
|
loop do
|
|
431
458
|
raise Xolo::TimeoutError, "Title Editor: Timed out waiting for SoftwareTitle '#{title}' to enable" if Time.now > breaktime
|
|
432
459
|
|
|
433
|
-
sleep 5
|
|
434
460
|
ted_title(refresh: true).enable
|
|
435
461
|
break
|
|
436
462
|
rescue Windoo::MissingDataError => e
|
|
463
|
+
sleep 5
|
|
437
464
|
log_debug "Title Editor: Looping up to #{Xolo::Server::Constants::MAX_JAMF_WAIT_FOR_TITLE_EDITOR} secs while re-enabling SoftwareTitle '#{title}': #{e}"
|
|
438
465
|
|
|
439
466
|
# make sure all patches are enabled, even tho at least one should have been
|
|
@@ -463,6 +490,8 @@ module Xolo
|
|
|
463
490
|
# @return [String] the URL for the title in the Title Editor
|
|
464
491
|
#####################
|
|
465
492
|
def ted_title_url
|
|
493
|
+
return unless managed?
|
|
494
|
+
|
|
466
495
|
"https://#{Xolo::Server.config.ted_hostname}/softwaretitles/#{ted_id_number}"
|
|
467
496
|
end
|
|
468
497
|
|
|
@@ -475,6 +504,10 @@ module Xolo
|
|
|
475
504
|
# @return [void]
|
|
476
505
|
############################
|
|
477
506
|
def repair_ted_title
|
|
507
|
+
if subscribed?
|
|
508
|
+
log_debug "Title Editor: SoftwareTitle '#{title}' is subscribed, skipping Title Editor repair"
|
|
509
|
+
return
|
|
510
|
+
end
|
|
478
511
|
progress "Title Editor: Repairing SoftwareTitle '#{title}'", log: :info
|
|
479
512
|
|
|
480
513
|
# TODO: version order??
|
|
@@ -500,16 +533,25 @@ module Xolo
|
|
|
500
533
|
if ted_title.patches.empty?
|
|
501
534
|
create_and_enable_stub_patch_in_ted(ted_title)
|
|
502
535
|
else
|
|
503
|
-
#
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
536
|
+
# repair all patches, because reparing the title might have changed the requirements
|
|
537
|
+
progress "Title Editor: Re-enabling all patches for '#{title}'", log: :info
|
|
538
|
+
version_objects.each do |vobj|
|
|
539
|
+
vobj.repair_ted_patch
|
|
507
540
|
end
|
|
508
541
|
end
|
|
509
542
|
|
|
510
543
|
ted_title.enable unless ted_title(refresh: true).enabled?
|
|
511
544
|
end
|
|
512
545
|
|
|
546
|
+
# Re-enable all patches in the title editor
|
|
547
|
+
# @return [void]
|
|
548
|
+
###########################
|
|
549
|
+
def reenable_all_ted_patches
|
|
550
|
+
# re-enable all patches, after any change, which might have disabled them
|
|
551
|
+
progress "Title Editor: Re-enabling all patches for '#{title}'", log: :info
|
|
552
|
+
version_objects.each { |vobj| vobj.enable_ted_patch }
|
|
553
|
+
end
|
|
554
|
+
|
|
513
555
|
end # TitleEditorTitle
|
|
514
556
|
|
|
515
557
|
end # Mixins
|
|
@@ -26,29 +26,24 @@ module Xolo
|
|
|
26
26
|
|
|
27
27
|
# The group of macs with this version installed
|
|
28
28
|
# is named the full prefix plus this suffix.
|
|
29
|
-
JAMF_SMART_GROUP_NAME_INSTALLED_SFX = '
|
|
29
|
+
JAMF_SMART_GROUP_NAME_INSTALLED_SFX = 'installed'
|
|
30
30
|
|
|
31
31
|
# The policy that does initial installs on-demand
|
|
32
32
|
# (via 'xolo install <title> <version') is named the full
|
|
33
33
|
# prefix plus this suffix.
|
|
34
|
-
JAMF_POLICY_NAME_MANUAL_INSTALL_SFX = '
|
|
34
|
+
JAMF_POLICY_NAME_MANUAL_INSTALL_SFX = 'manual-install'
|
|
35
35
|
|
|
36
36
|
# The policy that does auto-installs is named the full
|
|
37
37
|
# prefix plus this suffix.
|
|
38
38
|
# The scope is changed as needed when a version's status
|
|
39
39
|
# changes
|
|
40
|
-
JAMF_POLICY_NAME_AUTO_INSTALL_SFX = '
|
|
40
|
+
JAMF_POLICY_NAME_AUTO_INSTALL_SFX = 'auto-install'
|
|
41
41
|
|
|
42
42
|
# The policy that does auto-re-installs is named the full
|
|
43
43
|
# prefix plus this suffix.
|
|
44
44
|
# The scope is changed as needed when a version's status
|
|
45
45
|
# changes
|
|
46
|
-
JAMF_POLICY_NAME_AUTO_REINSTALL_SFX = '
|
|
47
|
-
|
|
48
|
-
# How long to wait after a pkg re-upload before creating/enabling/flushing
|
|
49
|
-
# the auto-reinstall policy
|
|
50
|
-
# See TODO in #wait_to_enable_reinstall_policy
|
|
51
|
-
JAMF_AUTO_REINSTALL_WAIT_SECS = 15 * 60
|
|
46
|
+
JAMF_POLICY_NAME_AUTO_REINSTALL_SFX = 'auto-reinstall'
|
|
52
47
|
|
|
53
48
|
# POLICIES, PATCH POLICIES, SCOPING
|
|
54
49
|
#############################
|
|
@@ -197,7 +192,11 @@ module Xolo
|
|
|
197
192
|
jamf_auto_install_policy
|
|
198
193
|
jamf_manual_install_policy
|
|
199
194
|
|
|
200
|
-
|
|
195
|
+
if subscribed?
|
|
196
|
+
activate_subscribed_patch_version_in_jamf
|
|
197
|
+
else
|
|
198
|
+
activate_managed_patch_version_in_jamf
|
|
199
|
+
end
|
|
201
200
|
end
|
|
202
201
|
|
|
203
202
|
# Apply edits to the Xolo version to Jamf as needed
|
|
@@ -276,8 +275,6 @@ module Xolo
|
|
|
276
275
|
# Delete package object
|
|
277
276
|
# This is slow and it blocks, so do it in a thread and update progress every
|
|
278
277
|
# 15 secs
|
|
279
|
-
return unless Jamf::JPackage.valid_id packageName: jamf_pkg_name, cnx: jamf_cnx
|
|
280
|
-
|
|
281
278
|
delete_jamf_package
|
|
282
279
|
|
|
283
280
|
# The code below is used when we want real-time progress updates to xadm
|
|
@@ -321,6 +318,8 @@ module Xolo
|
|
|
321
318
|
@jamf_package =
|
|
322
319
|
if id
|
|
323
320
|
log_debug "Jamf: Fetching Jamf::JPackage '#{id}'"
|
|
321
|
+
self.jamf_pkg_id = id # in case we only had the name before, now we have the id, so save it
|
|
322
|
+
save_local_data
|
|
324
323
|
Jamf::JPackage.fetch id: id, cnx: jamf_cnx
|
|
325
324
|
else
|
|
326
325
|
return if deleting?
|
|
@@ -329,10 +328,16 @@ module Xolo
|
|
|
329
328
|
end
|
|
330
329
|
end
|
|
331
330
|
|
|
331
|
+
# @return [Boolean] does the jamf_package exist?
|
|
332
|
+
#########################
|
|
333
|
+
def jamf_package_exist?
|
|
334
|
+
!Jamf::JPackage.valid_id(packageName: jamf_pkg_name, cnx: jamf_cnx).nil?
|
|
335
|
+
end
|
|
336
|
+
|
|
332
337
|
# @return [Jamf::JPackage] Create the Jamf::JPackage object for this version and return it
|
|
333
338
|
#########################
|
|
334
339
|
def create_jamf_package
|
|
335
|
-
progress "Jamf: Creating
|
|
340
|
+
progress "Jamf: Creating Jamf::JPackage '#{jamf_pkg_name}'", log: :info
|
|
336
341
|
|
|
337
342
|
# The filename is temporary, and will be replaced when the file is uploaded
|
|
338
343
|
pkg = Jamf::JPackage.create(
|
|
@@ -442,13 +447,13 @@ module Xolo
|
|
|
442
447
|
# @return [void]
|
|
443
448
|
#########################
|
|
444
449
|
def delete_jamf_package
|
|
445
|
-
pkg_id = Jamf::JPackage.valid_id
|
|
450
|
+
pkg_id = jamf_pkg_id || Jamf::JPackage.valid_id(packageName: jamf_pkg_name, cnx: jamf_cnx)
|
|
446
451
|
return unless pkg_id
|
|
447
452
|
|
|
448
453
|
msg = "Jamf: Starting deletion of Package '#{jamf_pkg_name}' id #{jamf_pkg_id} at #{Time.now.strftime '%F %T'}"
|
|
449
454
|
progress msg, log: :info
|
|
450
455
|
|
|
451
|
-
warning = +"IMPORTANT: Package deletion
|
|
456
|
+
warning = +"IMPORTANT: Package deletion can be slow. If you plan to re-add this version, '#{version}', please\n "
|
|
452
457
|
warning <<
|
|
453
458
|
if Xolo::Server.config.alert_tool
|
|
454
459
|
'check your Xolo alerts for completion, which can take up to 5 minutes,'
|
|
@@ -489,14 +494,18 @@ module Xolo
|
|
|
489
494
|
# @return [Jamf::Policy] The auto-install-policy for this version, if it exists
|
|
490
495
|
##########################
|
|
491
496
|
def jamf_auto_install_policy
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
Jamf::Policy.fetch(name: jamf_auto_install_policy_name, cnx: jamf_cnx)
|
|
495
|
-
else
|
|
496
|
-
return if deleting?
|
|
497
|
+
# This is imporant to avoid infinite recursion
|
|
498
|
+
return @jamf_auto_install_policy if @jamf_auto_install_policy
|
|
497
499
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
+
if jamf_auto_install_policy_exist?
|
|
501
|
+
@jamf_auto_install_policy = Jamf::Policy.fetch(name: jamf_auto_install_policy_name, cnx: jamf_cnx)
|
|
502
|
+
else
|
|
503
|
+
return if deleting?
|
|
504
|
+
|
|
505
|
+
# this sets @jamf_auto_install_policy
|
|
506
|
+
create_jamf_auto_install_policy
|
|
507
|
+
end
|
|
508
|
+
@jamf_auto_install_policy
|
|
500
509
|
end
|
|
501
510
|
|
|
502
511
|
# The auto install policy is triggered by checkin
|
|
@@ -505,32 +514,34 @@ module Xolo
|
|
|
505
514
|
# Before release, the targets are those defined in #pilot_groups_to_use
|
|
506
515
|
#
|
|
507
516
|
# After release, the targets are changed to those
|
|
508
|
-
# in title_object#
|
|
517
|
+
# in title_object#release_groups
|
|
509
518
|
#
|
|
510
519
|
# This policy is never in self service
|
|
511
520
|
# @return [Jamf::Policy] the auto install policy for this version
|
|
512
521
|
#########################
|
|
513
522
|
def create_jamf_auto_install_policy
|
|
514
523
|
progress "Jamf: Creating Auto Install Policy: #{jamf_auto_install_policy_name}", log: :debug
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
524
|
+
|
|
525
|
+
@jamf_auto_install_policy = Jamf::Policy.create name: jamf_auto_install_policy_name, cnx: jamf_cnx
|
|
526
|
+
|
|
527
|
+
configure_jamf_auto_install_policy
|
|
528
|
+
@jamf_auto_install_policy.save
|
|
519
529
|
end
|
|
520
530
|
|
|
521
531
|
# repair the auto-install policy only
|
|
522
532
|
#############################
|
|
523
533
|
def repair_jamf_auto_install_policy
|
|
524
534
|
progress "Jamf: Repairing Auto Install Policy '#{jamf_auto_install_policy_name}'", log: :info
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
pol.save
|
|
535
|
+
configure_jamf_auto_install_policy
|
|
536
|
+
jamf_auto_install_policy.save
|
|
528
537
|
end
|
|
529
538
|
|
|
530
539
|
# Configure the given policy as the auto-install policy for this version
|
|
531
540
|
# @param pol [Jamf::Policy] the policy to configure
|
|
532
541
|
################################
|
|
533
|
-
def configure_jamf_auto_install_policy(pol)
|
|
542
|
+
def configure_jamf_auto_install_policy(pol = nil)
|
|
543
|
+
pol ||= jamf_auto_install_policy
|
|
544
|
+
|
|
534
545
|
pol.category = Xolo::Server::JAMF_XOLO_CATEGORY
|
|
535
546
|
pol.set_trigger_event :checkin, true
|
|
536
547
|
pol.set_trigger_event :custom, Xolo::BLANK
|
|
@@ -553,7 +564,7 @@ module Xolo
|
|
|
553
564
|
end
|
|
554
565
|
|
|
555
566
|
# enable or disable based on status
|
|
556
|
-
if pilot? || released?
|
|
567
|
+
if pilot? || released? || releasing?
|
|
557
568
|
pol.enable
|
|
558
569
|
else
|
|
559
570
|
pol.disable
|
|
@@ -679,8 +690,6 @@ module Xolo
|
|
|
679
690
|
)
|
|
680
691
|
else
|
|
681
692
|
return if deleting?
|
|
682
|
-
# don't create unless there's been a re-upload of the pkg
|
|
683
|
-
return unless reupload_date
|
|
684
693
|
|
|
685
694
|
create_jamf_installed_group
|
|
686
695
|
end
|
|
@@ -730,51 +739,20 @@ module Xolo
|
|
|
730
739
|
# The criteria for the smart group in Jamf that contains all Macs
|
|
731
740
|
# with this version of this title installed
|
|
732
741
|
#
|
|
733
|
-
#
|
|
734
|
-
#
|
|
742
|
+
# We use the "Patch Reporting: #{title_object.display_name}" criterion so that we don't
|
|
743
|
+
# care whether the title uses a version-script or app data.
|
|
735
744
|
#
|
|
736
745
|
# @return [Array<Jamf::Criteriable::Criterion>]
|
|
737
746
|
###################################
|
|
738
747
|
def jamf_installed_group_criteria
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
),
|
|
748
|
-
|
|
749
|
-
Jamf::Criteriable::Criterion.new(
|
|
750
|
-
and_or: :and,
|
|
751
|
-
name: 'Application Bundle ID',
|
|
752
|
-
search_type: 'is',
|
|
753
|
-
value: title_object.app_bundle_id
|
|
754
|
-
),
|
|
755
|
-
|
|
756
|
-
Jamf::Criteriable::Criterion.new(
|
|
757
|
-
and_or: :and,
|
|
758
|
-
name: 'Application Version',
|
|
759
|
-
search_type: 'is',
|
|
760
|
-
value: version
|
|
761
|
-
)
|
|
762
|
-
]
|
|
763
|
-
|
|
764
|
-
# if not, it must have a version script
|
|
765
|
-
elsif title_object.version_script
|
|
766
|
-
[
|
|
767
|
-
Jamf::Criteriable::Criterion.new(
|
|
768
|
-
and_or: :and,
|
|
769
|
-
name: title_object.jamf_normal_ea_name,
|
|
770
|
-
search_type: 'is',
|
|
771
|
-
value: version
|
|
772
|
-
)
|
|
773
|
-
]
|
|
774
|
-
|
|
775
|
-
else
|
|
776
|
-
raise Xolo::Core::Exceptions::InvalidDataError, "Title #{title} has neither a version_script nor a defined app bundle."
|
|
777
|
-
end
|
|
748
|
+
[
|
|
749
|
+
Jamf::Criteriable::Criterion.new(
|
|
750
|
+
and_or: :or,
|
|
751
|
+
name: "Patch Reporting: #{title_object.display_name}",
|
|
752
|
+
search_type: 'is',
|
|
753
|
+
value: version
|
|
754
|
+
)
|
|
755
|
+
]
|
|
778
756
|
end
|
|
779
757
|
|
|
780
758
|
#########################
|
|
@@ -794,7 +772,7 @@ module Xolo
|
|
|
794
772
|
# @return [Boolean] does the jamf_auto_reinstall_policy exist?
|
|
795
773
|
##########################
|
|
796
774
|
def jamf_auto_reinstall_policy_exist?
|
|
797
|
-
Jamf::Policy.all_names(cnx: jamf_cnx).include? jamf_auto_reinstall_policy_name
|
|
775
|
+
Jamf::Policy.all_names(:refresh, cnx: jamf_cnx).include? jamf_auto_reinstall_policy_name
|
|
798
776
|
end
|
|
799
777
|
|
|
800
778
|
# Create or fetch the auto re-install policy for this version
|
|
@@ -808,8 +786,6 @@ module Xolo
|
|
|
808
786
|
Jamf::Policy.fetch(name: jamf_auto_reinstall_policy_name, cnx: jamf_cnx)
|
|
809
787
|
else
|
|
810
788
|
return if deleting?
|
|
811
|
-
# don't create unless there's been a re-upload of the pkg
|
|
812
|
-
return unless reupload_date
|
|
813
789
|
|
|
814
790
|
create_jamf_auto_reinstall_policy
|
|
815
791
|
end
|
|
@@ -839,6 +815,9 @@ module Xolo
|
|
|
839
815
|
# @param pol [Jamf::Policy] the policy to configure
|
|
840
816
|
######################
|
|
841
817
|
def configure_jamf_auto_reinstall_policy(pol)
|
|
818
|
+
# this creates the installed group if it doesn't already exist
|
|
819
|
+
jamf_installed_group
|
|
820
|
+
|
|
842
821
|
pol.category = Xolo::Server::JAMF_XOLO_CATEGORY
|
|
843
822
|
pol.set_trigger_event :checkin, true
|
|
844
823
|
pol.set_trigger_event :custom, Xolo::BLANK
|
|
@@ -846,7 +825,7 @@ module Xolo
|
|
|
846
825
|
pol.recon = false
|
|
847
826
|
pol.retry_event = :checkin
|
|
848
827
|
pol.retry_attempts = 5
|
|
849
|
-
pol.scope.set_targets :computer_groups, [
|
|
828
|
+
pol.scope.set_targets :computer_groups, [jamf_installed_group.name]
|
|
850
829
|
|
|
851
830
|
# exclusions are for always
|
|
852
831
|
set_policy_exclusions pol
|
|
@@ -870,41 +849,6 @@ module Xolo
|
|
|
870
849
|
@jamf_auto_reinstall_policy_url = "#{jamf_gui_url}/policies.html?id=#{pol_id}&o=r"
|
|
871
850
|
end
|
|
872
851
|
|
|
873
|
-
# This will start a thread
|
|
874
|
-
# that will wait some period of time (to allow for pkg uploads
|
|
875
|
-
# to complete) before enabling and flushing the logs for the reinstall policy.
|
|
876
|
-
# This will make all macs with this version installed get it re-installed.
|
|
877
|
-
# @return [void]
|
|
878
|
-
def wait_to_enable_reinstall_policy
|
|
879
|
-
return if @enable_reinstall_policy_thread&.alive?
|
|
880
|
-
return unless reupload_date
|
|
881
|
-
|
|
882
|
-
# TODO: some setting to determine how long to wait?
|
|
883
|
-
# - If uploading via the Jamf API, we need to give it time
|
|
884
|
-
# to then upload the file to the cloud distribution point
|
|
885
|
-
# - If uploading via a custom tool, we need to give that
|
|
886
|
-
# tool time to re-upload to wherever it uploads to
|
|
887
|
-
# - May need to wait for other non-jamf/non-xolo processes
|
|
888
|
-
# to sync the package to other distribution points. This
|
|
889
|
-
# might be very site-specific.
|
|
890
|
-
|
|
891
|
-
# For now, we wait 15 minutes.
|
|
892
|
-
wait_time = JAMF_AUTO_REINSTALL_WAIT_SECS
|
|
893
|
-
|
|
894
|
-
@enable_reinstall_policy_thread = Thread.new do
|
|
895
|
-
log_debug "Jamf: Starting enable_reinstall_policy_thread: waiting #{wait_time} seconds before enabling reinstall policy for version #{version} of title #{title}"
|
|
896
|
-
sleep wait_time
|
|
897
|
-
|
|
898
|
-
log_debug "Jamf: enable_reinstall_policy_thread: enabling and flushing logs for reinstall policy for version #{version} of title #{title}"
|
|
899
|
-
|
|
900
|
-
pol = jamf_auto_reinstall_policy
|
|
901
|
-
pol.enable
|
|
902
|
-
pol.flush_logs
|
|
903
|
-
pol.save
|
|
904
|
-
end
|
|
905
|
-
@enable_reinstall_policy_thread.name = "enable_reinstall_policy_thread-#{title}-#{version}"
|
|
906
|
-
end
|
|
907
|
-
|
|
908
852
|
####### The Jamf Patch Policy
|
|
909
853
|
###########################################
|
|
910
854
|
###########################################
|
|
@@ -977,10 +921,10 @@ module Xolo
|
|
|
977
921
|
# a rollback is being done
|
|
978
922
|
ppol.allow_downgrade = false
|
|
979
923
|
|
|
980
|
-
# This should
|
|
924
|
+
# This should default to false, so that
|
|
981
925
|
# we don't accidentally downgrade non-xolo test installs,
|
|
982
926
|
# or server-pushed updates (like with commvault or cisco VPN)
|
|
983
|
-
ppol.patch_unknown = false
|
|
927
|
+
ppol.patch_unknown = patch_unknown ? true : false
|
|
984
928
|
|
|
985
929
|
ppol.enable
|
|
986
930
|
|
|
@@ -1000,10 +944,10 @@ module Xolo
|
|
|
1000
944
|
ppol.name = jamf_patch_policy_name
|
|
1001
945
|
ppol.target_version = version
|
|
1002
946
|
|
|
1003
|
-
# This should
|
|
947
|
+
# This should default tofalse, so that
|
|
1004
948
|
# we don't accidentally downgrade non-xolo test installs,
|
|
1005
949
|
# or server-pushed updates (like with commvault or cisco VPN)
|
|
1006
|
-
ppol.patch_unknown = false
|
|
950
|
+
ppol.patch_unknown = patch_unknown ? true : false
|
|
1007
951
|
|
|
1008
952
|
if pilot?
|
|
1009
953
|
set_policy_pilot_groups ppol
|
|
@@ -1290,7 +1234,14 @@ module Xolo
|
|
|
1290
1234
|
@jamf_patch_version = title_object.jamf_patch_title.versions[version]
|
|
1291
1235
|
return @jamf_patch_version if @jamf_patch_version
|
|
1292
1236
|
|
|
1293
|
-
|
|
1237
|
+
if repairing?
|
|
1238
|
+
# if we're repairing, and the version isn't visible in Jamf, then
|
|
1239
|
+
# jamf polled the title editor in the few moments it was disabled.
|
|
1240
|
+
# and jamf will see it again within 5 minutes.
|
|
1241
|
+
return nil
|
|
1242
|
+
end
|
|
1243
|
+
|
|
1244
|
+
# TODO: wait for it to appear when adding, or re-appear when repairing?
|
|
1294
1245
|
msg = "Jamf: Version '#{version}' of Title '#{title}' is not visible in Jamf. Is the Patch enabled in the Title Editor?"
|
|
1295
1246
|
log_error msg
|
|
1296
1247
|
raise Xolo::NoSuchItemError, msg
|
|
@@ -1304,7 +1255,7 @@ module Xolo
|
|
|
1304
1255
|
#
|
|
1305
1256
|
# @return [void]
|
|
1306
1257
|
#########################
|
|
1307
|
-
def
|
|
1258
|
+
def activate_managed_patch_version_in_jamf
|
|
1308
1259
|
# don't do this if there's already one running for this instance
|
|
1309
1260
|
if @activate_patch_version_thread&.alive?
|
|
1310
1261
|
log_debug "Jamf: activate_patch_version_thread already running. Caller: #{caller_locations.first}"
|
|
@@ -1336,13 +1287,7 @@ module Xolo
|
|
|
1336
1287
|
end
|
|
1337
1288
|
|
|
1338
1289
|
if did_it
|
|
1339
|
-
|
|
1340
|
-
# give jamf a moment to catch up and refresh the patch title
|
|
1341
|
-
# so we see the pkg has been assigned
|
|
1342
|
-
sleep 2
|
|
1343
|
-
title_object.jamf_patch_title(refresh: true)
|
|
1344
|
-
|
|
1345
|
-
create_jamf_patch_policy
|
|
1290
|
+
activate_patch_version_in_jamf
|
|
1346
1291
|
msg = "Jamf: Version '#{version}' of title '#{title}' is now visible in Jamf Pro. Package assigned and Patch policy created."
|
|
1347
1292
|
log_info msg, alert: true
|
|
1348
1293
|
else
|
|
@@ -1353,6 +1298,37 @@ module Xolo
|
|
|
1353
1298
|
@activate_patch_version_thread.name = "activate_patch_version_thread-#{title}-#{version}"
|
|
1354
1299
|
end
|
|
1355
1300
|
|
|
1301
|
+
# Patches for subscribed titles are already visible in Jamf Patch Management
|
|
1302
|
+
# So we just need to assign the pkg to the patch version, and create the patch policy.
|
|
1303
|
+
##########################
|
|
1304
|
+
def activate_subscribed_patch_version_in_jamf
|
|
1305
|
+
msg = "Jamf: Assigning package and creating patch policy for version '#{version}' of subscribed title '#{title}'"
|
|
1306
|
+
log_info msg
|
|
1307
|
+
activate_patch_version_in_jamf
|
|
1308
|
+
end
|
|
1309
|
+
|
|
1310
|
+
# Assign the package for this version to the Jamf::PatchTitle::Version in Jamf
|
|
1311
|
+
# and create the patch policy for this version.
|
|
1312
|
+
#
|
|
1313
|
+
# @return [void]
|
|
1314
|
+
##########################
|
|
1315
|
+
def activate_patch_version_in_jamf
|
|
1316
|
+
log_debug "Jamf: Activating patch version in Jamf for version '#{version}' of title '#{title}'"
|
|
1317
|
+
|
|
1318
|
+
# create the Jamf::JPackage object if needed
|
|
1319
|
+
jamf_package
|
|
1320
|
+
title_object.jamf_patch_title(refresh: true)
|
|
1321
|
+
sleep 3
|
|
1322
|
+
|
|
1323
|
+
assign_pkg_to_patch_in_jamf
|
|
1324
|
+
# give jamf a moment to catch up and refresh the patch title
|
|
1325
|
+
# so we see the pkg has been assigned
|
|
1326
|
+
sleep 2
|
|
1327
|
+
title_object.jamf_patch_title(refresh: true)
|
|
1328
|
+
|
|
1329
|
+
create_jamf_patch_policy
|
|
1330
|
+
end
|
|
1331
|
+
|
|
1356
1332
|
# Assign the Package to the Jamf::PatchTitle::Version for this Xolo version.
|
|
1357
1333
|
# This 'activates' the version in Jamf Patch, and must happen before
|
|
1358
1334
|
# patch policies can be created
|
|
@@ -1368,10 +1344,23 @@ module Xolo
|
|
|
1368
1344
|
# @return [void]
|
|
1369
1345
|
########################################
|
|
1370
1346
|
def assign_pkg_to_patch_in_jamf
|
|
1371
|
-
|
|
1347
|
+
patch_vers_obj = jamf_patch_version
|
|
1348
|
+
|
|
1349
|
+
if patch_vers_obj.nil? && repairing?
|
|
1350
|
+
msg = "Jamf: Cant re-assign package '#{jamf_pkg_name}' to patch version '#{version}' of title '#{title}' at this time. If there are problems with it, try 'repair' again later."
|
|
1351
|
+
progress msg, log: :info
|
|
1352
|
+
return
|
|
1353
|
+
end
|
|
1354
|
+
|
|
1355
|
+
progress "Jamf: Assigning package '#{jamf_pkg_name}' to patch version '#{version}' of title '#{title}'", log: :info
|
|
1356
|
+
|
|
1357
|
+
log_debug "Jamf: jamf_patch_version is: #{patch_vers_obj}"
|
|
1358
|
+
|
|
1359
|
+
patch_vers_obj.package = jamf_pkg_name
|
|
1360
|
+
log_debug "Jamf: jamf_patch_version after assignment is: #{patch_vers_obj}"
|
|
1372
1361
|
|
|
1373
|
-
jamf_patch_version.package = jamf_pkg_name
|
|
1374
1362
|
title_object.jamf_patch_title.save
|
|
1363
|
+
log_debug 'Jamf: Saved jamf_patch_title after assigning package to version.'
|
|
1375
1364
|
end
|
|
1376
1365
|
|
|
1377
1366
|
# Get the patch report for this version
|