SlideShare a Scribd company logo
Infrastructure as Code
Aybüke Özdemir
@aybuke_ozdemir
Halil Kaya
@halilkaya
Kısa bir örnekle kod tabanlı altyapının önemi
Yeni bir projeye başlıyoruz
Biz Ruby on Rails’ı seçtik
> gem install rails
> gem install rails
Fetching: i18n-0.7.0.gem (100%)
Fetching: json-1.8.3.gem (100%)
Building native extensions. This could take a while…
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
creating Makefile
make
sh: 1: make: not found
Tabii ki önce make’i kurmamız gerek!
> sudo apt-get install make
...
Success!
> gem install rails
> gem install rails
Fetching: nokogiri-1.6.7.2.gem (100%)
Building native extensions. This could take a while…
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0.rc2
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Hmm. Stackoverflow’a baksak iyi olacak sanki...
> sudo apt-get install zlib1g-dev
...
Success!
> gem install rails
> gem install rails
Building native extensions. This could take a while…
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0.rc2
checking for gzdopen() in -lz... yes
checking for iconv... yes
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-pc-linux-
gnu/ports/libxml2/2.9.2... OK
*** extconf.rb failed ***
Infrastructure as code - Python Saati #36
Stackoverflow’da 2 saat geçirdikten sonra...
> gem install rails
> gem install rails
...
Success!
> rails new my-project
> cd my-project
> rails start
> rails new my-project
> cd my-project
> rails start
/source/my-project/bin/spring:11:in `<top (required)>`:
undefined method `path_separator` for Gem:Module
(NoMethodError)
from bin/rails:3:in `load`
from bin/rails:3:in `<main>`
Infrastructure as code - Python Saati #36
… uzunca bir süre sonra
bir şekilde proje çalışır!
Production
Infrastructure as code - Python Saati #36
> bundle update rails
> bundle update rails
Building native extensions. This could take a while…
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0.rc2
checking for gzdopen() in -lz... yes
checking for iconv... yes
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-pc-linux-
gnu/ports/libxml2/2.9.2... OK
*** extconf.rb failed ***
Infrastructure as code - Python Saati #36
Aslında problem Rails ya da Django değil.
Problem sunucuyu elle yapılandırmakta!
Configuration
Management
IAC
Provisioning
Configuration
Management
nginx
conf
- tek tek elle?
- tek tek elle?
- script?
- tek tek elle?
- script?
- scp veya rsync?
- tek tek elle?
- script?
- scp veya rsync?
- tmux cluster ssh?
- tek tek elle?
- script?
- scp veya rsync?
- tmux cluster ssh?
- hosts: production
remote_user: deployment
become: true
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Copy nginx conf file
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
- name: Reload nginx
service:
name: nginx
state: reloaded
- hosts: production
remote_user: deployment
become: true
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Copy nginx conf file
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
- name: Reload nginx
service:
name: nginx
state: reloaded
“production” başlığı altındaki makinalar
- hosts: production
remote_user: deployment
become: true
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Copy nginx conf file
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
- name: Reload nginx
service:
name: nginx
state: reloaded
“deployment” kullanıcısı ile
- hosts: production
remote_user: deployment
become: true
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Copy nginx conf file
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
- name: Reload nginx
service:
name: nginx
state: reloaded
sudo yetkisi ile
- hosts: production
remote_user: deployment
become: true
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Copy nginx conf file
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
- name: Reload nginx
service:
name: nginx
state: reloaded
“nginx” paketini kur
- hosts: production
remote_user: deployment
become: true
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Copy nginx conf file
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
- name: Reload nginx
service:
name: nginx
state: reloaded
önceden hazırlanmış nginx
yapılandırma dosyasını ilgili
yere kopyala
- hosts: production
remote_user: deployment
become: true
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Copy nginx conf file
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
- name: Reload nginx
service:
name: nginx
state: reloaded
nginx servisini reload et
Provisioning
cloud
LoadBalancer
Instance Group
Network
Firewall
Disks & Images
resource “google_compute_instance” “prod-1” {
name = “prod-1”
machine_type = “n1-standard-1”
zone = “europe-west1-d”
boot_disk {
initialize_params {
image = “debian-cloud/debian-8”
}
}
}
resource “google_compute_instance_group” “prod” {
name = “prod”
zone = “europe-west1-d”
instances = [
“${google_compute_instance.prod-1.self_link}”,
]
}
resource “google_compute_instance” “prod-1” {
name = “prod-1”
machine_type = “n1-standard-1”
zone = “europe-west1-d”
boot_disk {
initialize_params {
image = “debian-cloud/debian-8”
}
}
}
resource “google_compute_instance_group” “prod” {
name = “prod”
zone = “europe-west1-d”
instances = [
“${google_compute_instance.prod-1.self_link}”,
]
}
- resource tipi
- resource ismi
- GCE’deki instance ismi
resource “google_compute_instance” “prod-1” {
name = “prod-1”
machine_type = “n1-standard-1” GCE’deki makine tipi
zone = “europe-west1-d”
boot_disk {
initialize_params {
image = “debian-cloud/debian-8”
}
}
}
resource “google_compute_instance_group” “prod” {
name = “prod”
zone = “europe-west1-d”
instances = [
“${google_compute_instance.prod-1.self_link}”,
]
}
resource “google_compute_instance” “prod-1” {
name = “prod-1”
machine_type = “n1-standard-1”
zone = “europe-west1-d” makinenin açılacağı datacenter bölgesi
boot_disk {
initialize_params {
image = “debian-cloud/debian-8”
}
}
}
resource “google_compute_instance_group” “prod” {
name = “prod”
zone = “europe-west1-d”
instances = [
“${google_compute_instance.prod-1.self_link}”,
]
}
resource “google_compute_instance” “prod-1” {
name = “prod-1”
machine_type = “n1-standard-1”
zone = “europe-west1-d”
boot_disk {
initialize_params {
image = “debian-cloud/debian-8” debian 8 imajıyla boot diski oluştur
}
}
}
resource “google_compute_instance_group” “prod” {
name = “prod”
zone = “europe-west1-d”
instances = [
“${google_compute_instance.prod-1.self_link}”,
]
}
resource “google_compute_instance” “prod-1” {
name = “prod-1”
machine_type = “n1-standard-1”
zone = “europe-west1-d”
boot_disk {
initialize_params {
image = “debian-cloud/debian-8”
}
}
}
resource “google_compute_instance_group” “prod” {
name = “prod”
zone = “europe-west1-d”
instances = [ oluşturduğun makineyi
“${google_compute_instance.prod-1.self_link}”, bu instance group’a
] koy
}
> terraform plan
> terraform apply
Faydalar
- tekrar kullanılabilirlik
- otomasyon
- version control
- gözden geçirme
- döküman
- başka bir cloud sistemine geçiş kolaylığı
Olası Sorunlar
- state dosyası!
- araç kullanırken elle yapılandırma!
- hala tam anlamıyla olgunlaşmış değil!
- uygulama yöntemindeki muhtemel sosyal sorunlar!
- var olan bir projeyi IAC’a taşıma(!)
Chef Puppet Ansible SaltStack CloudFormation Terraform
Code Open Source Open Source Open Source Open
Source
Closed Source Open Source
Cloud All All All All AWS Only All
Type Config Mngt Config Mngt Config Mngt Config Mngt Provisioning Provisioning
Infrastructure Mutable Mutable Mutable Mutable Immutable Immutable
Language Procedural Declarative Procedural Declarative Declarative Declarative
Architecture Client/Server Client/Server Client-Only Client/Server Client-Only Client-Only
Infrastructure as code - Python Saati #36
Kaynaklar
- Infrastructure as code: running microservices on
AWS using Docker, Terraform and ECS
- Why we use Terraform and not Chef, Puppet,
Ansible, SaltStack, or CloudFormation
- https://www.ybrikman.com/writing/2016/03/31/i
nfrastructure-as-code-microservices-aws-docker-
terraform-ecs/

