Problem | AWS | DigitalOcean |
---|---|---|
Network isolation | Private Cloud/Security Groups | tinc / n2n / freelan |
Node initialization | CloudInit/User Data | ? |
Node discovery | EC2 API | Serf |
Pull app on scale | More Like This | Serf |
Distributed config | etcd | etcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
alias_method :bar, | |
def foo | |
:hello | |
end | |
end | |
Foo.new.bar # => :hello |
Upon launch of custom base box intended as app behind load balancer:
- [serf] join cluster, update lists
- update local iptables
- [serf] announce presence (already part of step 1?)
- provision self (chef/ansible/docker/etc)
- pull app (deploy to self from git, deb, docker, could be part of step 4?)
- [serf] announce online
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Permissions cheatsheet | |
`chmod [a]bcd` | |
* bit a — sticky:1/setgid:2/setuid:4 (optional, default: 0) | |
* bit b — owner | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 | |
* bit c — group | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 | |
* bit d — everyone | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 | |
note: only file/dir owner can chmod it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'yaml' | |
PLAYS_DIR = '.' | |
ROLES_DIR = './roles' | |
def deps_of(role) | |
dep_path = File.join(ROLES_DIR, "#{role}/meta/main.yml") | |
File.exists?(dep_path) ? (YAML.load_file(dep_path)['dependencies'] || []) : [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jinja2 import contextfilter | |
class FilterModule(object): | |
''' Extra filters ''' | |
def filters(self): | |
return { | |
'percent_of': self.percent_of, | |
'of_ram': self.of_ram | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rack', github: 'rack/rack' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INFO[7bdf78e4] Running /usr/bin/env /home/deployer/deploy.sh on util1.example.org | |
DEBUG[7bdf78e4] Command: /usr/bin/env /home/deployer/deploy.sh | |
DEBUG[7bdf78e4] fetching | |
DEBUG[7bdf78e4] fetching | |
DEBUG[7bdf78e4] From github.com:example/example | |
DEBUG[7bdf78e4] fetching | |
DEBUG[7bdf78e4] 36d03e8..52fa872d feature/foo -> origin/feature/foo | |
DEBUG[7bdf78e4] fetching | |
DEBUG[7bdf78e4] 4372c38..79bba2b master -> origin/master | |
DEBUG[7bdf78e4] HEAD is now at 79bba2b Merge pull request #111 from example/fix/bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController | |
helper_method :current_copywriting | |
def current_copywriting | |
@current_copywriting ||= Copywriting.find_by_request(request) | |
end | |
end | |
module SomeHelpers | |
def header_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# {{ ansible_managed }} | |
require 'puma_worker_killer' | |
daemonize false | |
directory '/srv/{{ app_name }}' | |
threads {{ puma_threads_min }}, {{ puma_threads_max }} | |
workers {{ ansible_processor_vcpus }} | |
bind 'unix:///var/run/{{ app_name }}/{{ app_name }}.sock' | |
prune_bundler |
OlderNewer