Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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()
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
#whatever/init.sls
install some package
do basic configuration
include:
- .users
#whatever/users.sls
configure some users for the service
{
"checks": {
"load_metrics": {
"type": "metric",
"command": "metrics-load.rb",
"interval": 1,
"subscribers": ["all"],
"handlers": ["show", "debug"]
}
}
echo -n "memory_used,host=com.somedomain.something-whatever,metric=memory_metrics value=123 1439500070" | nc -u -w1 192.168.217.87 8090
@dnd
dnd / auth.log
Last active September 4, 2015 14:53
filter_syslog.conf
Sep 4 09:30:24 lb1 sshd[29552]: Accepted publickey for steve from 72.64.121.61 port 35652 ssh2: RSA 70:74:08:63:33:7f:28:c2:8c:65:da:70:51:11:fd:c1
Sep 4 10:10:41 app1 sudo: pam_unix(sudo:auth): authentication failure; logname=steve uid=1006 euid=0 tty=/dev/pts/1 ruser=events rhost= user=events
Sep 4 10:14:35 app1 sshd[9274]: Failed password for events from 72.64.121.61 port 38268 ssh2
Sep 4 10:14:37 app1 sshd[9274]: Connection closed by 72.64.121.61 [preauth]
@dnd
dnd / handlers.json
Created September 11, 2015 23:19
Sensu InfluxDB 0.9 UDP Line Protocol
{
"handlers": {
"metrics": {
"type": "set",
"handlers": ["influxdb_udp"]
},
"influxdb_udp": {
"type": "udp",
"mutator": "influxdb_line_protocol",
"socket": {
@dnd
dnd / production environment results.json
Created February 2, 2016 14:10
Different scoring for same documents
// There are many more users that have been snipped out of this, but they all score exactly the same matching the first name 'lori'
[
{
"attributes": {
"first_name": "Lori",
"last_name": "Packer",
"phone": null,
"created_at": "2015-01-14T21:44:47.000Z",
"updated_at": "2015-01-14T21:55:08.000Z",
"role_ids": [