More Related Content

PDF
Everything as a code
PPTX
Exploring the Titanium CLI - Codestrong 2012
PPTX
Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013
PDF
Docker command
PDF
Docker remote-api
PDF
Testing your infrastructure with litmus
PDF
MeaNstack on Docker
PDF
How to Begin Developing Ruby Core
Everything as a code
Exploring the Titanium CLI - Codestrong 2012
Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013
Docker command
Docker remote-api
Testing your infrastructure with litmus
MeaNstack on Docker
How to Begin Developing Ruby Core

What's hot (20)

PDF
Ansible 實戰:top down 觀點
PDF
Rhebok, High Performance Rack Handler / Rubykaigi 2015
PDF
mruby で mackerel のプラグインを作るはなし
PDF
Composer, putting dependencies on the score
PDF
Fabric workshop(1) - (MOSG)
PDF
Practical Testing of Ruby Core
PDF
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
PDF
Securing Prometheus exporters using HashiCorp Vault
PDF
DevOps(3) : Ansible - (MOSG)
PDF
kubernetes practice
PPTX
Docker practice
PDF
Vagrant + Rouster at salesforce.com - PuppetConf 2013
PPTX
Real World Lessons on the Pain Points of Node.js Applications
PDF
Configuring Django projects for multiple environments
PDF
Nodejs Explained with Examples
PDF
Statyczna analiza kodu PHP
PDF
Puppet and the HashiStack
KEY
Plack - LPW 2009
PDF
Vagrant for real (codemotion rome 2016)
PDF
Preparation study of_docker - (MOSG)
Ansible 實戰:top down 觀點
Rhebok, High Performance Rack Handler / Rubykaigi 2015
mruby で mackerel のプラグインを作るはなし
Composer, putting dependencies on the score
Fabric workshop(1) - (MOSG)
Practical Testing of Ruby Core
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
Securing Prometheus exporters using HashiCorp Vault
DevOps(3) : Ansible - (MOSG)
kubernetes practice
Docker practice
Vagrant + Rouster at salesforce.com - PuppetConf 2013
Real World Lessons on the Pain Points of Node.js Applications
Configuring Django projects for multiple environments
Nodejs Explained with Examples
Statyczna analiza kodu PHP
Puppet and the HashiStack
Plack - LPW 2009
Vagrant for real (codemotion rome 2016)
Preparation study of_docker - (MOSG)
Ad

