View python27.yml
---
- hosts: all
gather_facts: no
become: yes
tasks:
- name: Install python27 for Ansible
raw: bash -c "test -e /usr/bin/python || (apt -qqy update && apt install -qqy python-minimal)"
register: output
changed_when: output.stdout != ""
View simple_args_parsing.sh
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
View Install PHP 5.3 on Ubuntu 14.04(trusty)
#Add the Ubuntu 12.04(precise) repositories
cat <<EOF >> /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu precise main restricted universe
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
EOF
# Update the repos
apt-get update
View get_subnet_route_map.py
from jinja2.utils import soft_unicode
def get_subnet_route_map(value, routes, tag_key='Type', tag_value='public'):
# given a list of subnet results from the ec2_vpc_subnet task
# and a list of route results from the ec2_vpc_route_table task
# return a list of dicts of public subnet_id : route_id mapping
# where the public subnet is in the same az as the subnet the
# route is associated with
# assumes all private subnets in a routing table are in the same az!
View extras.py
# ansible_plugins/filter_plugins/extras.py
def getFromDict(dataDict, mapList):
return reduce(lambda d, k: d[k], mapList, dataDict)
def get_host_attr_for_group(hosts, hostvars, keys):
# given a list of nested keys, return the value for each host in hostvars
results = []
for host in hosts:
results.append(getFromDict(hostvars[host], keys))
return results
View python-update-on-ubuntu-14.04
sudo add-apt-repository ppa:jonathonf/python-2.7
sudo apt-get update
sudo apt-get install python2.7
python --version
View ec2_cloud.groovy
/*
* Configure the Jenkins EC2 Plugin via Groovy Script
* EC2 Plugin URL: https://wiki.jenkins-ci.org/display/JENKINS/Amazon+EC2+Plugin
*/
import hudson.model.*
import jenkins.model.*
import hudson.plugins.ec2.*
import com.amazonaws.services.ec2.model.InstanceType
View nodejs-installers.groovy
import jenkins.model.*
import hudson.model.*
import jenkins.plugins.nodejs.tools.*
import hudson.tools.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("jenkins.plugins.nodejs.tools.NodeJSInstallation")
def versions = [
View snapshots.py
import re
import boto3
import csv
from botocore.exceptions import ClientError
ec2 = boto3.client('ec2')
def get_snapshots():
return ec2.describe_snapshots(OwnerIds=['self'])['Snapshots']
View info.md

RDS Production Termination Protection

Create a policy like this, substituting your AWS account number, then attach it to all groups and roles. It will prevent deletion of RDS instances containing the string "prod" in their name.

Note: This is intended to prevent accidental deletion, and is easily sidestepped.