Skip to content

Instantly share code, notes, and snippets.

View arbabnazar's full-sized avatar
🏠
Working from home

Arbab Nazar arbabnazar

🏠
Working from home
View GitHub Profile
@arbabnazar
arbabnazar / boto3_hands_on.md
Created March 25, 2016 12:54 — forked from iMilnb/boto3_hands_on.md
Programmatically manipulate AWS resources with boto3 - a quick hands on

boto3 quick hands-on

This documentation aims at being a quick-straight-to-the-point-hands-on AWS resources manipulation with [boto3][0].

First of all, you'll need to install [boto3][0]. Installing it along with [awscli][1] is probably a good idea as

  • [awscli][1] is boto-based
  • [awscli][1] usage is really close to boto's
@arbabnazar
arbabnazar / github-knownhost.yml
Created July 20, 2016 18:12
add the github rsa public key to the known hosts
- name: Tell the host about our servers it might want to ssh to
known_hosts:
path: '/etc/ssh/ssh_known_hosts'
name: 'github.com'
key: "{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}"
@arbabnazar
arbabnazar / ansible.yml
Created August 20, 2016 19:40 — forked from ernestas-poskus/ansible.yml
Ansible Tips
# 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 %}"
@arbabnazar
arbabnazar / info.md
Created May 12, 2017 19:00 — forked from manicminer/info.md
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.

@arbabnazar
arbabnazar / changepassword.sh.j2
Created August 20, 2016 19:50 — forked from elleryq/changepassword.sh.j2
Create Django super user in ansible
#!/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
}
@arbabnazar
arbabnazar / elastic_beanstalk_external_sessions.md
Created July 12, 2016 09:26 — forked from mlconnor/elastic_beanstalk_external_sessions.md
Analaysis and recommendation for externalizing session in Elastic Beanstalk using Tomcat and memcached.

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

---
- name: Ansible tips
connection: local
hosts: localhost
tasks:
- name: Ping only if OSX
ping:
when: "{{ lookup('pipe', 'uname -s') | match('Darwin') }}"
#!/bin/bash
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
@arbabnazar
arbabnazar / snapshots.py
Created August 15, 2017 18:35 — forked from Eyjafjallajokull/README.md
AWS EBS - Find unused snapshots - this script generates csv raport about snapshot usage
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']
@arbabnazar
arbabnazar / nodejs-installers.groovy
Created August 23, 2017 14:23 — forked from mllrjb/nodejs-installers.groovy
Jenkins init.groovy.d Nodejs installer script
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 = [