Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)
First one found from of
Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)
First one found from of
I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):
For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source. | |
# Will include all hosts the playbook is run on. | |
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html | |
- name: "Build hosts file" | |
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present | |
when: hostvars[item].ansible_default_ipv4.address is defined | |
with_items: groups['all'] |
--- | |
# 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: |
This script can help you find and remove unused AWS snapshots and volumes.
There is hardcoded list of regions that it searches, adjust the value to suit your needs.
Use snapshot.py snapshot-report
to generate report.csv
containing information about all snapshots.
snapshot.py snapshot-cleanup
lets you interactively delete snapshot if it finds it is referencing unexisting resources.
./snapshots.py --help
# Add this snippet to the top of your playbook. | |
# It will install python2 if missing (but checks first so no expensive repeated apt updates) | |
# gwillem@gmail.com | |
- hosts: all | |
gather_facts: False | |
tasks: | |
- name: install python 2 | |
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) |
#!/bin/bash | |
# set up some variables | |
NOW_DATE=$(date '+%Y-%m-%d-%H-%M') | |
RESTORE_FROM_INSTANCE_ID=<source name> | |
TARGET_INSTANCE_ID=<target name> | |
TARGET_INSTANCE_CLASS=db.m4.large | |
VPC_ID=<vpc subnet id> | |
NEW_MASTER_PASS=<root password> |
#!/usr/bin/expect | |
set timeout -1; | |
spawn {{django_dir}}/venv/bin/python manage.py changepassword {{admin_user}}; | |
expect { | |
"Password:" { exp_send "{{admin_pass}}\r" ; exp_continue } | |
"Password (again):" { exp_send "{{admin_pass}}\r" ; exp_continue } | |
eof | |
} |
- name: ensure github.com is a known host | |
lineinfile: | |
dest: /root/.ssh/known_hosts | |
create: yes | |
state: present | |
line: "{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}" | |
regexp: "^github\\.com" |
[ssh_connection] | |
ssh_args = -F ssh.cfg | |
control_path = ~/.ssh/mux-%r@%h:%p |