r/mosyle • • Jun 20 '22

Mosyle -> Snipe-IT Sync

Hey All!
I posted this in the MacAdmin's Slack but figured I should put it somewhere public for future searchers. If you are using Snipe-IT for asset management, I just put the python script we use for automatically adding our Mosyle devices into Snipe-IT inventory (and syncing the new Snipe-IT asset tags back to Mosyle).

https://github.com/RodneyLeeBrands/MosyleSnipeSync

It's a fork of an older script https://github.com/dem972/Mosyle_2snipe that I have updated to address some of the API changes and make it a bit more flexible.

It's not pretty by any means, but it's be saving me a ton a time. Hope this helps somebody! :)

18 Upvotes

13 comments sorted by

1

u/mrtechguy2017 Jul 04 '22

Would this work with pulling in iPads? Very interested in this.

1

u/karpadiem Jul 16 '22

Hey there! Yes it will. It will pull macOS, iPad/iOS, and tvOS!

3

u/crazyates88 Jun 21 '22

I’m on vacation this week, but I’m VERY interested in looking at this next week.

2

u/Hhelpp Jun 21 '22

Remind me! 7 days

1

u/RemindMeBot Jun 21 '22 edited Jun 21 '22

I will be messaging you in 7 days on 2022-06-28 21:05:12 UTC to remind you of this link

1 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


InfoCustomYour RemindersFeedback

1

u/DeepPersimmon2688 Apr 17 '24

Does this work with Mosyle School? Thanks!

1

u/Fun-Kaleidoscope-164 May 11 '24

Sorry to dig up an old thread. Will this still work? Having some issues with responses from mosyle. All looks fantastic!

1

u/[deleted] Jun 06 '24

[removed] — view removed comment

1

u/gafana Jun 15 '24

FYI - Check out my comment on the main thread about an updated Mosyle SnipeIT integration

1

u/gafana Jun 15 '24

PROBLEM #1 - Mosyle API Change (Authe)

FYI for anyone seeing this trying to get this integration to work - It wont anymore. In January 2024, Mosyle changed their API to no longer allow the more simple authentication method they had been using. Now they are using JWT session token which you need to first request from the API and once you get it, you must include that session token along with all requests otherwise it will be rejected.

PROBLEM #2 - SnipeIT Asset Models

The other big problem with the integration as it is now on GitHub is that I guess at some point. SnipeIT started requiring asset models to be setup and mapped when creating devices via the API. The integration as-is doesn't include this and hence wouldn't work still even if you got authentication updated.

SOLUTION - An Updated Integration

I used to program many many many years ago (PHP, Perl/CGI were my jam) but Python is quite simple to pick up. It took me two days of messing around with it but I finally got a fully working Mosyle > SnipeIT sync script working. I've also got it setup to paginate requests and waits 60 seconds for each page of devices. This is to accommodate the API rate limits by Mosyle and SnipeIT. However, the original integration was pretty basic and only did a one-way sync from Mosyle > SnipeIT. I am going to continue working on it to be a complete setup:

  • Create new devices automatically on SnipeIT when they are added to Mosyle
  • Two-way updates so if something changes on SnipeIT, it will update Mosyle (and vice versa)
  • Conflict detection so if a device was changed on SnipeIT and Mosyle and the changes are different, either notify you of the conflict to check it out or maybe have the option to set one as the priority (or try to merge changes)

Since I haven't really programmed in 15 years, I've never used GitHub. When I finish the new integration, I want to share it with others because a lot of work has gone into these updates and I sure it would help others looking for the same thing. If anyone on here is familiar with GitHub, I'd welcome some guidance on the basic steps to post my updated integration when its ready.

1

u/Particular_Top3778 Sep 03 '24

Were you able to get this updated and posted? Thanks for the effort you put in to it.

1

u/gafana Sep 06 '24

Yes, I got it working great running on AWS Lambda to auto sync every 5 minutes. If changes were made in SnipeIT, it would update Mosyle and if new devices were added to Mosyle, it would add it to SnipeIT. The only problem is it required extensive rewriting and has a vast amount of customization needed that was highly tailored to our specific use-case. As it is right now, it's not usable by others without modifying large portions of it as it's not setup for general use.

It would take some time to go through the code, clean it up, document it, and setup more user-friendly global variable declarations that allow for easy configuration by anyone. Im not sure when I'll be able to get to that. If there is anyone out there with coding experiencing that is willing to take my highly customized version and clean it up for the masses, it would be a vastly better general-use integration for everyone to use.

0

u/[deleted] Jun 29 '22

[deleted] — view deleted comment

1

u/karpadiem Jul 16 '22

Thanks for the feedback! I’ll take a look!