Skip to content

Instantly share code, notes, and snippets.

View ryancurrah's full-sized avatar

Ryan Currah ryancurrah

  • Toronto, Ontario
View GitHub Profile
@ryancurrah
ryancurrah / tcp_returner.py
Created December 10, 2015 05:15
SaltStack State Event TCP Returner Module
# -*- coding: utf-8 -*-
'''
Returns state event data for state.sls and state.highstate execution only using a tcp socket, this method of
returning data can be used for Splunk or ELK.
Each event sent represents a single state executed.
It is strongly recommended to use the ``event_return_whitelist`` so not all
events call this returner, for example:
@ryancurrah
ryancurrah / kc.cfg
Created November 1, 2015 23:58
kc.cfg
# We want to "install"
install
cdrom
# Set the language
lang en_US.UTF-8
keyboard us
@ryancurrah
ryancurrah / Set-DatetimeFromNtp.ps1
Created October 7, 2015 20:01
Set-DatetimeFromNtp
$Server = $args[0]
$StartOfEpoch=New-Object DateTime(1900,1,1,0,0,0,[DateTimeKind]::Utc)
[Byte[]]$NtpData = ,0 * 48
$NtpData[0] = 0x1B # NTP Request header in first byte
$Socket = New-Object Net.Sockets.Socket([Net.Sockets.AddressFamily]::InterNetwork,
[Net.Sockets.SocketType]::Dgram,
[Net.Sockets.ProtocolType]::Udp)
$Socket.Connect($Server,123)
@ryancurrah
ryancurrah / New-StartupTask.ps1
Last active November 5, 2015 03:21
schedule windows startup task using powershell
$execute = $args[0]
$argmuent = $args[1]
$working_directory = $args[2]
$task_name = $args[3]
$description = $args[4]
$get_task = Get-ScheduledTask $task_name -ErrorAction SilentlyContinue
if ($get_task) {
Write-Output "changed=no comment='Task name already exists, task not added.'"
}
@ryancurrah
ryancurrah / salt-target-hosts.py
Created October 1, 2015 20:18
salt-target-hosts
from subprocess import Popen, PIPE
from argparse import ArgumentParser
from pprint import pprint
import logging
import sys
import salt.client
import json
logging.basicConfig(stream=sys.stdout,
@ryancurrah
ryancurrah / sensu-event-report.py
Last active September 25, 2015 02:54
sensu-event-report
__author__ = 'ryan currah'
import requests
from argparse import ArgumentParser
import csv
import logging
logging.basicConfig(filename=__file__.replace('.py', '.log'),
format='%(asctime)s %(levelname)s: %(message)s',
level=logging.DEBUG)
@ryancurrah
ryancurrah / check-salt-conf.py
Last active September 16, 2015 16:58
Check Salt Configuration
import ast
from salt.config import minion_config, master_config
from argparse import ArgumentParser
from common.sensu import Sensu
sensu = Sensu()
def main():
"""
@ryancurrah
ryancurrah / check-salt-minion-keys-threshold.py
Last active September 8, 2015 22:18
Check Salt Minion Keys Threshold
from os import listdir
from os.path import isfile
from argparse import ArgumentParser
from common.sensu import Sensu
from common.proc import Proc
sensu = Sensu()
def main():
@ryancurrah
ryancurrah / check-salt-master.py
Last active September 8, 2015 22:14
Sensu Check Salt Master (test.ping)
import salt.client
from salt.config import apply_minion_config
from argparse import ArgumentParser
from common.sensu import Sensu
sensu = Sensu()
def main():
"""
@ryancurrah
ryancurrah / add-user-to-tenants.py
Last active September 7, 2015 15:17
OpenStack Add User to Multiple Tenants
import getpass
import logging
from keystoneclient.v2_0 import client
from keystoneclient import utils
from keystoneclient.openstack.common.apiclient import exceptions
from argparse import ArgumentParser
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO)