WordPress DevOps
For Beginners
http://poweredbycoffee.co.uk
Stewart Ritchie
@stewartritchie
stewart@poweredbycoffee.co.uk
This is NOT
a Tutorial
http://poweredbycoffee.co.uk
This is a guide to dev ops for beginners. You’ve probably heard talks about this stuff before. aimed at technical tutorial instead of a 101 - why should you care

This talk is for 

- beginners to devops, 

- devs who want to start to improve their productivity and quality

- business owners who hear developers talking about stuff the don't understand and want to up their understanding

- pm’s who want more control and efficiency
What is Dev Ops
anyway?
http://poweredbycoffee.co.uk
Asked my friends Andy, works for Sky on Now TV as a Scrum Master

Dev Ops is a very simple concept at its heart. 

Its not a technology.

its not a cure all to your problems. 

Investment. Spent time now 

- create development project processes 

- that save time later

- improve efficiency 

- improve happiness

- and improve your over all project outcome. (Quality/Time to market/Profitability)

IE - Devs spend more time developing.
Why is Dev Ops
Important?
http://poweredbycoffee.co.uk
why does it provide value? no value - no point

1. dev

2. bus

3. comm
1. DevOps will make you a
better developer.
http://poweredbycoffee.co.uk
- You’ll learn to structure your code in more reusable, 

- your learn how do write code that can be tested

- you’ll learn to think about performance and failure of the code you write

1. collaborate with other developers

2. reduce the risk of trying new techniques

3. improve the quality of your code

4. Help developers do more development and less system administration

5. bring new people into a project quickly.
2. DevOps will help you
deliver better work to your
clients
http://poweredbycoffee.co.uk
You will be able to deliver faster, iterate faster, involve your clients in your process more.

Talk about deployments/Continuous Integration

-Make it hard or almost impossible to have a bug get in production

1. If you do have a problem, your recovery time will be slashed.

2. Make everyone on your team more efficient 

3. faster iteration cycle

4. better data mining and monitoring of systems
3. DevOps helps move
WordPress into bigger
companies and
opportunities
http://poweredbycoffee.co.uk
DevOps bring reliability, repeatability and lowers risk.

WordPress == Wild West - a toy/hobby. DevOps brings respectability.

scaleability

reliability

predicable and repeatable
How Does Dev Ops Help?
http://poweredbycoffee.co.uk
1. Collaboration
2. Code Sharing
3. Automation
1. Collaboration
http://poweredbycoffee.co.uk
Work together better.

teams grow,projects grow, more and more people will need involved

Bad collaboration can kill projects dead

Developer collaboration is hard
Version Control
http://poweredbycoffee.co.uk
Easy for developers to collaborate
A hardened nuclear bunker for your source code
Makes it easy to have more that one version of your project!
Basically a time machine
- version control

	 - gives us a way to manage code and version that gets it off your laptop

	 - code is a shared resource and changes should not be made 'willy nilly"

	 - similar to version on the mac or even time machine

	 	 you can go back in time to a point in your project
What is a “Commit”?
http://poweredbycoffee.co.uk
- Snapshot of code

- the difference since the last snapshot, layer them up and you get a project

- a commit should include a defined piece of work

	 	 - bug fix

	 	 - a change that had a purpose

	 	 - made changes that you dont want to keep? revet to the last commit.
http://poweredbycoffee.co.uk
This layering gives us a log of the project over time

See how files changed
Merging Version Control
http://poweredbycoffee.co.uk
- Gives you the ability to manage different versions of your software
- Development, Staging & Production
- Approve code to move up the versions into production
The real killer feature is that your code base can exits in different states. This comes from “Branching”

1. you can see here every dot is a commit. 

2. At this commit you made a deployement

