Skip to content

Instantly share code, notes, and snippets.

View lsjostro's full-sized avatar
:shipit:

Lars Sjöström lsjostro

:shipit:
View GitHub Profile
@lsjostro
lsjostro / docker-registry-caching-proxy.conf
Created March 14, 2017 21:34 — forked from etuttle/docker-registry-caching-proxy.conf
NGINX config for a caching proxy that sits in front of a docker registry
upstream docker-mirror-upstream {
server upstream.example.com;
}
proxy_cache_path /var/lib/docker-mirror/cache levels=1:2 max_size=10g inactive=48h keys_zone=cache:10m;
server {
listen 80 default_server;
listen 443 ssl default_server;
@lsjostro
lsjostro / rkt-in-rkt-issue.sh
Last active June 9, 2016 09:22
rkt in rkt issue
$ /usr/local/bin/rkt version
rkt Version: 1.7.0
appc Version: 0.8.4
Go Version: go1.6.1
Go OS/Arch: linux/amd64
Features: -TPM
# _Without_ bind mount of /var/lib/rkt
$ sudo /usr/local/bin/rkt run \
--insecure-options=image \
@lsjostro
lsjostro / changesets.groovy
Created April 20, 2016 08:33
Jenkinsfile: build only changed files
#!groovy
@NonCPS
def getACIChangeSets() {
def aci = []
currentBuild.rawBuild.getChangeSets().each { cs ->
cs.getItems().each { item ->
item.getAffectedFiles().each { f ->
if (f.path.endsWith(".yml")) {
aci << f.path
}
def main():
options = parse_options()
db = Connection('localhost', 27017).pulp_database
rpms = db.units_rpm
repo_content_units = db.repo_content_units.find({'repo_id': options.repo_id})
units = {}
for unit in repo_content_units:
data = rpms.find_one({"_id": unit['unit_id']})
if data:
@lsjostro
lsjostro / puppetdb_report.sh
Created June 3, 2014 13:25
puppetdb event report shell function
# req: brew/yum install jq on MacOS X/Linux (install in .bashrc or global profile.d/)
export PUPPETDB_HOST="my.puppetdb.host.foo"
function puppet_report { curl -sG http://$PUPPETDB_HOST/v3/events --data-urlencode "query=[\"and\", [\"=\", \"latest-report?\", true],[\"~\", \"certname\", \"^$1\"]]" | jq -r '.[] | .certname+","+.["resource-type"]+"["+.["resource-title"]+"]" + "," +.status + "," + .message' | column -t -s,; }
export -f puppet_report
@lsjostro
lsjostro / flume-logstash.py
Created March 14, 2014 18:58
multiline logstash to flumelogger
#!/usr/bin/python
import re
import time
import logging
from os import stat
from stat import ST_SIZE
from flumelogger.handler import FlumeHandler
FILE_INPUT = "/var/log/jenkins/jenkins.log"
MULTILINE_PATTERN_RE = r"^\w+ \d+, \d+ (\d+?:){1,2}\d\d \w\w "
#!/usr/bin/python
import sys
import time
import socket
import urllib2
def main(haproxy_host, statsd_host):
s = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)