Instantly share code, notes, and snippets.

Kris Payne krispayne

  • Tulsa, OK
View GitHub Profile
View profile-preinstall-check
#!/bin/bash
# preflight to check for profile installed by Jamf
profile_id="SAMPLE-SAMPLE-SAMPLE-SAMPLE"
# Get logged in user
loggedInUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
#loggedInUID=$(id -u "$loggedInUser")
# First, see if the profile is there
View freeipa.py
#!/usr/bin/env python
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This script can create an Ansible Dynamic Inventory with either:
# - the FreeIPA API over HTTPS with the `python_freeipa` module
# - using kerberos authentication with the `ipalib` and `ipaclient` module
#
# DEPENDENCIES: before this script will work the python_freeipa or ipalib module has to be installed
#
# For Ansible AWX or Tower add this to your Docker image
@krispayne
krispayne / ovirt4.py
Last active Sep 27, 2018
changed around line 115 to get credentials from awx custom credential. taken and modified from: https://github.com/ansible/ansible/blob/devel/contrib/inventory/ovirt4.py
View ovirt4.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
View awx custom credential notes
for freeipa source credential:
input config (yaml)
fields:
- type: string
id: fipahttps
label: HTTPS
default: True
- type: string
id: fipaserver
@krispayne
krispayne / jss-inventory.py
Last active Jul 12, 2018
trying to make a useable jss to ansible inventory based off groups of last reported ip's from the jss api.
View jss-inventory.py
#!/usr/bin/python
"""
JSS + Ansible inventory
A dictionary of lists of computers by group name.
Heavily influenced by https://gist.github.com/BadStreff/0af3f881de162182eaaff406ce7a7f0d
with help from https://gist.github.com/chilcote/fb670103b8e90aaea67dee0ffc6cc983
I'd really like to avoid caching, as any sort of timeout won't be appropriate since I
View gist:abbbc6e18b5f71e53ffa5c2d39231388
#!/usr/bin/python
import sys, os
import urllib, urllib2
import base64
import json
import requests
import xml.etree.ElementTree as ET
def requests_xml(jss_user, jss_pass, jss_url, category):
@krispayne
krispayne / update-patch.sh
Last active May 9, 2018
wrapper to update a patch definition with patchstarter.py from brysontyrell
View update-patch.sh
#!/bin/bash
# update a patch
PATCHSTARTER="/usr/local/sbin/patchstarter"
echo -n "Enter an app name: "
read -e APP_NAME
echo -n "Enter a Publisher name (blank to match App Name): "
read -e PUBLISHER_NAME
@krispayne
krispayne / freeipa.md
Created Mar 27, 2018 — forked from devynspencer/freeipa.md
FreeIPA api notes
View freeipa.md
[devyn@ipa ~]$ ipa help commands
automember-add                         Add an automember rule.
automember-add-condition               Add conditions to an automember rule.
automember-default-group-remove        Remove default (fallback) group for all unmatched entries.
automember-default-group-set           Set default (fallback) group for all unmatched entries.
automember-default-group-show          Display information about the default (fallback) automember groups.
automember-del                         Delete an automember rule.
automember-find                        Search for automember rules.
automember-mod                         Modify an automember rule.
@krispayne
krispayne / freeipa.py
Created Mar 22, 2018 — forked from devynspencer/freeipa.py
Use FreeIPA hostgroups as a dynamic inventory source for Ansible. Badass.
View freeipa.py
#!/usr/bin/env python
import argparse
import json
from ipalib import api
def initialize():
'''
This function initializes the FreeIPA/IPA API. This function requires
View ea-appversion.py
#!/usr/bin/env python
"""
Check version of app installed using CFBundleVersion
"""
import os
import CoreFoundation
app = "Utilities/cocoaDialog.app" # Assumes '/Applications/App.app'