3. you keep commiting until some one finds a bug - you;ve been working on the project in the mean time, added half a dozen unfinished features you fix the bug in your
deployed version. Now you need to unpick the new features or download
http://poweredbycoffee.co.uk
http://poweredbycoffee.co.uk
http://poweredbycoffee.co.uk
http://poweredbycoffee.co.uk
http://poweredbycoffee.co.uk
2. Code Sharing
http://poweredbycoffee.co.uk
all projects have code that they didn’t create in them
Dependencies
http://poweredbycoffee.co.uk
- every software project is built on the shoulders of those that came before it. 

- starting fro scratch again would be irresponsible and wasteful

- PHP is a dependency (basically a piece of software written in C), mysql and a webserver

- we do not want to have to manage code we didn’t create, do not commit that

- multiple kinds of dependencies to manage (production/dev) software
WordPress Has
Dependencies
http://poweredbycoffee.co.uk
- Diff by Geoffrey T. Bairiki
- ID3 by James Heinrich
- BackBone & Underscores
The Problem with
dependancies is that they
can change
http://poweredbycoffee.co.uk
- The problem with dependancies is that they change

	 - Writing software is hard, using extenal dependancies is hard.

	 	 - they change. Features get added or removed

	 - Building a house with a foundation of sand

	 - the sand/dependency changes and the house can fall down

	 - by targeting a specific version of a library or a dependancy you can stop this happening

	 - then update when you know its safe (SEMVER - FTW)

	 - dependencies can have their own dependencies
What About Your Project?
http://poweredbycoffee.co.uk
	 - WordPress is a dependancy. Its a library that your are writing software against

	 - So are all your plugins, themes, libraries etc etc

	 - any libraries you add are dependencies (PHP/JS/CSS)

	 - You are creating something that depends on these - that is a risk
Your Dependancies
- have dependencies
http://poweredbycoffee.co.uk
	 - WordPress is a dependancy. Its a library that your are writing software against

	 - So are all your plugins, themes, libraries etc etc

	 - any libraries you add are dependencies (PHP/JS/CSS)

	 - You are creating something that depends on these - that is a risk

- Different kinds of dependencies

	 - production dependencies

	 	 - stuff needed to make the site run

	 - dev dependencies

	 	 - helpers and devtool
What About Your Project?
http://poweredbycoffee.co.uk
- Story of Smallbusiness.co.uk

	 - using Timber (with routing)

	 	 - timber goes v1 all fine

	 	 - timber goes v1.1 site falls apart

	 	 	 - routing was removed

	 	 - wordpress updates to 4.6 and falls apart

	 	 - dependencies to blame

	 	 	 - installed routes -> installed wpcli -> requests

	 	 	 - requests got included in wp 4.6 hence a conflict

	 	 	 - site collapses
This Sounds Like a
Nightmare
http://poweredbycoffee.co.uk
- managing all this manually shounds like a nightmare

	 - install the librarys/whatever you tell it to in the version you tell it to

	 - install all the things you need to run that thing as well. And the correct versions for it.

	 - This is pretty cool

	 	 - keeps your team using the same things

	 	 - recorded in a file so you dont have to store them in your repo

You’ve probably already done something similar installing grunt/gulp/sass etc
getcomposer.org
- composer

	 	 	 - composer.json

	 	 	 - WordPress and composer are not natural friends

	 	 	 - we need to move everything that might change in our repo out of the wordpress folder

	 	 	 	 - htaccess

	 	 	 	 - wp-config.php

	 	 	 	 - wp-content

	 	 	 - many good tutorials on the web for this

	 	 	 - configure composer to work

	 	 	 - get plugins and themes from github, packaginst and wp-packagist

	 	 	 - satispress for premium plugins

	 	 	 - wordpress maybe becoming a package - composer.json trac ticket
- get plugins and themes from github, packaginst and wp-packagist
- satispress for premium plugins
Composer & WordPress
http://poweredbycoffee.co.uk
https://core.trac.wordpress.org/ticket/23912
https://core.trac.wordpress.org/ticket/36335
WordPress may be becoming a composer package
bower.io
- bower for JS

	 	 	 - much simpler

	 	 	 - load JS however you want
