Skip to content

Instantly share code, notes, and snippets.

John E. Vincent lusis

Block or report user

Report or block lusis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View python argparse subcommand subparsers.py
import argparse
from mock import Mock
m = Mock()
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
query_group = subparsers.add_parser('query')
add_group = subparsers.add_parser('add')
@lusis
lusis / index.md
Last active Jul 13, 2019
Docker "Best Practices"
View index.md

This is a copy/paste from an internal wiki on how we should use docker

This guide is to serve as an outline of internal best practices to using Docker. The idea is to give enough information to allow engineers to create containers for new stack components while minimizing the cleanup required to make them production ready.

Concepts

Before we get to the practices, it's important to understand WHY we are doing this. The key concepts we're concerned about with broad Docker usage are provenance, determinism, repeatability and auditability.

Provenance

Provenance refers to knowing WHERE something comes from. Generally with the end use of software, this is easy:

  • Maven artifacts are pulled from central
@lusis
lusis / README.md
Created Apr 10, 2019
exabgp promethues exporter
View README.md

Current metrics at startup

root@node1:~# curl -s http://localhost:9569/metrics  | grep peer
# HELP peer_route_state shows the current peer state for a given route
# TYPE peer_route_state gauge
peer_route_state{family="ipv4 unicast",peer_asn="64496",peer_ip="192.168.1.2",route="192.168.88.2/32",self_asn="64496",self_ip="192.168.1.184"} 1
# HELP peer_state shows the current peer state
# TYPE peer_state gauge
peer_state{peer_asn="64496",peer_ip="192.168.1.2",self_asn="64496",self_ip="192.168.1.184"} 1
@lusis
lusis / README.md
Last active Apr 10, 2019
terraform template to generate serverspec properties
View README.md

This uses terraform's template_file resource to generate a yaml properties file for serverspec to use.

  • create the Rakefile in your terraform project root
  • create a spec directory and put spec_helper.rb in it
  • create the templates/properties.tmpl.yml file
  • create the serverspec.tf
  • terraform apply

tests

Tests will be matched based on roles defined for a given node.

View artifactory.conf
# place in /etc/yum/pluginconf.d/artifactory.conf
[main]
enabled=1
@lusis
lusis / keytool.rb
Created Mar 26, 2012
recipe for adding certs to keytool
View keytool.rb
keystore = "/etc/java-6-sun/security/cacerts"
keystore_pass = "foobar"
# you'll need foo.cert et. al. in files/default
certs = %w{foo bar bang}
certs.each do |cert|
cookbook_file "#{Chef::Config[:file_cache_path]}/#{cert}.cert" do
source "#{cert}.cert"
end
@lusis
lusis / dba-user.json
Created Jan 7, 2011
Managing MySQL user accounts with Chef
View dba-user.json
{
"id":"dbauser",
"uid":506,
"comment":"DBA User",
"shell":"/bin/bash",
"groups": [
"sysadm",
"dba"
],
"ssh_key": "XXXXXXXXXX"
@lusis
lusis / package.sh
Created Feb 26, 2013
Generate system packages with FPM as part of maven.
View package.sh
#!/usr/bin/env bash
if [ -z ${CURRENT_ITERATION} ]; then
CURRENT_ITERATION=0enstratus1
fi
case "${PKG_VERSION}" in
*-SNAPSHOT)
echo "Packaging a snapshot version!"
CURRENT_TSTAMP=`date +%s`
#CURRENT_SHA=`git rev-parse HEAD`
#CURRENT_ITERATION="${CURRENT_TSTAMP}-${CURRENT_SHA}"
@lusis
lusis / iam-s3-policy.json
Created Jan 5, 2011
A sample AWS IAM json policy file with read-only access to certain S3 buckets
View iam-s3-policy.json
{
"Statement":[{
"Effect":"Allow",
"Action":["s3:ListBucket","s3:GetObject","s3:GetObjectVersion"],
"Resource":["arn:aws:s3:::my_bucket/*","arn:aws:s3:::my_bucket"]
}
],
"Statement":[{
"Effect":"Allow",
"Action":["s3:ListBucket","s3:GetObject","s3:GetObjectVersion"],
@lusis
lusis / log4j.xml
Created Nov 23, 2011
Ruby logstash cli application - allows searching historical data in ElasticSearch or live tailing from AMQP topic exchange
View log4j.xml
<!-- the env variables are controlled by Chef and passed in via -D on the java command-line -->
<!-- This is using the appender here: https://github.com/t0xa/gelfj -->
<appender name="graylog2" class="org.graylog2.log.GelfAppender">
<param name="graylogHost" value="${graylog.server}"/>
<param name="originHost" value="${graylog.origin}"/>
<param name="extractStacktrace" value="true"/>
<param name="addExtendedInformation" value="true"/>
<!-- The _web part is because a given app has multiple components -->
<!-- This app might have a _web as well as an _batch component -->
<param name="facility" value="${graylog.facility}_web"/>
You can’t perform that action at this time.