Skip to content

Instantly share code, notes, and snippets.

@hemebond
hemebond / salt_api_examples.rst
Last active March 3, 2017 01:21
Saltstack API (netapi) Examples

rest_cherrypy

First authenticate against the API:

curl -si $HOST:$CHERRY_PORT/login' -H 'Accept: application/json' -H 'Content-type: application/json' -d "{"username": "$USER", "password": "$PASS", "eauth": "pam"}"

Request data from Salt Mine using the token given by the login:

curl -sS -i -H "Accept: application/json" -H "Content-type: application/json" -H "X-Auth-Token: $TOKEN" -d "[{"username": "$USER", "password": "$PASS", "eauth": "pam", "client": "runner", "fun": "mine.get", "tgt": "*", "kwargs": {"tgt": "db9svc*", "fun": "grains.items"}}]" $HOST:$CHERRY_PORT
@hemebond
hemebond / icinga2_return.py
Last active July 1, 2017 05:28
Saltstack Icinga2 API returner
# -*- coding: utf-8 -*-
'''
Return salt data to Icinga2 via the API
The following fields can be set in the minion conf file::
icinga2.url (required)
icinga2.service (optional)
icinga2.username (optional)
icinga2.password (optional)
@hemebond
hemebond / salt_python_renderer_example1.py
Created March 27, 2017 11:00
Render a YAML file using the Saltstack Python renderer
#!py
# test.sls
import yaml
def run():
config = {}
map_file = __salt__.cp.cache_file("salt://formula/map.yaml")
@hemebond
hemebond / check_nginx.py
Last active January 31, 2018 04:04
Nginx Status monitoring plugin script
#!/usr/bin/env python3
"""
Parse the Nginx Status output and return as monitoring plugin data.
"""
import nagiosplugin
from http.client import HTTPConnection
@hemebond
hemebond / autoexec.cfg
Last active September 27, 2018 05:21
Quake configuration for rtlights editing
gl_finish 1
bind q "exec default.cfg"
bind e "exec rtlights.cfg"
@hemebond
hemebond / new_instance.sls.jinja
Created August 25, 2018 03:21
Reactor system for initialising new minions (jinja extensions just for formatting)
{#
Requires Salt 2016.11 as the syntax changes for these functions
https://docs.saltstack.com/en/2016.11/topics/orchestrate/orchestrate_runner.html
Using salt.function instead of salt.state for highstate because of bug https://github.com/saltstack/salt/issues/26448
#}
{% set tag = salt.pillar.get('event_tag') %}
{% set data = salt.pillar.get('event_data') %}
{# minion IDs start with a three-letter code that is their environment #}
@hemebond
hemebond / globals.sls
Created July 31, 2019 15:38
Sharing data in Pillars
#!jinja|yaml|gpg
{%- macro sjoin(items, sep=joiner(','), suffix='', prefix='') %}
{%- for item in items %}{{ sep() }}{{ prefix }}{{ item }}{{ suffix }}{% endfor %}
{%- endmacro %}
domain: my.example.com
@hemebond
hemebond / ad_effectinfo.txt
Last active August 10, 2019 09:09
Arcane Dimensions particle effects with changes
//======================================================================
// PARTICLE DEF file
//
// MOD : AD v1.70 - (Arcane Dimensions)
// Date : 1st August 2017
// Author : Simon "Sock" OCallaghan
// Website: www.simonoc.com
//
//======================================================================
// SHOTGUN
@hemebond
hemebond / gravtest.map
Created November 30, 2019 06:42
My trigger_setgravity test map
// Game: Quake
// Format: Standard
// entity 0
{
"classname" "worldspawn"
"_tb_mod" "src;progs_dump"
"_tb_def" "external:/home/james/.darkplaces/hipnotic/maps/src/hipnotic.fgd"
"wad" "/home/james/.darkplaces/id1/maps/src/prototype.wad"
// brush 0
{
@hemebond
hemebond / get_file_list.py
Last active December 25, 2019 09:54
Get file info for all files inside a zip or pak file
import os
import hashlib
from zipfile import ZipFile, BadZipFile
from datetime import datetime
from vgio.quake.pak import PakFile, BadPakFile # https://github.com/joshuaskelly/vgio/ <3
from typing import Union, BinaryIO
def get_digest(b):
"""Calculate the SHA256 hash of the bytes"""