Can Bite You
http://poweredbycoffee.co.uk
LeftPad

Cache stuff, mirror critical dependancies
Easy Ways To Get Started
http://poweredbycoffee.co.uk
- write stuff as small plugins

	 - version control the plugin and use your repeats in projects

	 - eg

	 	 - wpmail-mailgun

	 	 - envswitch

	 	 - disable xmlrpc

	 	 - google analytics
3. Automation
http://poweredbycoffee.co.uk
Repetition Sucks
http://poweredbycoffee.co.uk
Mistakes Get Made
People Get Bored
Creative people usually don't like to do the same thing over and over again.
Not a good use of skills and talent
anything that has to be done regularly and takes more than 2 minutes is a good candidate
Need to do it twice?
http://poweredbycoffee.co.uk
Need to do it twice?
Automate it.
http://poweredbycoffee.co.uk
Good Candidates for
Automation
http://poweredbycoffee.co.uk
Deployments
Compiling Assets (Sass, CoffeeScript, etc)
Compressing Images
Setting up servers
Installing WordPress
Introduce myself (who I am, what I do)

Introduce the topic

- imposter syndrome

- creativity in churches

- anger and identity

We need 	 to ask a few questions?
I Hate FTP
http://poweredbycoffee.co.uk
- slow, insecure, inaccurate

- who has had a site stop working because a file didn't transfer properly over FTP?

- initial deploy is slow (huge sites)

- updates are slow and error prone

- enables bad behaviour and "cowboy coding"
Automated Deployments
http://poweredbycoffee.co.uk
No more slow or failed FTP transfers
Easily tied into your version control
Easily undo a mistake
Get new code into production with a few key stokes or clicks
- faster

- use your version control backend

- provide an audit trail

- can be automated and customised to suit how your team works

- version control branches and deployments

- allows us to give clients visual updates super fast without having to code on the server
http://capistranorb.com
Introduce myself (who I am, what I do)

Introduce the topic

- imposter syndrome

- creativity in churches

- anger and identity

We need 	 to ask a few questions?
Capistrano
http://poweredbycoffee.co.uk
- Scriptable and self-installed
- Ruby
- Task Based
- Logs in to your server, pulls from your Version Control, runs a series of tasks
you tell it to.
- Super powerful and flexible
- ssh, git pull, run tasks

	 	 - has role backs, supports multiple servers and roles.

	 	 - Ruby /shrug

	 	 - FREE & OpenSource

	 	 - cap staging deploy

	 	 	 - capistrano logs in to seach server and does a git pull

	 	 	 - runs and tasks we tell in to eg `composer install`

	 	 	 - then creates symlinks for any directories that are shared between releases

	 	 	 - run any other tasks we might wants as well (eg assets/image compression etc)
Deploy HQ Deploy Bot Buddy
Introduce myself (who I am, what I do)

Introduce the topic

- imposter syndrome

- creativity in churches

- anger and identity

We need 	 to ask a few questions?
DeployBot (etc)
http://poweredbycoffee.co.uk
- Many of these services exist
- Hard to configure but just works when its done
- $/£/€
- Less control and less flexible but easier to setup
- logins via ssh

	 	 - has a record of the last commit you deployed

	 	 - git pulls onto their server

	 	 - then transfers every files that has been modified since the last deployment
Standardising
Environments
http://poweredbycoffee.co.uk
- this seems to create massive complexity

	 - massively not worth it - riiiight up until it save you.

	 - different versions of MySQL and PHP have different features

	 - some of thee things are easy to change, some not

	 - make it impossible to have a problem

	 - pick one a build against it

	 - utf8mb4 and MySQL < 5.5.3

	 	 - if you develop on one the try to move into production on another - you have a problem

	 - PHP versions
Use Virtual Machines
http://poweredbycoffee.co.uk
- Virtual Machienes (Parallels etc)
vagrantup.com
not that clever

