set timeout -1;
spawn {{django_dir}}/venv/bin/python changepassword {{admin_user}};
expect {
"Password:" { exp_send "{{admin_pass}}\r" ; exp_continue }
"Password (again):" { exp_send "{{admin_pass}}\r" ; exp_continue }
View ansible.yml
# Extracting all ips from defined group
ips: "{{ groups['webservers']|map('extract', hostvars, ['ansible_eth1', 'ipv4', 'address'])|list }}"
# Iterate through dict, reject empty values
nsq_nsqd_opts: "{% for key, value in nsq_nsqd.iteritems() if value is not none %}-{{ key | replace('_', '-') }}=\"{{ value }}\" {% endfor %}"
View github-knownhost.yml
- name: Tell the host about our servers it might want to ssh to
path: '/etc/ssh/ssh_known_hosts'
name: ''
key: "{{ lookup('pipe', 'ssh-keyscan -t rsa') }}"

Session Management in an Autoscaling Environment

Problem Statement

User sessions in J2EE and LAMP stacks have traditionally been handled in memory by the application server handling the user request. Because of that, load balancers have been configured to use sticky sessions. By sticky sessions we mean that once the user has visited the site, they will be assigned an app server and will return to that server for subsequent requests. The load balancers typically handle that by referencing the users session cookie.

Elastic cloud environments differ from traditional server configurations in that they have a variable number of servers based on traffic loads whereas traditional configurations had a fixed number of servers. When traffic volumes decline it is necessary to vaporize servers. In doing so, we would lose user sessions (essentially forcing a logout) unless we come up with a new strategy for session management.

A new approach

After much research, it is clear that the best

View gist:6b9909cfba52ac066512ba5d1c1a1080
# files/env:
Defaults env_keep += "SSH_AUTH_SOCK"
# tasks/main.yml
- name: ensure sudo keeps SSH_AUTH_SOCK in environment
copy: src=env
View ansible-tips.yml
- name: Ansible tips
connection: local
hosts: localhost
- name: Ping only if OSX
when: "{{ lookup('pipe', 'uname -s') | match('Darwin') }}"
apt-get update
apt-get install -y libffi-dev g++ libssl-dev python-pip python-dev git
pip install -U awscli ansible setuptools
aws s3 cp s3://tendo-github-key-s3/git-private-key /root/.ssh/bitbucket_secret_key
chmod 400 /root/.ssh/bitbucket_secret_key
View s3-policy.json
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": [
"Resource": [
provider "aws" {
region = "${var.aws_region}"
// Setup your S3 Bucket
resource "aws_s3_bucket" "cdn_bucket" {
bucket = "${var.bucket_name}"
acl = "public-read"
policy = <<POLICY
View rename-bulk-files-with-ansible.yml
- hosts: all
gather_facts: no
become: yes
- shell: ls /files/*
register: files_to_rename
- copy:
src: "{{ item.1 }}"
dest: "/files/file-{{ item.0 + 1 }}"