Skip to content

Instantly share code, notes, and snippets.

@rca
rca / roles.sls
Created March 8, 2013 01:19
roles pillar data works on salt master, but do not show up on minions
#!py
def get_roles(nodename):
"""
Stub function that will by replaced by a dynamic lookup
"""
roles = []
@rca
rca / gist:5121424
Created March 8, 2013 23:52
Printing responses being dropped even though master receives payload. Code for output below at: https://github.com/rca/salt/tree/debug_dropped_responses
2013-03-08 23:49:48,566 [salt.master ][DEBUG ] Published command details {'tgt_type': 'glob', 'jid': '20130308234948566036', 'tgt': '*', 'ret': '', 'user': 'sudo_local', 'arg': [], 'fun': 'test.ping'}
2013-03-08 23:49:48,577 [salt.master ][INFO ] AES payload received with command _return
2013-03-08 23:49:48,577 [salt.master ][INFO ] Got return from lxc01.baremetal.io for job 20130308234948566036
2013-03-08 23:49:48,577 [salt.master ][DEBUG ] {'jid': '20130308234948566036', 'cmd': '_return', 'return': True, 'id': 'lxc01.baremetal.io'}
2013-03-08 23:49:48,587 [salt.master ][INFO ] AES payload received with command _return
2013-03-08 23:49:48,587 [salt.master ][INFO ] Got return from bm-django for job 20130308234948566036
2013-03-08 23:49:48,587 [salt.master ][DEBUG ] {'
@rca
rca / vbox.sh
Created March 9, 2013 23:19
VirtualBox aliases
VBOX_MANAGE='/Applications/VirtualBox.app/Contents/MacOS/VBoxManage-amd64'
function vautostart() {
cat ${HOME}/.vbox_autostart | while read i; do
${VBOX_MANAGE} startvm --type=headless $i
done;
}
function _vdo() {
buf=$1
# MIT License:
#
# Copyright (C) 2012 Heroku, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:

Django is app-based

projects vs. apps

  • templates directory in apps
  • static directory in apps

python manage.py collectstatic

@rca
rca / foo.md
Created May 24, 2013 22:23
Salt mine always returning data belonging to the salt master

Created mine.sls pillar:

#!py

def run():
    return {
        'mine_interval': 60,
        'mine_functions': {
 'network.interfaces': [],
@rca
rca / docker_registry.conf
Created July 10, 2013 09:11
nginx config for docker registry. The key setting is `client_max_body_size 600M;` which allows large uploads. The setting `proxy_read_timeout 900;` gives the upload enough time to complete (but this might not be needed).
upstream docker_registry {
server 127.0.0.1:15000;
}
server {
listen 443;
root /dev/null;
index index.html index.htm;
@rca
rca / models.py
Created July 30, 2013 23:37
A working post_save signal handler
class Repository(BaremetalModel):
account = models.ForeignKey('Account')
url = GitURIField()
def __unicode__(self):
return unicode(self.url)
def do_something(self):
pass
@rca
rca / foo
Last active December 20, 2015 12:09
{{ salt['baremetal.ssl_cert_path'](domain) }}:
file.managed:
- contents: |
{{ domain['ssl_cert'] | indent(0) }}
@rca
rca / twitter_name.py
Created August 5, 2013 10:58
Find an available name on Twitter
#!/usr/bin/env python
"""
Find a name in Twitter's packed namespace
Type in a word like your name and get some variations.
"""
import os
import sys