In my last post, AirPrint Generator, I noted that one of the potential issues with programmatically installing AirPrinters is that the client computer needs to be able to actively communicate with the printer at the time of installation. This quickly came up in discussion on the MacAdmins Slack.
As I outlined there, we can work around this by generating the AirPrint PPDs and Icons, packaging them up and deploying them to the client computers ahead of time.
This method presents several advantages, read on for the details.
There are several advantages to taking this approach:
- The standard PrinterGenerator print_generator.py script can be used. This avoids the extra preinstall_script logic from AirPrint_Generator.py that is needed to programmatically generate the AirPrint PPDs on the fly. This in turn reduces the complexity of the installation process.
- The printer installation, via Munki, will complete even if the computer can’t route to the printer at that time. This is because the needed AirPrint PPD will already be on disk.
- It allows us to get rich icons in System Preferences even if installation happens without a user logged in, such as managed installs or lab situations.
Generating the PPD and Icon
There are a couple ways the PPDs and Icons can be created manually.
The first is to just install the AirPrinter in System Preferences and then grab the resulting PPD from /etc/cups/ppd/ and Icon from /Library/Printers/Icons/.
Alternatively you can utilize the same ipp2ppd tool mentioned my my last post to generate them from the command line:
/System/Library/Printers/Libraries/ipp2ppd ipp://184.108.40.206 everywhere > /Users/Shared/PRINTERNAME.ppd
The resulting PPD file will be in /Users/Shared/, or wherever you direct the output, and the icon will be in /Library/Printers/Icons/.
NOTE: Before deciding which method to use, generate the PPDs using both methods and compare the output. I created them using the following four different methods and while some printers produced identical results, others did not.
- Command line ipp2ppd tool
- System Preferences, default bonjour browser, AirPrint driver
- System Preferences, default bonjour browser, Secure AirPrint driver
- System Preferences, manually specifying an IP, AirPrint driver
For example, on one printer, the *APScannerModulePath: pointed to “/Library/Image Capture/Devices/HP Scanner 3.app” with System Preferences AirPrint, but to “/System/Library/Image Capture/Devices/AirScanScanner.app” with System Preferences Secure AirPrint, manual IP specification and the command line ipp2pdd tool.
Creating the Package
If you are new to packaging I highly recommend Armin Briegel’s book, Packaging for Apple Administrators. The method below is the one Armin teaches in the book, but you could also use munkipkg or the Whitebox Packages application.
You’ll want to deploy the Icons into the same /Library/Printers/Icons/ directory you retrieved them from, and I suggest deploying the PPDs into /Library/Printers/PPDs/Contents/Resources/. This is the same directory all third party PPDs are installed into and the directory that the original PrinterGenerator looks in by default.
I named my PPDs using the same name I supply for the printer in the CSV file. This ensures I won’t ever mix up a legacy PPD supplied by the vendor and the one I created for AirPrint. My package project directory structure looks like this before building:
Deploying the package
Once you’ve built the package and tested that it works, import it into your Munki repo. To ensure it gets installed before the printers that need it you’ll want to set the package as a requires item in the printers’ pkginfo. This is no different than when installing printers with legacy PPDs and PrinterGenerator.
The small size should deploy easily even to remote workers.
When using the regular print_generator.py with this method make sure your CSV file is filled out correctly:
- Address must include ipp://
- Driver must be the exact name you created and deployed in previous steps, e.g. Tech_HP_M477dfw.ppd
- Requires must include the PPD/Icon package you imported into Munki. You would specify the name field from that package’s pkginfo file e.g. AirPrintDrivers
- If you want this to be an update for your existing installs make sure you don’t change the printer names and remember to bump the version number.
If you have any suggestions, thoughts or questions please reach out, leave a comment or join us in the #printers-n-cups channel on the the MacAdmins Slack for more discussion.
Pingback: Scripting OS X — Weekly News Summary for Admins — 2020-12-11 – Scripting OS X