Jamf Nation Community
community.jamf.com user-id
Solved: Hey, I am looking ideas to use Python to accomplish various tasks with Jamf. I am not sure where to get started or how powerful - 148248
https://community.jamf.com/html/@341C36E148083396DBCB6E6A9C18E572/assets/favicon.ico
Jamf Nation
I started digging into Python about a year ago and thus far anything I can do in BASH I can do in Python. In my limited experience modules work just fine depending on the module of course. I have a large clustered Linux environment so I wrote a tool in Python that allows me to run commands against all of the nodes in a loop. This helps with stopping, rebooting, or restarting Tomcat for upgrades etc. I would recommend picking a problem or project that you would normally solve with BASH and figure out how to do it in Python.

This list is slightly out of date, but is a still a very good list of Mac/Apple admin tools built with Python. https://github.com/timsutton/python-macadmin-tools

Some of the best known are Munki, AutoPkg, dockutil, and outset. There are a ton of others.

Python also gives you access to PyObjC which extends your scripting possibilities even further if you're interested in experimenting with Apple frameworks. Something like this - https://github.com/gregneagle/macaduk2017

Bash is still great and useful in many situations. You'll notice though that most open source Apple management projects aren't written in it. Instead they prefer Python, Ruby, Swift, etc. Guess I can't provide a definitive answer as to why, but in my opinion it's because those languages handle data processing much better than bash and have built in functions/modules for common tasks. Things like text manipulation, reading/writing JSON, looping over lists, etc. are just way easier.

Think ultimately it's good to use the tool that works for your situation. If bash is that tool then go for it.

Hi @kdean

We are working on two tools, "python-jamf" and "jctl" and we will be presenting on them at JNUC 2021.

Presentation will be named "Turn 1000 Clicks into 1 with python-jamf and jctl"

`python-jamf` is a library for connecting to a Jamf Server that maps directly to the Jamf Pro Classic API. It is the basis for the `jctl` tool to automate patch management & packages and many other items. We are actively developing the tools and provides automation and performing tasks quickly on your Jamf Pro server.

Here are the GitHub repositories, if you are interested in checking them out...

python-jamf

https://github.com/univ-of-utah-marriott-library-apple/python-jamf

jctl

https://github.com/univ-of-utah-marriott-library-apple/jctl

We have a channel in MacAdmin's slack if you have any questions or need help with setup and usage:

jctl