Recently uploaded (20)

PDF
Digital Strategies for Manufacturing Companies
PDF
System and Network Administraation Chapter 3
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
history of c programming in notes for students .pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Introduction to Artificial Intelligence
PPTX
L1 - Introduction to python Backend.pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
System and Network Administration Chapter 2
PPTX
assetexplorer- product-overview - presentation
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
Digital Strategies for Manufacturing Companies
System and Network Administraation Chapter 3
How to Migrate SBCGlobal Email to Yahoo Easily
history of c programming in notes for students .pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Operating system designcfffgfgggggggvggggggggg
Introduction to Artificial Intelligence
L1 - Introduction to python Backend.pptx
How to Choose the Right IT Partner for Your Business in Malaysia
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Design an Analysis of Algorithms II-SECS-1021-03
CHAPTER 2 - PM Management and IT Context
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
System and Network Administration Chapter 2
assetexplorer- product-overview - presentation
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
2025 Textile ERP Trends: SAP, Odoo & Oracle
Ad

Infrastructure as code - Python Saati #36

  • 1. Infrastructure as Code Aybüke Özdemir @aybuke_ozdemir Halil Kaya @halilkaya
  • 2. Kısa bir örnekle kod tabanlı altyapının önemi
  • 3. Yeni bir projeye başlıyoruz
  • 4. Biz Ruby on Rails’ı seçtik
  • 6. > gem install rails Fetching: i18n-0.7.0.gem (100%) Fetching: json-1.8.3.gem (100%) Building native extensions. This could take a while… ERROR: Error installing rails: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb creating Makefile make sh: 1: make: not found
  • 7. Tabii ki önce make’i kurmamız gerek!
  • 8. > sudo apt-get install make ... Success!
  • 10. > gem install rails Fetching: nokogiri-1.6.7.2.gem (100%) Building native extensions. This could take a while… ERROR: Error installing rails: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. Using mini_portile version 2.0.0.rc2 checking for gzdopen() in -lz... no zlib is missing; necessary for building libxml2 *** extconf.rb failed ***
  • 11. Hmm. Stackoverflow’a baksak iyi olacak sanki...
  • 12. > sudo apt-get install zlib1g-dev ... Success!
  • 13. > gem install rails
  • 14. > gem install rails Building native extensions. This could take a while… ERROR: Error installing rails: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. Using mini_portile version 2.0.0.rc2 checking for gzdopen() in -lz... yes checking for iconv... yes Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-pc-linux- gnu/ports/libxml2/2.9.2... OK *** extconf.rb failed ***
  • 16. Stackoverflow’da 2 saat geçirdikten sonra...
  • 17. > gem install rails
  • 18. > gem install rails ... Success!
  • 19. > rails new my-project > cd my-project > rails start
  • 20. > rails new my-project > cd my-project > rails start /source/my-project/bin/spring:11:in `<top (required)>`: undefined method `path_separator` for Gem:Module (NoMethodError) from bin/rails:3:in `load` from bin/rails:3:in `<main>`
  • 22. … uzunca bir süre sonra bir şekilde proje çalışır!
  • 26. > bundle update rails Building native extensions. This could take a while… ERROR: Error installing rails: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. Using mini_portile version 2.0.0.rc2 checking for gzdopen() in -lz... yes checking for iconv... yes Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-pc-linux- gnu/ports/libxml2/2.9.2... OK *** extconf.rb failed ***
  • 28. Aslında problem Rails ya da Django değil. Problem sunucuyu elle yapılandırmakta!
  • 32. - tek tek elle?
  • 33. - tek tek elle? - script?
  • 34. - tek tek elle? - script? - scp veya rsync?
  • 35. - tek tek elle? - script? - scp veya rsync? - tmux cluster ssh?
  • 36. - tek tek elle? - script? - scp veya rsync? - tmux cluster ssh?
  • 37. - hosts: production remote_user: deployment become: true tasks: - name: Install nginx apt: name: nginx state: present - name: Copy nginx conf file template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf - name: Reload nginx service: name: nginx state: reloaded
  • 38. - hosts: production remote_user: deployment become: true tasks: - name: Install nginx apt: name: nginx state: present - name: Copy nginx conf file template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf - name: Reload nginx service: name: nginx state: reloaded “production” başlığı altındaki makinalar
  • 39. - hosts: production remote_user: deployment become: true tasks: - name: Install nginx apt: name: nginx state: present - name: Copy nginx conf file template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf - name: Reload nginx service: name: nginx state: reloaded “deployment” kullanıcısı ile
  • 40. - hosts: production remote_user: deployment become: true tasks: - name: Install nginx apt: name: nginx state: present - name: Copy nginx conf file template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf - name: Reload nginx service: name: nginx state: reloaded sudo yetkisi ile
  • 41. - hosts: production remote_user: deployment become: true tasks: - name: Install nginx apt: name: nginx state: present - name: Copy nginx conf file template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf - name: Reload nginx service: name: nginx state: reloaded “nginx” paketini kur
  • 42. - hosts: production remote_user: deployment become: true tasks: - name: Install nginx apt: name: nginx state: present - name: Copy nginx conf file template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf - name: Reload nginx service: name: nginx state: reloaded önceden hazırlanmış nginx yapılandırma dosyasını ilgili yere kopyala
  • 43. - hosts: production remote_user: deployment become: true tasks: - name: Install nginx apt: name: nginx state: present - name: Copy nginx conf file template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf - name: Reload nginx service: name: nginx state: reloaded nginx servisini reload et
  • 46. resource “google_compute_instance” “prod-1” { name = “prod-1” machine_type = “n1-standard-1” zone = “europe-west1-d” boot_disk { initialize_params { image = “debian-cloud/debian-8” } } } resource “google_compute_instance_group” “prod” { name = “prod” zone = “europe-west1-d” instances = [ “${google_compute_instance.prod-1.self_link}”, ] }
  • 47. resource “google_compute_instance” “prod-1” { name = “prod-1” machine_type = “n1-standard-1” zone = “europe-west1-d” boot_disk { initialize_params { image = “debian-cloud/debian-8” } } } resource “google_compute_instance_group” “prod” { name = “prod” zone = “europe-west1-d” instances = [ “${google_compute_instance.prod-1.self_link}”, ] } - resource tipi - resource ismi - GCE’deki instance ismi
  • 48. resource “google_compute_instance” “prod-1” { name = “prod-1” machine_type = “n1-standard-1” GCE’deki makine tipi zone = “europe-west1-d” boot_disk { initialize_params { image = “debian-cloud/debian-8” } } } resource “google_compute_instance_group” “prod” { name = “prod” zone = “europe-west1-d” instances = [ “${google_compute_instance.prod-1.self_link}”, ] }
  • 49. resource “google_compute_instance” “prod-1” { name = “prod-1” machine_type = “n1-standard-1” zone = “europe-west1-d” makinenin açılacağı datacenter bölgesi boot_disk { initialize_params { image = “debian-cloud/debian-8” } } } resource “google_compute_instance_group” “prod” { name = “prod” zone = “europe-west1-d” instances = [ “${google_compute_instance.prod-1.self_link}”, ] }
  • 50. resource “google_compute_instance” “prod-1” { name = “prod-1” machine_type = “n1-standard-1” zone = “europe-west1-d” boot_disk { initialize_params { image = “debian-cloud/debian-8” debian 8 imajıyla boot diski oluştur } } } resource “google_compute_instance_group” “prod” { name = “prod” zone = “europe-west1-d” instances = [ “${google_compute_instance.prod-1.self_link}”, ] }
  • 51. resource “google_compute_instance” “prod-1” { name = “prod-1” machine_type = “n1-standard-1” zone = “europe-west1-d” boot_disk { initialize_params { image = “debian-cloud/debian-8” } } } resource “google_compute_instance_group” “prod” { name = “prod” zone = “europe-west1-d” instances = [ oluşturduğun makineyi “${google_compute_instance.prod-1.self_link}”, bu instance group’a ] koy }
  • 52. > terraform plan > terraform apply
  • 53. Faydalar - tekrar kullanılabilirlik - otomasyon - version control - gözden geçirme - döküman - başka bir cloud sistemine geçiş kolaylığı
  • 54. Olası Sorunlar - state dosyası! - araç kullanırken elle yapılandırma! - hala tam anlamıyla olgunlaşmış değil! - uygulama yöntemindeki muhtemel sosyal sorunlar! - var olan bir projeyi IAC’a taşıma(!)
  • 55. Chef Puppet Ansible SaltStack CloudFormation Terraform Code Open Source Open Source Open Source Open Source Closed Source Open Source Cloud All All All All AWS Only All Type Config Mngt Config Mngt Config Mngt Config Mngt Provisioning Provisioning Infrastructure Mutable Mutable Mutable Mutable Immutable Immutable Language Procedural Declarative Procedural Declarative Declarative Declarative Architecture Client/Server Client/Server Client-Only Client/Server Client-Only Client-Only
  • 57. Kaynaklar - Infrastructure as code: running microservices on AWS using Docker, Terraform and ECS - Why we use Terraform and not Chef, Puppet, Ansible, SaltStack, or CloudFormation - https://www.ybrikman.com/writing/2016/03/31/i nfrastructure-as-code-microservices-aws-docker- terraform-ecs/