Skip to content

Instantly share code, notes, and snippets.

@hemebond
hemebond / sync_with_playlist.py
Last active April 15, 2019 21:29
Synchronise a directory with an .M3U playlist
#!/usr/bin/env python3
import os
import subprocess
import shutil
from time import time
import argparse
import codecs
import unicodedata
from tempfile import gettempdir
@hemebond
hemebond / check_updates.ps1
Created March 2, 2015 10:27
PowerShell script checks for available updates and returns the result in the standard monitoring plugin output format.
$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$Result = $Searcher.Search("IsInstalled = 0 and IsHidden = 0")
$Updates = $Result.Updates
$Total = $Updates.Count
$Critical = @($Updates | Where-Object {$_.MsrcSeverity -eq 'Important' -or $_.MsrcSeverity -eq 'Critical'}).Count
if ($Critical -gt 0) {
$CheckResult = 'CRITICAL'
#!/usr/bin/python3
#
# Save Flash videos on Linux when using Mozilla Firefox
#
# When watching Flash videos in Mozilla Firefox using the Adobe Flash player a
# temporary but "deleted" file is created. This file can still be accessed and
# copied somewhere else. This script will find all the temporary video files
# and save them to the current directory.
#
#! /bin/bash
#
# Original at http://hempeldesigngroup.com/embedded/stories/debian-squeeze-pxe-netboot-for-virtualbox/
#
# -----------------------------------------------------------------------------
# makePxeInstaller.sh - Make a netbootable directory that has all the IDE
# and sata drivers needed for a VirtualBox install
#
# Works in the current directory
# -----------------------------------------------------------------------------
@hemebond
hemebond / yamlloader.py
Last active March 13, 2016 10:42
Additional method on the SaltYamlSafeLoader class in yamlloader.py to fix YAML merging
class SaltYamlSafeLoader(yaml.SafeLoader, object):
def flatten_mapping(self, node):
merge = []
index = 0
while index < len(node.value):
key_node, value_node = node.value[index]
if key_node.tag == u'tag:yaml.org,2002:merge':
del node.value[index]
if isinstance(value_node, MappingNode):
@hemebond
hemebond / output
Created July 21, 2016 09:22
Pillar Interpolation Results
mem01.xen.local:
----------
sample1:
127.0.0.1/24/Contact me at
sample2:
127.0.0.1/24/Contact me at example.com
sample3:
127.0.0.1/24/Contact me at example.com 127.0.0.1
sample4:
${sample5} 24
@hemebond
hemebond / 0_article.md
Last active March 13, 2022 11:51
A SaltStack AWS Auto Scaling Solution

A SaltStack AWS Auto Scaling Solution

Overview

The AWS Auto Scaling Goup, configured with a customised Cloud-Init file, sends a notification to an SNS Topic, which in turn passes it onto an SQS queue that the Salt Master is subscribed to. A Reactor watches for the auto scaling events and pre-approves the new minion based on its Auto Scaling group name and instance ID.

Salt Master Configuration

@hemebond
hemebond / awspsv.py
Last active March 24, 2019 20:31
A passive AWS EC2 wrapper for the salt-cloud profile function
#!/usr/bin/env python
# 2019-03-22 Updated to be compatible with Salt 2018.3.3
# Import python libs
import logging
import os.path
import time
import boto3
@hemebond
hemebond / etc_salt_master.d_reactor.conf
Last active January 11, 2017 12:09
Sync grains every start and highstate once automatically.
reactors:
# Run this script every time an abc instance starts
- 'salt/minion/abc*/start':
- '/srv/salt/reactors/abc/start.sls'
# Run this script every time an abc instance returns from a job
- 'salt/job/*/ret/abc*':
- '/srv/salt/reactors/abc/ret.sls'
@hemebond
hemebond / __init__.py
Last active March 24, 2017 03:38
NSCA Saltstack Returner
'''
Return data to an NSCA server
This returner requires the following individual files
from the https://github.com/Yelp/send_nsca repo
* send_nsca/nagios.py
* send_nsca/nsca.py
Place those files, and this `__init__.py` file into your
state returners directory, e.g.: