Skip to content

Instantly share code, notes, and snippets.

View jcockhren's full-sized avatar
👨‍🍳
Cooking up something 🔥

Jurnell Cockhren jcockhren

👨‍🍳
Cooking up something 🔥
View GitHub Profile
homeassistant:
pip.installed:
- bin_env: '/usr/bin/pip3'
python3-pip:
pkg.installed
cython3:
pkg.installed

Coming from puppet I really got used to the hierarchical data structure hiera provides. It's easy to use, yet pretty powerful when used in combination with the module_data puppet module, which allows you to put your hiera-data in the module directory itself, while still being able to globally override stuff from the main hiera source.

The approach I present here allows you to do something similar with salt and it's pillar data by using Jinja2 only. No additional modules whatsoever are required for this to work.

Configuration data is being split up into four levels:

  • state defaults
  • filtered state defaults
  • pillar data
  • filtered pillar data
from django.core.cache import cache
from django.http import HttpResponseForbidden
from functools import wraps
from django.utils.decorators import available_attrs
def ratelimit(limit=10,length=86400):
""" The length is in seconds and defaults to a day"""
def decorator(func):
def inner(request, *args, **kwargs):
ip_hash = str(hash(request.META['REMOTE_ADDR']))
http://pcottle.github.io/learnGitBranching/
http://rogerdudler.github.io/git-guide/
http://think-like-a-git.net/
http://gitimmersion.com/
http://gitref.org/
http://git-scm.com/documentation
Yes, this is a contrived example just to show off what I'm talking about...
init.sls ( I used /base/be_cool/init.sls)
========
do_something_cool:
cmd.run:
- unless: '[[ -e /tmp/dsc.no_run ]]'
- name: echo 'done' > /tmp/dsc.log && touch /tmp/dsc.report && true
@jcockhren
jcockhren / install.sls
Last active December 23, 2015 12:09 — forked from mech422/install.sls
##
## salt '*' grains.setval key val
## salt '*' grains.setval key "{'sub-key': 'val', 'sub-key2': 'val2'}"
##
{% set id = grains.id %}
{% set os = grains.os %}
{% set node_type = pillar.node_type %}
{% set node_role = pillar.node_role %}
{% set key = id + '-sls-base-nginx-_action' %}
*Pigs*
- Product Owner
- Team
- Scrum Master
*Chickens*
Stakeholders
Managers
*Sprint*