Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Automating infrastructure with ruby - Tiago Macedo
Search
Daniel Lopes
October 11, 2013
Programming
0
520
Automating infrastructure with ruby - Tiago Macedo
Slide deck used by Tiago Macedo on Coimbra.rb (organized by
http://whitesmith.co
)
Daniel Lopes
October 11, 2013
Tweet
Share
More Decks by Daniel Lopes
See All by Daniel Lopes
RubyMotion - Ruby for iOS
danielflopes
0
550
Calabash
danielflopes
0
470
Other Decks in Programming
See All in Programming
선언형 UI에서의 상태관리
l2hyunwoo
0
240
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
360
Jaspr Dart Web Framework 박제창 @Devfest 2024
itsmedreamwalker
0
120
週次リリースを実現するための グローバルアプリ開発
tera_ny
1
120
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
310
良いユニットテストを書こう
mototakatsu
11
3.4k
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
9
2.2k
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
190
快速入門可觀測性
blueswen
0
460
情報漏洩させないための設計
kubotak
4
1.1k
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
370
CloudflareStack でRAGに入門
asahiiwm
0
140
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Why Our Code Smells
bkeepers
PRO
335
57k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Practical Orchestrator
shlominoach
186
10k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Bash Introduction
62gerente
609
210k
The Cult of Friendly URLs
andyhume
78
6.1k
Into the Great Unknown - MozCon
thekraken
34
1.6k
GraphQLとの向き合い方2022年版
quramy
44
13k
Documentation Writing (for coders)
carmenintech
67
4.5k
Transcript
Automating Infrastructure with Ruby
DevOps
• Repeatability • Automation • Agility • Scalability • Reassurance
• Disaster Recovery Infrastructure as Code Test-Driven Infrastructure with Chef By Stephen Nelson-Smith
Configuration Management
Puppet package { 'apache2': provider=>'apt', ensure=>'installed' } service { 'apache2':
ensure=>'running' }
Chef package 'apache2' service 'apache2' do action [ :enable, :start
] end
Chef %w(mysql-server apache2).each do |s| package s service s do
action [ :enable, :start ] end end
Chef ruby_block "add users to passwords file" do block do
require 'webrick/httpauth/htpasswd' passwd = WEBrick::HTTPAuth::Htpasswd.new(nginx[:pass_file]) nginx[:users].each do |u| passwd.set_passwd( 'Auth', u['username'], u['password'] ) end passwd.flush end end
Chef name "varnish" description "Varnish caching proxy for Solr" run_list
'varnish' default_attributes( :varnish => { :malloc => '3G', :backend => { :nodes => Configuration::Server.all.select { |s| s.solr_slave? && s.production? }.map{|s| s.name}, :port => 30002 } } )
Chef { "run_list" : [ "role[staging_server]" ], "database_config" : {
"staging" : { "database" : "staging", "adapter" : "mysql2", "reconnect" : "true", "host" : "localhost", "username" : "staging", "encoding" : "utf8" } } }
Chef server "lisbon", :staging_server do natted! attributes( :database_config => {
:staging => { :adapter => "mysql2", :database => "staging", :encoding => "utf8", :reconnect => "true", :username => "staging", :host => "localhost" } } ) end
Chef package 'haproxy' template '/etc/haproxy/haproxy.cfg' do variables :port => 80
owner 'haproxy' end service 'haproxy' do action [:start] end
Chef package 'nginx' template '/etc/nginx/nginx.cfg' do variables :port => 80
owner 'nginx' end service 'nginx' do action [:start] end
Chef file '/home/user/scripts/remove_some_file' do content “rm some_random_file“ end file '/home/user/scripts/remove_some_file'
do action :delete end
• VMs • OpenVZ • Docker Immutable Infrastructure / Deployments
Vagrant
Capistrano config/deploy/vagrant.rb ssh_options[:port] = 2222 server 'localhost', :web, :app cap
vagrant deploy
fog
Bootstrapping Fog::Compute.new(credentials).servers.create( flavor_id: flavor_id, image_id: image_id, name: name, public_key_path: ssh_key_path
)
Load Balancers elb = Fog::AWS::ELB.new(credentials) listener = {'Protocol' => 'HTTP',
'LoadBalancerPort' => 80, 'InstancePort' => 80, 'InstanceProtocol' => 'HTTP'} elb.create_load_balancer('us-east-1a', 'my-elb',[listener]) ids = Fog::Compute.new(credentials).servers.map {|s| s.id} elb.register_instances_with_load_balancer(ids, 'my-elb')
DNS dns = Fog::DNS.new(credentials) zone = dns.zones.get('mydomain.com') zone.records.create( :name =>
'foo.mydomain.com', :value => '127.0.0.1', :type => 'A')