Skip to content

Instantly share code, notes, and snippets.

#whatever/init.sls
install some package
do basic configuration
include:
- .users
#whatever/users.sls
configure some users for the service
require 'test_helper'
require 'virtus'
require 'representable/json'
class NilFailTest < MiniTest::Spec
class Company
include Virtus.model
attribute :name, String
attribute :errors, Hash, default: nil
@dnd
dnd / gist:f96853b6837331113929
Last active August 29, 2015 14:13
environment custom grain
#!/usr/bin/env python
import salt.config
import salt.loader
import salt.utils
__opts__ = salt.config.minion_config('/etc/salt/minion')
envutil = salt.loader.raw_mod(__opts__, 'envutil', None)
def environment():
fqdn = salt.utils.network.get_fqhostname()
@dnd
dnd / environment.py
Created January 7, 2015 16:46
_grains/environment.py
#!/usr/bin/env python
import salt.log
import salt.utils
def environment():
fqdn = salt.utils.network.get_fqhostname()
host = fqdn.partition('.')[0]
grains = {}
environment = __salt__['envutil.infer_env_from_name'](host)
@dnd
dnd / bootstrap-linode-networking.sh
Last active August 29, 2015 14:12
bootstrap-linode-networking.sh
#!/bin/bash
echo "Setting hostname to: {{vm['name']}}"
echo '{{vm['name']}}' > /etc/hostname
hostname -F /etc/hostname
echo "Setting private interface address to: {{data['private_ips'][0]}}"
cat >>/etc/network/interfaces <<EOF
auto eth0:0
@dnd
dnd / gist:f250a6c0cde8e79f9b20
Created August 29, 2014 06:09
Grape ActiveSupport Instrumentation
class Logger
def initialize(app)
@app = app
end
def call(env)
payload = {
remote_addr: env['REMOTE_ADDR'],
request_method: env['REQUEST_METHOD'],
request_path: env['PATH_INFO'],
setup-rabbit:
salt.state:
- tgt: 'G@environment:staging and G@provides:rabbitmq:*'
- tgt_type: compound
- sls:
- rabbitmq
# do stuff
include:
- somesls
# do some more stuff
include:
- anothersls
- require:
@dnd
dnd / gist:72f2da2354d8abe39636
Last active August 29, 2015 14:02
SaltStack YAML block reuse
#salt requires a proper dictionary with declared state, so the file.missing is just a dummy
appUserGroup:
file.missing:
- name: /tmp/aroisntoaursntoyaurnsotnarstnarosetairestoiaernst
- &usergroup
- user: {{user}}
- group: {{group}}
- hashvalues: &hashvals
some: value
include:
- appbase:
- context:
appname: app1
# do stuff specific to this app