Skip to content

Instantly share code, notes, and snippets.

View kszarek's full-sized avatar

Krzysztof Szarek kszarek

View GitHub Profile
@kszarek
kszarek / pulse.rb
Last active August 29, 2015 14:01
pulse deployment
include_recipe "smart_git::pulse"
include_recipe "smart_nodejs"
execute "start-pulse" do
action :run
command "su - nodejs -c 'cd pulse && ./start.sh'"
not_if "nc -w1 -zvv localhost 5555 2>/dev/null;"
end
@kszarek
kszarek / faf.py
Last active August 29, 2015 14:01
faf show
@task
def show(debug=False):
"""Show server list via EC2"""
instances = get_instances_map(debug)
sorted_instances = sorted(instances, key=lambda instance: instance['name'])
print 'Instance ID Name ',
print 'Public IP Private IP Flavor State',
print ' Status Prev Version Current Version Next Version'
for instance in sorted_instances:
@kszarek
kszarek / smartiam.py
Created June 20, 2014 10:37
SmartIAM class
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from boto.exception import BotoServerError
from boto.iam import IAMConnection
__author__ = 'Krzysztof Szarek'
class SmartIAM(IAMConnection):
def create_user(self, user):
@kszarek
kszarek / ec2_functions.py
Created June 23, 2014 12:06
Create ec2 instance with new ssd backed ebs
dev_sda1 = boto.ec2.blockdevicemapping.BlockDeviceType(
delete_on_termination=True, volume_type='gp2')
dev_sda1.size = env.ebs_size # size in Gigabytes
bdm = boto.ec2.blockdevicemapping.BlockDeviceMapping()
bdm['/dev/sda'] = dev_sda1
@kszarek
kszarek / default.rb
Created August 4, 2014 06:12
chef cron @reboot
cron "chef-client-autostart" do
time :reboot
command "/opt/chef/embedded/bin/ruby /usr/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef.log -P /var/run/chef/client.pid"
end
@kszarek
kszarek / upstreams.conf.erb
Created August 12, 2014 18:58
only one can rule the world
#cartmans
upstream wo {
<%- @wo.each do |host| %>
server <%= host %>:80<%- if @wo.length > 1 and @wo.index(host) != 0 %> backup<%- end %>;
<%- end %>
}
#cartmans2
upstream wo2 {
<%- @wo.each do |host| %>
server <%= host %>:80<%- if @wo.length > 1 and @wo.index(host).modulo(2) != 1 %> backup<%- end %>;
@kszarek
kszarek / decorators.py
Created October 22, 2014 09:16
fabric decorator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Krzysztof Szarek'
from functools import wraps
from fabric.decorators import _wrap_as_new
from darwin.ec2 import _cloud_hosts
@kszarek
kszarek / fabfile.py
Created October 22, 2014 09:26
Custom task for fabric
class CustomTask(Task):
def __init__(self, func, myarg, *args, **kwargs):
super(CustomTask, self).__init__(*args, **kwargs)
self.func = func
self.myarg = myarg
if env.hosts == []:
logger.debug("env.hosts is empty")
# if hasattr(env, 'env_name'):
logger.debug("Found env_name in env")

Keybase proof

I hereby claim:

  • I am krzysztofszarek on github.
  • I am kszarek (https://keybase.io/kszarek) on keybase.
  • I have a public key whose fingerprint is 3830 FF0B C48D 86FF C8BF 0D40 AACD 88D7 CAD4 A964

To claim this, I am signing this object:

@kszarek
kszarek / java.sh
Created August 20, 2015 20:26
Install Java on Ubuntu
#!/bin/bash
set -xe
echo "Add repository and install java"
apt-get -y install python-software-properties
add-apt-repository -y ppa:webupd8team/java
apt-get -q -y update
apt-get -y upgrade
echo "Accept license"