Skip to content

Instantly share code, notes, and snippets.

View manicminer's full-sized avatar
☁️

Tom Bamford manicminer

☁️
View GitHub Profile
@manicminer
manicminer / info.md
Last active November 1, 2018 22:44
RDS Production termination protection

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.

---
- block:
- name: Retrieve some information
stat:
path: /path/to/a/file
register: info_result
- name: Check a condition
assert:
@manicminer
manicminer / latest-arch-ami.yml
Created February 14, 2016 21:21
Find the latest Arch Linux AMI
- hosts: localhost
connection: local
tasks:
- ec2_ami_find:
name: "arch-linux-hvm-*.x86_64-ebs"
virtualization_type: hvm
owner: 093273469852 # Uplink Labs
sort: name
@manicminer
manicminer / git_facts.py
Created February 13, 2015 21:05
Ansible git_facts module
#!/usr/bin/python
DOCUMENTATION = '''
---
module: git_facts
version_added: "devel"
short_description: retrieve facts about a git repository
description:
- retrieve facts about a git repository. This module has a dependency on GitPython.
options:
@manicminer
manicminer / append.py
Last active August 29, 2015 14:11
Append some string in place after a multiline match
#!/usr/bin/env python
import re, sys
filename = sys.argv[1]
match = sys.argv[2]
append = sys.argv[3]
f = open(filename, 'r+')
content = f.read()
@manicminer
manicminer / results with limit
Created October 29, 2014 12:06
ansible limit test with host facts
$ ansible-playbook -i test.ini test.yml --limit group1
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [group1]
TASK: [command true] **********************************************************
changed: [host1]
@manicminer
manicminer / ansible_test.yml
Last active August 29, 2015 14:07
Conditional fail
---
- hosts: localhost
connection: local
tasks:
- set_fact:
is_test: "{{ env == 'development' or 'test' in env }}"
- set_fact:
security_group: blah