This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import subprocess | |
from random import randint | |
COWSAY = "/usr/games/cowsay" | |
def get_randomth(arr): | |
return arr[randint(0, len(arr) - 1)] | |
def get_critters(cowsay): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# set up our graphite namespace | |
graphite_host="localhost" | |
graphite_port=2003 | |
namespace="system.$(hostname).loadavg" | |
# get current time and loadavg | |
time=$(date +'%s') | |
load=$(cat /proc/loadavg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example.net | |
(:require [goog.net.WebSocket] | |
[goog.events :refer (listen)] | |
[cljs.core.async :as async :refer (chan <! >! put! close)] | |
[cljs.core.async.impl.protocols :as proto]) | |
(:require-macros [cljs.core.async.macros :refer (go)])) | |
(defn ws | |
"WebSocket as a core.async channel | |
returns a channel which delivers the ws chan then closes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
connection: local | |
vars: | |
special: '{{ hostvars[inventory_hostname]["ansible_" + cluster_interface]["ipv4"]["address"] }}' | |
tasks: | |
- set_fact: {cluster_interface: eth0} | |
- name: reading special var |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: compiling & installing some package | |
shell: > | |
creates=/path/to/some/binary | |
curl somebinary | tar xz && cd /path/to/extracted && | |
make && | |
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ansible uses jinja templates for variable substitution | |
# because of this, you are free to use all of jinja anywhere ansible templates | |
# for example the arguments to modules | |
- name: pattern or antipattern? you decide | |
hosts: local | |
connection: local | |
vars: | |
iferate: no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: control some app | |
hosts: localhost | |
vars: | |
git_repo: git://example.org/path/to/repo.git | |
app_home: ~/projects/app | |
super_args: > | |
config=~/.virtualenvs/supervisor/conf/supervisord.conf | |
supervisorctl_path=~/.virtualenvs/supervisor/bin/supervisorctl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SETUP VARS: | |
# this assumes this script is in $ANSIBLE_ROOT/scripts/setup-ansible.sh and roles are in $ANSIBLE_ROOT/roles | |
ANSIBLE_ROOT=$(dirname $(dirname $(readlink -e $0))) | |
# ANSIBLE_PACKAGE_NAME="ansible" # latest official release | |
ANSIBLE_PACKAGE_NAME="git+https://github.com/ansible/ansible@devel" # mainline dev branch | |
function install_ansible() { | |
echo "Beginning ansible installation.." | |
sudo su -c "apt-get remove ansible -y; apt-get install python-pip python-virtualenv -y && pip uninstall ansible -y; pip install ${ANSIBLE_PACKAGE_NAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: webservers | |
vars_files: | |
- vars/web-archival-config.yaml | |
roles: | |
- getcwd | |
- role: cron-job | |
frequency: hourly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.define :serf do |config| | |
config.vm.box = "precise64" | |
config.vm.box_url = "http://files.vagrantup.com/precise64.box" |