Skip to content

Instantly share code, notes, and snippets.

Bogdan metallica127

Block or report user

Report or block metallica127

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DOCKER_OVERLAY.md

Network

We need a global docker network in order to communicate between docker-compose setups on different hosts

Step 1: Install and run Consul (as a key-value storage for docker)

https://www.consul.io/intro/getting-started/install.html

Step 2: Edit docker configuration (on each docker host)

@metallica127
metallica127 / gotchas.md
Last active Nov 14, 2017
List of some weirdness and gotchas
View gotchas.md

Ruby

  1. Outside ENV strings are frozen:

example.rb:

ENV['foo'].strip!

Run:

View CHEF_SOLO_PROGRAMMATICALLY.md

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
View DOCKER_PUBLIC_IP.md

Actually, it's a guide to setup docker macvlan network and it can be used to attach static ip to container on public/local network.

  1. Create docker public network:
docker network create -d macvlan --subnet=$SUBNET --gateway=$GATEWAY_IP -o parent=eth0 public

Where:
$SUBNET - your public network subnet
$GATEWAY_IP - your public network gateway

@metallica127
metallica127 / AWS_SWAP.md
Last active Nov 14, 2017
Create and use swap on aws instance (or any other ubuntu machine)
View AWS_SWAP.md

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
View Install_docker_specific_version.md
  1. Add docker repo
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  1. Update
@metallica127
metallica127 / AWS_ENI_SECONDARY_IP.md
Last active Nov 14, 2017
Assign second IP to single elastic interface
View AWS_ENI_SECONDARY_IP.md

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
@metallica127
metallica127 / AWS_ENI_GUIDE.md
Last active Mar 20, 2018
How to setup elastic interface on AWS instance.
View AWS_ENI_GUIDE.md

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:

View Ruby_delegation.md

Use the delegate instance methods flexibly in class:

require 'forwardable'

class MyHash

  extend(Forwardable)

  include(Enumerable)
@metallica127
metallica127 / CHEF_NODE_ATTRIBUTES.md
Last active Nov 14, 2017
Chef: add node attributes automatically
View CHEF_NODE_ATTRIBUTES.md

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; }"

You can’t perform that action at this time.