Slide 1

Slide 1 text

Infrastructure as Code with Chef http://www.fotopedia.com/items/flickr-2572841582

Slide 2

Slide 2 text

Jesse Dearing @JesseDearing Full Stack Developer

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Front-end (HTML, JavaScript) App (Ruby) Data Models (Ruby) Database (PostgreSQL, MySQL) OS (Linux) I work in all these layers Infrastructure as Code and Chef live here

Slide 5

Slide 5 text

I work for

Slide 6

Slide 6 text

Dependency Resolution Time To understand Chef you have to understand Infrastructure as Code

Slide 7

Slide 7 text

Dependency Resolution Time To understand you have to understand Infrastructure as Code Devops

Slide 8

Slide 8 text

Dependency Resolution Time To understand you have to understand Devops writing and running software

Slide 9

Slide 9 text

What is DevOps?

Slide 10

Slide 10 text

Developers and Operations

Slide 11

Slide 11 text

Developers and Operations X vs

Slide 12

Slide 12 text

Fight!

Slide 13

Slide 13 text

Developers ‣Write buggy code ‣Do not develop on systems that look like production ‣Builds features to throw over the wall ‣Think that understanding infrastructure is not their problem Operations ‣Stands in the way of deployments ‣Mostly reactive to issues as alerts are triggered ‣Rolls back code that works on my box™ ‣Think that understanding architecture is not their problem ‣Think that understanding architecture is not their problem ‣Think that understanding infrastructure is not their problem

Slide 14

Slide 14 text

Developers Operations ‣Think that understanding architecture is not their problem ‣Think that understanding infrastructure is not their problem

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

DevOps is about breaking down silos Code inventory (software not deployed to production) has no business value Only shipped code has value Devs and Ops are responsible for shipping Give and take: devs take the pager to assist with software issues and ops codifies processes Dev and Ops need to speak a common language

Slide 17

Slide 17 text

Infrastructure as Code

Slide 18

Slide 18 text

Infrastructure is composed of ๏CPU ๏Memory ๏Network ๏Disks ๏Remote Storage ๏Virtual Machines ๏Policy Configuration ๏Firewalls ๏Services

Slide 19

Slide 19 text

Infrastructure is composed of ๏CPU ๏Memory ๏Network ๏Disks ๏Remote Storage ๏Virtual Machines ๏Policy Configuration ๏Firewalls ๏Services CODE Resources

Slide 20

Slide 20 text

So I just commit all my shell scripts? ಠ_ಠ

Slide 21

Slide 21 text

Shell scripts always need tweaking You can’t run shell scripts against a given criteria of servers Shell scripts take a lot of work to make idempotent There is a better way!

Slide 22

Slide 22 text

Introducing Chef

Slide 23

Slide 23 text

3 ways of using Chef Chef Solo Chef Server Hosted Chef

Slide 24

Slide 24 text

3 ways of using Chef Chef Solo Chef Server Hosted Chef

Slide 25

Slide 25 text

Chef Solo Write resources Recipes, Data Bags, Roles

Slide 26

Slide 26 text

Chef Solo Write resources Execute them Recipes, Data Bags, Roles Chef-solo

Slide 27

Slide 27 text

Chef Solo Write resources Execute them Installs packages, creates files, etc. Recipes, Data Bags, Roles Chef-solo Updates system state

Slide 28

Slide 28 text

Chef Solo Write resources Execute them Installs packages, creates files, etc. Recipes, Data Bags, Roles Chef-solo Updates system state Meh.

Slide 29

Slide 29 text

Only slight improvement over shell scripts But it’s great for testing your Chef scripts before uploading them to the server

Slide 30

Slide 30 text

3 ways of using Chef Chef Solo Chef Server Hosted Chef

Slide 31

Slide 31 text

Node that polls with chef-client chef-server Polls server periodically for run list or data changes

Slide 32

Slide 32 text

Node that polls with chef-client chef-server Also sends back metadata about the node using Ohai

Slide 33

Slide 33 text

Node that polls with chef-client chef-server Also sends back metadata about the node using Ohai My laptop Modify recipes, search nodes, change variables

Slide 34

Slide 34 text

Ohai Gathers metadata from the node to send back to Chef server •Installed languages •CPU •Kernel version •Settings •IP Address •Users •Groups (Oh, hi)

Slide 35

Slide 35 text

3 ways of using Chef Chef Solo Chef Server Hosted Chef

Slide 36

Slide 36 text

OpsCode runs your chef-server

Slide 37

Slide 37 text

user "foobar" file "/etc/service.conf" do mode '0640' owner 'foobar' end package "nginx" execute "/usr/bin/somecommand" Recipe Example

Slide 38

Slide 38 text

Recipes can be shared and committed to source control

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Configuration is stored on the Chef server API keys, passwords, environment/role/instance specific data

Slide 41

Slide 41 text

Let’s see how the MySQL recipe sets the root password

Slide 42

Slide 42 text

Chef’s best friend: He’s a Vagrant

Slide 43

Slide 43 text

Defines VirtualBox VMs Creates using CLI Forwards ports Tears down VMs

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Questions?

Slide 46

Slide 46 text

Thanks!