A lovingly updated munki-enroll
.
A set of scripts to automatically enroll clients in Munki, allowing for a very flexible manifest structure.
This version is a deeply modified rewrite of the original, Copyright (c) 2012 Cody Eding, to suit my (and hopefully your) needs . See below and LICENSE file for licensing details.
Before you even think about using any Munki Enroll, or anything like these projects, please read An opinionated guide to Munki manifests and Another opinionated guide to Munki manifests first.
I just needed something a bit cleaner with some error checking and recovery. I also wanted something to turn run as a conditional item so it would/could/can/does update the display_name of the record when it's changed. Just a preference for my environments.
Like aysiu/munki-serial-enroll and grahampugh/munki-enroll, peetinc/munki-enroll focuses on a one manifest per client workflow. See above for more reading, but unlike aysiu/munki-serial-enroll, this project uses TECLIB/CFPropertyList], it may be a bit long in tooth, but it profides an infinitely more flexibly fremwork for creating and updating manifests.
Munki Enroll requires PHP to be working on the webserver hosting your Munki repository. As well as www write access to manifests
.
Copy the "munki-enroll" folder to the root of your Munki repository (the same directory as pkgs, pkginfo, manifests and catalogs).
Make sure your www user can write to manifests
and munki-enroll/logs/
Define the following in enroll.php
:
$defaultmanifest = 'Default/Manifest';
$defaultcatalog = 'production';
The included munki-enroll.sh
or munki-enrollONLY.sh
scripts needs a couple variables set:
REPO_URL="https://munki.domain/repo"
ENROLL_URL="$REPO_URL/munki-enroll/enroll.php"
UPDATE_URL="$REPO_URL/munki-enroll/update.php"
PORT=443
ENROLL_PLIST=domain.munki.munki-enroll (if staging a /private/var/root/Library/Preferences/$ENROLL_PLIST.plist)
RUNFILE=/usr/local/munki/.runfile (only if using munki-enrollONLY.sh)
RUNLIMIT=10 (only if using munki-enrollONLY.sh)
Optionally you can add these as well:
CATALOG1=(This will be set for you in `enroll.php`)
CATALOG2=
CATALOG2=
MANIFEST1=(This will be set for you in `enroll.php`)
MANIFEST2=
MANIFEST3=
MANIFEST4=
If munki-enroll.sh
runs anywhere but from /usr/munki/conditions
it will copy itself into /usr/munki/conditions
to keep your computers enrolled/display_name up-to-date.
If munki-enrollONLY.sh
fails to contact your SUBMITURL
on PORT
, it moves itself into /usr/munki/conditions
and runs as any other Conditional Items. If it successfully creates a manifest or finds that there's a manifest with its RECORDNAME
(defaulted to computer serial number) it deletes itself from /usr/munki/conditions
.
Currently theres a bit of error checking both server-side in enroll.php
and in munki-enroll.sh
:
enroll.php
won't let an existing record be overwritten.enroll.php
won't run withoutRECORDNAME
,DISPLAYNAME
andUUID
.munki-enroll.sh
will drop into/usr/munki/conditions
if it runs from anywhere but/usr/munki/conditions
and run as a Conditional Item with managedsoftwareupdate.munki-enrollONLY.sh
will drop into/usr/munki/conditions
if it fails to contact yourSUBMITURL
onPORT
and will run as a Conditional Item with managedsoftwareupdate.- Theres a
RUNLIMIT
formunki-enrollONLY.sh
when running from/usr/munki/conditions
as well. If exceeded, themunki-enroll.sh
gives up and self destructs.
Some niceties and expectations:
update.php
validates requests with theUUID
of the computer. It currently only updatesdisplay_name
.enroll.php
has a logging facility that logs to/munki-enroll/log/munki-enroll.log
just in case there are some rouge requests out thereenroll.php
as a few exit codes:0
successful creation of a new manifest1
not enough arguments9
manifest exists
enroll.php
can accept up to four included manifests. Simply provideCATALOG1
,CATALOG2
and/orCATALOG3
as well asMANIFEST1
,MANIFEST2
,MANIFEST3
and/orMANIFEST4
variables in the script.CATALOG1
andMANIFEST1
defaults are built intoenroll.php
munki-enroll.sh
andmunki-enrollONLY.sh
will readCATALOG1
,CATALOG2
and/orCATALOG3
as well asMANIFEST1
,MANIFEST2
,MANIFEST3
and/orMANIFEST4
from/private/var/root/Library/Preferences/$ENROLLPLIST.plist
munki-enroll.sh
andmunki-enrollONLY.sh
must be run as root.munki-enroll.sh
andmunki-enrollONLY.sh
pushes the computerUUID
toenroll.php
which drops it into anotes
anduuid
strings.munki-enroll.sh
andmunki-enrollONLY.sh
pullsAdditionalHttpHeaders
fromManagedInstalls
with the expectation that your repo is protected by HTTP Basic Authentication. If you are limiting access toenroll.php
without Basic Authentication, simply remove-u "$AUTH" \
from the curl statements.
Munki Enroll, like the contained CFPropertyList project, is published under the MIT License.