Skip to content

Instantly share code, notes, and snippets.

View SEJeff's full-sized avatar

Jeff Schroeder SEJeff

View GitHub Profile
/etc/salt/minion:
file:
- managed
- owner: root
- group: root
- mode: 444
- source: salt://salt/files/salt-minion.config
- template: jinja
- context:
{% if grains['fqdn'] == 'clients.fatbox.ca' %}
{% macro postconf(key, value) -%}
postconf-{{ key }}:
cmd:
- run
- name:
- postconf -e {{ key }}='{{ value }}'
- unless: test "x$(postconf -h {{ key }} )" = 'x{{ value }}'
- require:
- pkg: postfix
@SEJeff
SEJeff / check_salt.py
Created March 27, 2012 04:08
nagios check to make sure the salt minion is available and responding to commands from @bastichelaar
#!/usr/bin/env python
import salt.cli.caller
import salt.config
import argparse
import sys
parser = argparse.ArgumentParser(description='Check if minions are online.')
parser.add_argument('hostname', help='The name of the minion to be checked')
args = parser.parse_args()
@SEJeff
SEJeff / djangomodule.py
Created March 28, 2012 21:46 — forked from fatbox/djangomodule.py
Load Django modules from within a Salt module
"""
This allows you to import Django modules into a Salt module
"""
import logging
import sys
import os
log = logging.getLogger(__name__)
@SEJeff
SEJeff / salt_mock.py
Created April 5, 2012 17:03 — forked from tgecho/salt_mock.py
Brainstormed mock for testing salt states and modules
class Mock(object):
def __init__(self):
history = []
unmet_expectations = []
def __call__(self, func, *args, **kwargs):
"""
Here we can grab a copy of the actual function/state and insert
the Mock object as __salt__ so the usual calls to
@SEJeff
SEJeff / which.py
Created May 2, 2012 14:35
Implementation of Unix's which command in python
def which(exe=None):
'''
Python clone of POSIX's /usr/bin/which
'''
if exe:
(path, name) = os.path.split(exe)
if os.access(exe, os.X_OK):
return exe
for path in os.environ.get('PATH').split(os.pathsep):
full_path = os.path.join(path, exe)
@SEJeff
SEJeff / state.yaml
Created May 11, 2012 21:54
states + context + templates from @herlo
/home/kojiadmin/.koji/config:
file.managed:
- source: salt://koji/files/config
- user: kojiadmin
- group: kojiadmin
- mode: 644
- makedirs: true
- template: jinja
- context:
kojiweb_url: "http://koji2.egavas.org/koji/"
@SEJeff
SEJeff / gist:2669205
Created May 12, 2012 21:30
Good example state that configures redis
/etc/redis/redis.conf:
file.managed:
- source: salt://redis/redis.conf
- user: redis
- group: redis
- mode: 644
- template: jinja
- require:
- file: /etc/redis
- cmd: 'make && make install'
@SEJeff
SEJeff / yaml_ordered_dict.py
Created May 21, 2012 23:28 — forked from enaeseth/yaml_ordered_dict.py
Load YAML mappings as ordered dictionaries
import yaml
import yaml.constructor
try:
# included in standard lib from Python 2.7
from collections import OrderedDict
except ImportError:
# try importing the backported drop-in replacement
# it's available on PyPI
from ordereddict import OrderedDict
@SEJeff
SEJeff / gist:2769055
Created May 22, 2012 13:29 — forked from kadel/gist:2768868
Salt watch statement and requires example
ganglia-monitor:
pkg:
- installed
service:
- running
# Since the service name is ganglia-monitor and the daemon binary is gmond
- sig: '^gmond'
- watch:
- file: /etc/ganglia/gmond.conf
- pkg: ganglia-monitor