Skip to content

Instantly share code, notes, and snippets.

@gauravve
gauravve / ansible_conditionals_examples.yaml
Created November 24, 2015 05:08 — forked from marcusphi/ansible_conditionals_examples.yaml
Ansible 1.3 Conditional Execution -- Very complete example with comments -- I find the conditional expressions to be ridiculously hard to get right in Ansible. I don't have a good model of what's going on under the surface so I often get it wrong. What makes it even harder is that there has been at least three different variants over the course …
---
# 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:
@gauravve
gauravve / playbook-install-jdk8.yml
Created November 24, 2015 11:39 — forked from andershedstrom/playbook-install-jdk8.yml
Ansible playbook for installing Oracle Java 8 on CentOS
---
- hosts: app
remote_user: vagrant
sudo: yes
vars:
download_url: http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.tar.gz
download_folder: /opt
java_name: "{{download_folder}}/jdk1.8.0_05"
java_archive: "{{download_folder}}/jdk-8u5-linux-x64.tar.gz"
@gauravve
gauravve / Vagrantfile.rb
Created December 16, 2015 10:11 — forked from mrrooijen/Vagrantfile.rb
Example of running multiple VM's using a single Vagrantfile.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "base"
config.vm.customize ["modifyvm", :id, "--memory", 1024]
config.vm.define :haproxy do |haproxy|
haproxy.vm.forward_port 80, 8000
haproxy.vm.network :hostonly, "192.168.1.10"
@gauravve
gauravve / Vagrantfile
Last active June 11, 2016 09:53
Simple Vagrant file with private network and shell provisioner
Vagrant.configure(2) do |config|
config.vm.define "grafana", autostart: false do |ami|
ami.vm.box = "puppetlabs/centos-7.2-64-nocm"
ami.vm.network "private_network", ip: "192.168.0.20"
ami.vm.network "forwarded_port", guest: 3000, host: 3000
ami.vm.network "forwarded_port", guest: 8083, host: 8083
@gauravve
gauravve / influxdb-grafana-howto.sh
Created May 7, 2016 13:26 — forked from otoolep/influxdb-grafana-howto.sh
Shell script to download, and configure, InfluxDB, nginx, and Grafana
#!/bin/bash
# Check out the blog post at:
#
# http://www.philipotoole.com/influxdb-and-grafana-howto
#
# for full details on how to use this script.
AWS_EC2_HOSTNAME_URL=http://169.254.169.254/latest/meta-data/public-hostname
INFLUXDB_DATABASE=test1
@gauravve
gauravve / gist:82edde94ff67c4207d6dcdefbfed2ae7
Created May 26, 2016 11:41
Install specific version of docker on Ubuntu 15.10 Wily
apt-get update
apt-get install apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-wily main" > /etc/apt/sources.list.d/docker.list
apt-get update
apt-cache madison docker-engine
apt-get install -y docker-engine=1.10.3-0~wily
service docker start
@gauravve
gauravve / install_centos_docker.sh
Created May 28, 2016 23:23
Docker Centos Install specific docker version
sudo yum -y update
sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
sudo yum install -y docker-engine-1.10.3
@gauravve
gauravve / install_ansible.sh
Last active November 4, 2019 15:35
Install ansible using pip on centos7
sudo rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
#Yum
sudo yum -y update
sudo yum install -y python-devel
sudo yum install -y openssl-devel
sudo yum install -y libffi-devel
sudo yum -y install python-pip
@gauravve
gauravve / envelope_encryption_kms_boto_pycrypto.md
Created August 26, 2016 02:42 — forked from pmp/envelope_encryption_kms_boto_pycrypto.md
Envelope Encryption using AWS KMS, Python Boto, and PyCrypto.

If you use Amazon AWS for nearly anything, then you are probably familiar with KMS, the Amazon Key Management Service.

KMS is a service which allows API-level access to cryptographic primitives without the expense and complexity of a full-fledged HSM or CloudHSM implementation. There are trade-offs in that the key material does reside on servers rather than tamper-proof devices, but these risks should be acceptable to a wide range of customers based on the care Amazon has put into the product. You should perform your own diligence on whether KMS is appropriate for your environment. If the security profile is not adequate, you should consider a stronger product such as CloudHSM or managing your own HSM solutions.

The goal here is to provide some introductory code on how to perform envelope encrypt a message using the AWS KMS API.

KMS allows you to encrypt messages of up to 4kb in size directly using the encrypt()/decrypt() API. To exceed these limitations, you must use a technique called "envelope encryptio

@gauravve
gauravve / release.sh
Created September 10, 2016 13:16 — forked from bclinkinbeard/release.sh
Bash script to automate the Git Flow tag/release process
#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# v1.0.0, v1.5.2, etc.
versionLabel=v$1
# establish branch and tag name variables
devBranch=develop