promoter – a python project for replicating a jss via the api
TRANSCRIPT
promoterA Python module for migrating
objects between JSSs
A bit of backstory• A topic came in from the internal all.tech@ list:
“promote everything from a test environment to prod”
• Discussion was focused on migrating or promoting a policy from test/staging to prod
• It was agreed that it was better done manually
• I took the idea and starting looking into scripting
The original idea:
• Migrate a policy from one JSS to another
• Policies are complex JSS objects
• To ‘promote’ a policy you need to fulfill its dependencies first
• Parse through the XML, find these dependencies and migrate them one-by-one before finally posting the policy
The holdup?
• The 8.x series REST API lacked support for some of the objects that would be in a policy (e.g. scripts)
• A shell script wasn’t the right means to accomplish this…
• …I didn’t know Python
So, here comes v9…
• Didn’t do much work on promoter
• A PSE found out about it from a Developer…
• The first version of promoter written over the weekend
Some good stuff
• The first Python project I ever wrote
• Decent command line interface
• Standard library only
• Multi-platform
In hindsight, it was ugly
• Monolithic script
• All function and no class
• Written as a stand-alone utility
• Well recieved, but other priorities took up my time
Coming back to promoter
• JAMF’s Production JSS is hosted
• No direct database access
• How do I replicate my production environment as closely as possible?
• Hey, I think I wrote something that handled a similar idea once…
A JSS to JSS replication in 14 seconds(at 25000% speed…)
The new version
• Ditched utility concept, now a module
• A few core functions using a lightweight JSS REST API wrapper
• ‘Manifests’ are used to manipulate the XML into the desired state
Manifest?• A dictionary that defines actions to take on the
XML of an object
• ‘exclude’ will remove elements
• ‘override’ will replace the value for an element with a new one
• ‘inject’ will create an element with a value at the provided path in the XML
• ‘collections’ is the path to a collection in the XML where the ID elements need to be removed
{ objectName: { 'exclude': [ Element/Path1, Element/Path2 ], 'override': { Element/Path1: NewValue, Element/Path2: NewValue }, 'inject': { NewElement/Path1: Value, NewElement/Path2: Value }, 'collections': [ Element/Path1, Element/Path2, ] } }
So where is it?• Not quite ready for primetime
• Supports migrating whole resources, but not individual objects and does not handle dependencies (being worked on)
• Adding in some more advanced features to address some shortcomings (borrowing the concept of Autopkg’s Processors)
• It will be available in GitHub (remains to be seen if on my profile or the JAMF IT Open Source project)
Thank You!Maybe some brief Q&A?