Skip to content

Instantly share code, notes, and snippets.

type: CheckConfig
api_version: core/v2
metadata:
name: read_secret
spec:
command: env|grep -i influx
env_vars:
- INFLUXDB_PASSWORD=strongpasshere
- INFLUXDB_USER=sensu-read
handlers: []
type: CheckConfig
api_version: core/v2
metadata:
name: read_secret
spec:
command: env|grep -i influx
env_vars: null
handlers: []
publish: false
secrets:
@anatolijd
anatolijd / sensu-go-agent-patch.diff
Last active November 15, 2020 22:42
sensu-agent with vault support
diff --git a/agent/agent.go b/agent/agent.go
index 3b8cb897..3e00ed65 100644
--- a/agent/agent.go
+++ b/agent/agent.go
@@ -35,12 +35,15 @@ import (
"github.com/sensu/sensu-go/util/retry"
utilstrings "github.com/sensu/sensu-go/util/strings"
"github.com/sirupsen/logrus"
+ "github.com/anatolijd/vaultservice/vaultservice"
)
import commands
import time
import sys
from socket import socket
import argparse
import os
import pymongo
from pymongo import Connection
import yaml
@anatolijd
anatolijd / configure-pat.sh
Created August 12, 2014 21:06
AWS VPC NAT instance script ( /usr/local/sbin/configure-pat.sh)
#!/bin/bash
# Configure the instance to run as a Port Address Translator (PAT) to provide
# Internet connectivity to private instances.
#
set -x
echo "Determining the MAC address on eth0"
ETH0_MAC=`/sbin/ifconfig | /bin/grep eth0 | awk '{print tolower($5)}' | grep '^[0-9a-f]\{2\}\(:[0-9a-f]\{2\}\)\{5\}$'`
if [ $? -ne 0 ] ; then
require 'fog'
bucket = 'bucket-name'
credentials = {
:provider => 'AWS',
:aws_access_key_id => 'access_key_id',
:aws_secret_access_key => 'secret_key',
}
fog = Fog::Storage.new(credentials)
---
# This has been tested with ansible 1.3 with these commands:
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts"
# NB: The type of the variable is crucial!
- name: Ansible Conditionals Examples
hosts: $hosts
vars_files:
@anatolijd
anatolijd / hash_ring_selector2.py
Last active December 16, 2017 04:48
Following the https://gist.github.com/anatolijd/5576536 and https://answers.launchpad.net/graphite/+question/228472 I've limited the combinations (each CARBONLINK_HOSTS item is assigned a list of local carbon-cache instances only), and rearranged the output. Now it is pretty clear visible that webapp consistent hashing get_node(key) does the job…
# python hash_ring_selector2.py
DESTINATIONS : ['10.4.0.1:2104:a', '10.4.0.1:2204:b',
'10.4.0.2:2104:a', '10.4.0.2:2204:b']
CARBONLINK_HOSTS: ['10.4.0.1:7102:a', '10.4.0.1:7202:b']
result metric carbon-relay webapp
[ OK ] some.metric ('10.4.0.1', 'b') ('10.4.0.1', 'b')
[ OK ] mymetric ('10.4.0.1', 'a') ('10.4.0.1', 'a')
@anatolijd
anatolijd / hash_ring_selector_stdout
Created May 14, 2013 14:52
A test script to answer the question whether the list of instances in DESTINATIONS AND CARBONLINK_HOSTS should match each other and have the exactly same order. test run output provided It seems that the order carbon-cache instances are listed does not matter. The only requirement is that CARBONLINK_HOSTS should list all the carbon-cache instanc…
# python hash_ring_selector_test.py
========================================================================================================================
DESTINATIONS = ['192.168.97.121:2104:a', '192.168.97.121:2204:b', '192.168.97.132:2104:a', '192.168.97.132:2204:b']
CARBONLINK_HOSTS = ['192.168.97.121:7102:a', '192.168.97.121:7202:b', '192.168.97.132:7102:a', '192.168.97.132:7202:b']
result metric carbon-relay webapp
[ OK ] test.anatoliy ('192.168.97.121', 'b') ('192.168.97.121', 'b')
[ OK ] test.random ('192.168.97.121', 'b') ('192.168.97.121', 'b')
[ OK ] test.roma ('192.168.97.121', 'a') ('192.168.97.121', 'a')