CLI interface and automation tool for VirtualBox

Because no one wants to use virtual box
Concluding
http://poweredbycoffee.co.uk
Its going to take a while
http://poweredbycoffee.co.uk
These aren’t WordPress
Skills
http://poweredbycoffee.co.uk
They are Professional
Development Skills
http://poweredbycoffee.co.uk
Where To Go Next?
http://poweredbycoffee.co.uk
- Automated Testing (Never ship something broken again)
- Visual Regression Testing (Make CSS changes less painful)
- Code Quality Checks (Stop bad code getting into your repo or near a server)
- Install Software on your servers with a few keystrokes
- Notifications and Integration with your other tools

WordCamp Belfast DevOps for Beginners

  • 1.
    WordPress DevOps For Beginners http://poweredbycoffee.co.uk StewartRitchie @stewartritchie stewart@poweredbycoffee.co.uk
  • 2.
    This is NOT aTutorial http://poweredbycoffee.co.uk This is a guide to dev ops for beginners. You’ve probably heard talks about this stuff before. aimed at technical tutorial instead of a 101 - why should you care This talk is for - beginners to devops, - devs who want to start to improve their productivity and quality - business owners who hear developers talking about stuff the don't understand and want to up their understanding - pm’s who want more control and efficiency
  • 3.
    What is DevOps anyway? http://poweredbycoffee.co.uk Asked my friends Andy, works for Sky on Now TV as a Scrum Master Dev Ops is a very simple concept at its heart. Its not a technology. its not a cure all to your problems. Investment. Spent time now - create development project processes - that save time later - improve efficiency - improve happiness - and improve your over all project outcome. (Quality/Time to market/Profitability) IE - Devs spend more time developing.
  • 4.
    Why is DevOps Important? http://poweredbycoffee.co.uk why does it provide value? no value - no point 1. dev 2. bus 3. comm
  • 5.
    1. DevOps willmake you a better developer. http://poweredbycoffee.co.uk - You’ll learn to structure your code in more reusable, - your learn how do write code that can be tested - you’ll learn to think about performance and failure of the code you write 1. collaborate with other developers 2. reduce the risk of trying new techniques 3. improve the quality of your code 4. Help developers do more development and less system administration 5. bring new people into a project quickly.
  • 6.
    2. DevOps willhelp you deliver better work to your clients http://poweredbycoffee.co.uk You will be able to deliver faster, iterate faster, involve your clients in your process more. Talk about deployments/Continuous Integration -Make it hard or almost impossible to have a bug get in production 1. If you do have a problem, your recovery time will be slashed. 2. Make everyone on your team more efficient 3. faster iteration cycle 4. better data mining and monitoring of systems
  • 7.
    3. DevOps helpsmove WordPress into bigger companies and opportunities http://poweredbycoffee.co.uk DevOps bring reliability, repeatability and lowers risk. WordPress == Wild West - a toy/hobby. DevOps brings respectability. scaleability reliability predicable and repeatable
  • 8.
    How Does DevOps Help? http://poweredbycoffee.co.uk 1. Collaboration 2. Code Sharing 3. Automation
  • 9.
    1. Collaboration http://poweredbycoffee.co.uk Work togetherbetter. teams grow,projects grow, more and more people will need involved Bad collaboration can kill projects dead Developer collaboration is hard
  • 10.
    Version Control http://poweredbycoffee.co.uk Easy fordevelopers to collaborate A hardened nuclear bunker for your source code Makes it easy to have more that one version of your project! Basically a time machine - version control - gives us a way to manage code and version that gets it off your laptop - code is a shared resource and changes should not be made 'willy nilly" - similar to version on the mac or even time machine you can go back in time to a point in your project
  • 11.
    What is a“Commit”? http://poweredbycoffee.co.uk - Snapshot of code - the difference since the last snapshot, layer them up and you get a project - a commit should include a defined piece of work - bug fix - a change that had a purpose - made changes that you dont want to keep? revet to the last commit.
  • 12.
    http://poweredbycoffee.co.uk This layering givesus a log of the project over time See how files changed
  • 13.
    Merging Version Control http://poweredbycoffee.co.uk -Gives you the ability to manage different versions of your software - Development, Staging & Production - Approve code to move up the versions into production The real killer feature is that your code base can exits in different states. This comes from “Branching” 1. you can see here every dot is a commit. 2. At this commit you made a deployement 3. you keep commiting until some one finds a bug - you;ve been working on the project in the mean time, added half a dozen unfinished features you fix the bug in your deployed version. Now you need to unpick the new features or download
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
    2. Code Sharing http://poweredbycoffee.co.uk allprojects have code that they didn’t create in them
  • 20.
    Dependencies http://poweredbycoffee.co.uk - every softwareproject is built on the shoulders of those that came before it. - starting fro scratch again would be irresponsible and wasteful - PHP is a dependency (basically a piece of software written in C), mysql and a webserver - we do not want to have to manage code we didn’t create, do not commit that - multiple kinds of dependencies to manage (production/dev) software
  • 21.
    WordPress Has Dependencies http://poweredbycoffee.co.uk - Diffby Geoffrey T. Bairiki - ID3 by James Heinrich - BackBone & Underscores
  • 22.
    The Problem with dependanciesis that they can change http://poweredbycoffee.co.uk - The problem with dependancies is that they change - Writing software is hard, using extenal dependancies is hard. - they change. Features get added or removed - Building a house with a foundation of sand - the sand/dependency changes and the house can fall down - by targeting a specific version of a library or a dependancy you can stop this happening - then update when you know its safe (SEMVER - FTW) - dependencies can have their own dependencies
  • 23.
    What About YourProject? http://poweredbycoffee.co.uk - WordPress is a dependancy. Its a library that your are writing software against - So are all your plugins, themes, libraries etc etc - any libraries you add are dependencies (PHP/JS/CSS) - You are creating something that depends on these - that is a risk
  • 24.
    Your Dependancies - havedependencies http://poweredbycoffee.co.uk - WordPress is a dependancy. Its a library that your are writing software against - So are all your plugins, themes, libraries etc etc - any libraries you add are dependencies (PHP/JS/CSS) - You are creating something that depends on these - that is a risk - Different kinds of dependencies - production dependencies - stuff needed to make the site run - dev dependencies - helpers and devtool
  • 25.
    What About YourProject? http://poweredbycoffee.co.uk - Story of Smallbusiness.co.uk - using Timber (with routing) - timber goes v1 all fine - timber goes v1.1 site falls apart - routing was removed - wordpress updates to 4.6 and falls apart - dependencies to blame - installed routes -> installed wpcli -> requests - requests got included in wp 4.6 hence a conflict - site collapses
  • 26.
    This Sounds Likea Nightmare http://poweredbycoffee.co.uk - managing all this manually shounds like a nightmare - install the librarys/whatever you tell it to in the version you tell it to - install all the things you need to run that thing as well. And the correct versions for it. - This is pretty cool - keeps your team using the same things - recorded in a file so you dont have to store them in your repo You’ve probably already done something similar installing grunt/gulp/sass etc
  • 27.
    getcomposer.org - composer - composer.json - WordPress and composer are not natural friends - we need to move everything that might change in our repo out of the wordpress folder - htaccess - wp-config.php - wp-content - many good tutorials on the web for this - configure composer to work - get plugins and themes from github, packaginst and wp-packagist - satispress for premium plugins - wordpress maybe becoming a package - composer.json trac ticket
  • 28.
    - get pluginsand themes from github, packaginst and wp-packagist
  • 29.
    - satispress forpremium plugins
  • 30.
  • 31.
    bower.io - bower forJS - much simpler - load JS however you want
  • 32.
  • 33.
    Easy Ways ToGet Started http://poweredbycoffee.co.uk - write stuff as small plugins - version control the plugin and use your repeats in projects - eg - wpmail-mailgun - envswitch - disable xmlrpc - google analytics
  • 34.
  • 35.
    Repetition Sucks http://poweredbycoffee.co.uk Mistakes GetMade People Get Bored Creative people usually don't like to do the same thing over and over again. Not a good use of skills and talent anything that has to be done regularly and takes more than 2 minutes is a good candidate
  • 36.
    Need to doit twice? http://poweredbycoffee.co.uk
  • 37.
    Need to doit twice? Automate it. http://poweredbycoffee.co.uk
  • 38.
    Good Candidates for Automation http://poweredbycoffee.co.uk Deployments CompilingAssets (Sass, CoffeeScript, etc) Compressing Images Setting up servers Installing WordPress Introduce myself (who I am, what I do) Introduce the topic - imposter syndrome - creativity in churches - anger and identity We need to ask a few questions?
  • 39.
    I Hate FTP http://poweredbycoffee.co.uk -slow, insecure, inaccurate - who has had a site stop working because a file didn't transfer properly over FTP? - initial deploy is slow (huge sites) - updates are slow and error prone - enables bad behaviour and "cowboy coding"
  • 40.
    Automated Deployments http://poweredbycoffee.co.uk No moreslow or failed FTP transfers Easily tied into your version control Easily undo a mistake Get new code into production with a few key stokes or clicks - faster - use your version control backend - provide an audit trail - can be automated and customised to suit how your team works - version control branches and deployments - allows us to give clients visual updates super fast without having to code on the server
  • 41.
    http://capistranorb.com Introduce myself (whoI am, what I do) Introduce the topic - imposter syndrome - creativity in churches - anger and identity We need to ask a few questions?
  • 42.
    Capistrano http://poweredbycoffee.co.uk - Scriptable andself-installed - Ruby - Task Based - Logs in to your server, pulls from your Version Control, runs a series of tasks you tell it to. - Super powerful and flexible - ssh, git pull, run tasks - has role backs, supports multiple servers and roles. - Ruby /shrug - FREE & OpenSource - cap staging deploy - capistrano logs in to seach server and does a git pull - runs and tasks we tell in to eg `composer install` - then creates symlinks for any directories that are shared between releases - run any other tasks we might wants as well (eg assets/image compression etc)
  • 43.
    Deploy HQ DeployBot Buddy Introduce myself (who I am, what I do) Introduce the topic - imposter syndrome - creativity in churches - anger and identity We need to ask a few questions?
  • 44.
    DeployBot (etc) http://poweredbycoffee.co.uk - Manyof these services exist - Hard to configure but just works when its done - $/£/€ - Less control and less flexible but easier to setup - logins via ssh - has a record of the last commit you deployed - git pulls onto their server - then transfers every files that has been modified since the last deployment
  • 45.
    Standardising Environments http://poweredbycoffee.co.uk - this seemsto create massive complexity - massively not worth it - riiiight up until it save you. - different versions of MySQL and PHP have different features - some of thee things are easy to change, some not - make it impossible to have a problem - pick one a build against it - utf8mb4 and MySQL < 5.5.3 - if you develop on one the try to move into production on another - you have a problem - PHP versions
  • 46.
  • 47.
    vagrantup.com not that clever CLIinterface and automation tool for VirtualBox Because no one wants to use virtual box
  • 49.
  • 50.
    Its going totake a while http://poweredbycoffee.co.uk
  • 51.
  • 52.
    They are Professional DevelopmentSkills http://poweredbycoffee.co.uk
  • 53.
    Where To GoNext? http://poweredbycoffee.co.uk - Automated Testing (Never ship something broken again) - Visual Regression Testing (Make CSS changes less painful) - Code Quality Checks (Stop bad code getting into your repo or near a server) - Install Software on your servers with a few keystrokes - Notifications and Integration with your other tools