promoter – a python project for replicating a jss via the api

13
promoter A Python module for migrating objects between JSSs

Upload: macbrained

Post on 11-Aug-2015

229 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Promoter – A Python Project for Replicating a JSS via the API

promoterA Python module for migrating

objects between JSSs

Page 2: Promoter – A Python Project for Replicating a JSS via the API

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

Page 3: Promoter – A Python Project for Replicating a JSS via the API

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

Page 4: Promoter – A Python Project for Replicating a JSS via the API

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

Page 5: Promoter – A Python Project for Replicating a JSS via the API

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

Page 6: Promoter – A Python Project for Replicating a JSS via the API

Some good stuff

• The first Python project I ever wrote

• Decent command line interface

• Standard library only

• Multi-platform

Page 7: Promoter – A Python Project for Replicating a JSS via the API

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

Page 8: Promoter – A Python Project for Replicating a JSS via the API

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…

Page 9: Promoter – A Python Project for Replicating a JSS via the API

A JSS to JSS replication in 14 seconds(at 25000% speed…)

Page 10: Promoter – A Python Project for Replicating a JSS via the API

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

Page 11: Promoter – A Python Project for Replicating a JSS via the API

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, ] } }

Page 12: Promoter – A Python Project for Replicating a JSS via the API

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)

Page 13: Promoter – A Python Project for Replicating a JSS via the API

Thank You!Maybe some brief Q&A?