Skip to content

Instantly share code, notes, and snippets.

View cchurch's full-sized avatar
🤖
I'm not a robot.

Chris Church cchurch

🤖
I'm not a robot.
View GitHub Profile
@cchurch
cchurch / ping_on_windows.yml
Created July 25, 2015 16:49
Proof of concept to run Python ping module on Windows with Ansible
---
- hosts: windows
gather_facts: false
vars:
ansible_python_interpreter: python
tasks:
- win_chocolatey:
name: python2
state: present
@cchurch
cchurch / ratelimit.py
Created August 5, 2015 15:03
Ansible callback plugin example for rate limiting tasks
# Python
import time
class CallbackModule(object):
'''
Delay after Rackspace DNS API requests to avoid rate limit (20/minute).
'''
def _rate_limit(self):
role_name = getattr(getattr(self, 'task', None), 'role_name', '')
@cchurch
cchurch / github_pipeline.py
Created November 12, 2015 20:39
Custom Python social auth pipeline functions to fetch a GitHub user's orgs # and teams.
# Custom Python social auth pipeline functions to fetch a GitHub user's orgs
# and teams.
def fetch_github_user_orgs(backend, details, user=None, *args, **kwargs):
if not user or not hasattr(backend, 'get_json'):
return
response = kwargs.get('response') or {}
if 'organizations_url' not in response or 'access_token' not in response:
return
orgs = backend.get_json(response['organizations_url'],
@cchurch
cchurch / xmlsec_fix.py
Last active August 10, 2016 20:53
Quick fix for xmlsec initialize issue (copy into /etc/tower/conf.d/). Related to https://github.com/onelogin/python-saml/pull/149
import threading
xmlsec_init_lock = threading.Lock()
xmlsec_initialized = False
import dm.xmlsec.binding
original_xmlsec_initialize = dm.xmlsec.binding.initialize
def xmlsec_initialize(*args, **kwargs):
global xmlsec_init_lock, xmlsec_initialized, original_xmlsec_initialize
with xmlsec_init_lock:
@cchurch
cchurch / timeout.py
Created November 16, 2016 22:05
Timeout class - initialize with a duration, evaluates as boolean True until timeout has expired.
# Python
import time
__all__ = ['Timeout']
class Timeout(object):
def __init__(self, duration=None):
# If initializing from another instance, create a new timeout from the
@cchurch
cchurch / ansible-inventory
Last active March 30, 2017 19:43
Standalone ansible-inventory script based on https://github.com/bcoca/ansible/blob/a689d6a54bcaff2e686c95f0933a9b3519e9c209/lib/ansible/cli/inventory.py (variables defined under group_vars are not listed separately but still included in host variables)
#!/usr/bin/env python
# (c) 2017, Brian Coca <bcoca@ansible.com>
#
# 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
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,

Keybase proof

I hereby claim:

  • I am cchurch on github.
  • I am flyingfred0 (https://keybase.io/flyingfred0) on keybase.
  • I have a public key ASBNH4qEsFwxMks88hGONV4ujTBGyV2t6vPGRVpY0NHhRgo

To claim this, I am signing this object: