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
680
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
690
Calabash
danielflopes
0
610
Other Decks in Programming
See All in Programming
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
3
490
「テストは愚直&&網羅的に書くほどよい」という誤解 / Test Smarter, Not Harder
munetoshi
0
170
The Modern View Layer Rails Deserves: A Vision For 2025 And Beyond @ RailsConf 2025, Philadelphia, PA
marcoroth
1
170
Porting a visionOS App to Android XR
akkeylab
0
470
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
680
Result型で“失敗”を型にするPHPコードの書き方
kajitack
5
660
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
2
640
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
510
“いい感じ“な定量評価を求めて - Four Keysとアウトカムの間の探求 -
nealle
1
10k
ペアプロ × 生成AI 現場での実践と課題について / generative-ai-in-pair-programming
codmoninc
1
18k
XP, Testing and ninja testing
m_seki
3
250
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
170
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
Building an army of robots
kneath
306
45k
Adopting Sorbet at Scale
ufuk
77
9.5k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
A designer walks into a library…
pauljervisheath
207
24k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
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')