Skip to content

Instantly share code, notes, and snippets.

View bbl's full-sized avatar

Bogdan bbl

View GitHub Profile
@bbl
bbl / gotchas.md
Last active November 14, 2017 15:16
List of some weirdness and gotchas

Ruby

  1. Outside ENV strings are frozen:

example.rb:

ENV['foo'].strip!

Run:

How to run Chef-Solo programmatically:

require 'chef'
require 'chef/application/solo'

Chef::Config[:solo_legacy_mode] = true
Chef::Config[:cookbook_path] = [File.join(File.absolute_path(File.dirname(__FILE__)), 'cookbooks')]

chef_client = Chef::Application::Solo.new
@bbl
bbl / AWS_SWAP.md
Last active November 14, 2017 15:16
Create and use swap on aws instance (or any other ubuntu machine)

Platform: Ubuntu 16.04

  1. It is common practice to create swap that equals to your RAM. So firstly, you should find out your RAM:
free -m

Which outputs like:

 total used free shared buff/cache available
@bbl
bbl / AWS_ENI_SECONDARY_IP.md
Last active November 14, 2017 15:16
Assign second IP to single elastic interface

This guide assumes you've configured your ENI inside linux instance. After you've assigned second ip address to your ENI in the AWS console, you need to reconfigure your interface inside intance.

Assume your interface name: eth1 Assume your second ip: $second_ip From the guide, mentioned above, the content of /etc/network/interfaces.d/eth1.cfg should look like:

auto eth1
iface eth1 inet static
 address $your_ip_addr
@bbl
bbl / Ruby_delegation.md
Last active November 14, 2017 15:16
Ruby delegation

Use the delegate instance methods flexibly in class:

require 'forwardable'

class MyHash

  extend(Forwardable)

 include(Enumerable)
@bbl
bbl / CHEF_NODE_ATTRIBUTES.md
Last active November 14, 2017 15:16
Chef: add node attributes automatically

Chef: add node attributes automatically

Using knife exec

The best way probably

knife exec -E "nodes.find(:name => 'chef-node') { |node|  node.normal_attrs['some_key'] = 'some_value'; node.save; }"

@bbl
bbl / AWS_ENI_GUIDE.md
Last active March 20, 2018 18:22
How to setup elastic interface on AWS instance.

AMI: ubuntu 16.04

Create and assign ENI
Assume additional interface name: eth1
Assume its private ip: 10.170.224.57
Assume mask: 255.255.0.0 (16)

Inside instance:

  1. Add docker repo
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  1. Update
@bbl
bbl / simple_backup.sh
Last active September 30, 2018 18:34
Example script for "Consul - the swiss knife by Hashicorp" article.
#!/usr/bin/env bash
function perform_backup(){
echo -n "Copying some stuff on S3.."
echo "Done!"
}
perform_backup
@bbl
bbl / Installation.md
Last active December 20, 2018 21:22
Install docker and docker compose on Ubuntu

Lightweight script to install Docker CE and docker-compose on Ubuntu.

To run script simply execute:

curl https://gist.githubusercontent.com/metallica127/a6c1960502ae8ef61782f527eed1e343/raw/51cbf65b1fe1e213725822354ad16c479b928239/install_docker_compose.sh | sudo bash -s