Condition Scripts for Munki

If you've been using Munki for a while, you probably already know about conditional items that allow you add items to optional installs, managed installs, etc. based on a condition like whether the client is a laptop or a desktop, or whether the client is running 10.10 or 10.11.

But you can also create your own admin-provided conditions.

If you write your own script, it should go in /usr/local/munki/conditions on the client machines. At the end of the script, your script should write to the /Library/Managed Installs/ConditionalItems.plist file. For bash scripts, that would be just using a defaults write command. For Python scripts, you would want to read the existing .plist keys/values, and then write back with your additions.

If you want to test your script, put in a condition you know to be true and then run

sudo /usr/local/munki/managedsoftwareupdate -vvv
on a test client. You should see, for that relevant item, that the condition evaluated to true. Then try again for a false condition.

Don't panic if you write your script, run Munki or Managed Software Center, and see the ConditionalItems.plist file appear in /Library/Managed Installs and then disappear very quickly afterwards. That's normal behavior.

Tim Sutton has a collection of Munki condition scripts. I also wrote one that checks ping time back to the Munki server.

Leave a Reply

Your email address will not be published. Required fields are marked *