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
670
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
680
Calabash
danielflopes
0
600
Other Decks in Programming
See All in Programming
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
400
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
260
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
210
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
130
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
2
300
童醫院敏捷轉型的實踐經驗
cclai999
0
200
Composerが「依存解決」のためにどんな工夫をしているか #phpcon
o0h
PRO
1
240
ReadMoreTextView
fornewid
1
490
Bytecode Manipulation 으로 생산성 높이기
bigstark
2
390
Team operations that are not burdened by SRE
kazatohiei
1
270
GraphRAGの仕組みまるわかり
tosuri13
8
500
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
170
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
GraphQLとの向き合い方2022年版
quramy
49
14k
Building an army of robots
kneath
306
45k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Site-Speed That Sticks
csswizardry
10
670
Thoughts on Productivity
jonyablonski
69
4.7k
Docker and Python
trallard
44
3.4k
RailsConf 2023
tenderlove
30
1.1k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
800
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
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')