Slide 1

Slide 1 text

ANSIBLE & DOCKER The Path to Continuous Delivery Part 1

Slide 2

Slide 2 text

Demi ➜ infrastructure git:(master) bin/ap create_droplet.yml hosts -c local PLAY [Digital Ocean] ********************************************************** GATHERING FACTS *************************************************************** TASK: [Create DigitalOcean droplet] ******************************************* PLAY RECAP ******************************************************************** localhost : ok=1 changed=1 unreachable=0 failed=0

Slide 3

Slide 3 text

55” 1’ 25” Create DO 2GB AMS2 droplet

Slide 4

Slide 4 text

Don’t write cookbooks, just play

Slide 5

Slide 5 text

Changed. Skipped. OK.

Slide 6

Slide 6 text

Demi ➜ infrastructure git:(master) bin/ap dod.yml dohosts -u root PLAY [Digital Ocean Docker] *************************************************** GATHERING FACTS *************************************************************** TASK: [base | Install common system packages via apt] ************************* TASK: [base | NTP client] ***************************************************** TASK: [base | Sudo group] ***************************************************** TASK: [base | Docker group] *************************************************** TASK: [base | Create gerhard user] ******************************************** TASK: [base | gerhard SSH key] ************************************************ TASK: [base | root SSH key] *************************************************** TASK: [base | Sudoers don't need a password] ********************************** TASK: [base | Sudoers have their ssh agent forwarded] ************************* TASK: [base | Add github.com to known hosts] ********************************** TASK: [base | Make vim the default editor] ************************************ TASK: [base | Common bash aliases] ******************************************** TASK: [docker | Add docker apt repository key] ******************************** TASK: [docker | Add docker apt repository] ************************************ TASK: [docker | Install latest docker] **************************************** TASK: [docker | Start docker on boot] ***************************************** TASK: [docker | Docker aliases] *********************************************** TASK: [nginx | Add nginx PPA repository] ************************************** TASK: [nginx | Install nginx] ************************************************* TASK: [nginx | Customize nginx default configuration] ************************* TASK: [nginx | Start nginx on boot] ******************************************* PLAY RECAP ******************************************************************** 95.85.53.185 : ok=2 changed=23 unreachable=0 failed=0

Slide 7

Slide 7 text

1’ 50” Base system setup

Slide 8

Slide 8 text

nginx As special as dockerd

Slide 9

Slide 9 text

Demi ➜ infrastructure git:(master) bin/ap terrabox.yml dohosts -l docker-ams2 PLAY [terrabox app - Rails] *************************************************** GATHERING FACTS *************************************************************** TASK: [terrabox | Update app repository] ************************************** TASK: [terrabox | Dependent containers] *************************************** TASK: [terrabox | Check MySQL data container] ********************************* TASK: [terrabox | Build MySQL data container] ********************************* TASK: [terrabox | Check MySQL container status] ******************************* TASK: [terrabox | Remove MySQL container with same name] ********************** TASK: [terrabox | Start new MySQL container] ********************************** TASK: [terrabox | Check Redis container status] ******************************* TASK: [terrabox | Remove Redis container with same name] ********************** TASK: [terrabox | Start new Redis container] ********************************** TASK: [terrabox | Ensure we have the latest app master image] ***************** TASK: [terrabox | Ensure app branch image builds from master image] *********** TASK: [terrabox | Ensure app branch image exists] ***************************** TASK: [terrabox | Build app branch image] ************************************* TASK: [terrabox | Ensure all tests pass] ************************************** TASK: [terrabox | Check app container status] ********************************* TASK: [terrabox | Remove app container if stopped (name collision)] *********** TASK: [terrabox | Start new app container] ************************************ TASK: [terrabox | Find app container public port] ***************************** TASK: [terrabox | Update nginx production vhost ] ***************************** TASK: [terrabox | Update DNS production record ] ****************************** TASK: [terrabox | Notify HipChat of new production container ] **************** TASK: [terrabox | Reload nginx ] ********************************************** PLAY RECAP ******************************************************************** 95.85.53.185 : ok=5 changed=18 unreachable=0 failed=0

Slide 10

Slide 10 text

8’ 16” Rails, MySQL & Redis containers (no local Docker images)

Slide 11

Slide 11 text

Dependent containers Branch-specific

Slide 12

Slide 12 text

Test-only containers Hello CI

Slide 13

Slide 13 text

Demi ➜ infrastructure git:(master) bin/ap terrabox.yml dohosts -l docker-ams2 -e ‘app_branch=gem_updates’ PLAY [terrabox app - Rails] *************************************************** GATHERING FACTS *************************************************************** TASK: [terrabox | Update app repository] ************************************** TASK: [terrabox | Dependent containers] *************************************** TASK: [terrabox | Check MySQL data container] ********************************* TASK: [terrabox | Build MySQL data container] ********************************* TASK: [terrabox | Check MySQL container status] ******************************* TASK: [terrabox | Remove MySQL container with same name] ********************** TASK: [terrabox | Start new MySQL container] ********************************** TASK: [terrabox | Check Redis container status] ******************************* TASK: [terrabox | Remove Redis container with same name] ********************** TASK: [terrabox | Start new Redis container] ********************************** TASK: [terrabox | Ensure we have the latest app master image] ***************** TASK: [terrabox | Ensure app branch image builds from master image] *********** TASK: [terrabox | Ensure app branch image exists] ***************************** TASK: [terrabox | Build app branch image] ************************************* TASK: [terrabox | Ensure all tests pass] ************************************** TASK: [terrabox | Check app container status] ********************************* TASK: [terrabox | Remove app container if stopped (name collision)] *********** TASK: [terrabox | Start new app container] ************************************ TASK: [terrabox | Find app container public port] ***************************** TASK: [terrabox | Update nginx branch vhost ] ********************************* TASK: [terrabox | Update DNS branch record ] ********************************** TASK: [terrabox | Notify HipChat of new production container ] **************** TASK: [terrabox | Reload nginx ] ********************************************** PLAY RECAP ******************************************************************** 95.85.53.185 : ok=4 changed=19 unreachable=0 failed=0

Slide 14

Slide 14 text

2’ 23” Rails, MySQL & Redis containers (with local Docker images)

Slide 15

Slide 15 text

3.46x Rails, MySQL & Redis containers (with local Docker images)

Slide 16

Slide 16 text

ENVIRONMENTS How many do I really need?

Slide 17

Slide 17 text

PRODUCTION

Slide 18

Slide 18 text

PRODUCTION Development

Slide 19

Slide 19 text

PRODUCTION Development Integration

Slide 20

Slide 20 text

PRODUCTION Development Staging Integration

Slide 21

Slide 21 text

PRODUCTION Development Staging Integration QA

Slide 22

Slide 22 text

PRODUCTION Development Staging Integration Beta QA

Slide 23

Slide 23 text

PRODUCTION Development Staging Integration Beta QA Mooo

Slide 24

Slide 24 text

[branch].[fqdn] NOT Production

Slide 25

Slide 25 text

[fqdn] Production

Slide 26

Slide 26 text

git branch mentality K.I.S.S.

Slide 27

Slide 27 text

master == production

Slide 28

Slide 28 text

branch != production

Slide 29

Slide 29 text

THINGS I LIKE

Slide 30

Slide 30 text

container == process Single Responsibility Principle

Slide 31

Slide 31 text

container != VM Single Responsibility Principle

Slide 32

Slide 32 text

Data-only containers Single Responsibility Principle

Slide 33

Slide 33 text

Dependent containers .docker.[service]

Slide 34

Slide 34 text

Test-only containers Docker, the simple CI

Slide 35

Slide 35 text

DNS service discovery Instant DNS updates are real

Slide 36

Slide 36 text

Chat notifications Tell me when it’s done

Slide 37

Slide 37 text

WHAT’S NEXT?

Slide 38

Slide 38 text

Clean-up Old containers & images

Slide 39

Slide 39 text

Private registry Build images once, re-use

Slide 40

Slide 40 text

Data-only containers Back-up & Restore

Slide 41

Slide 41 text

Previous instances Backup upstream entries

Slide 42

Slide 42 text

GitHub hooks Real Continuous Delivery

Slide 43

Slide 43 text

Container supervision exec it

Slide 44

Slide 44 text

AND AFTER THAT?

Slide 45

Slide 45 text

Multi-host Redundancy & Scalability

Slide 46

Slide 46 text

Chat ops Everyone on the team can do it

Slide 47

Slide 47 text

gerhardlazu Thank you