WAG the Blog

14
WAG the Blog* Using WordPress, Ansible, and Git to Build Your Website WordCamp Atlanta 2016 || Evan Volgas || Developer Track * Ha! A pun.

Transcript of WAG the Blog

Page 1: WAG the Blog

WAG the Blog*Using WordPress, Ansible, and Git to Build Your Website

WordCamp Atlanta 2016 || Evan Volgas || Developer Track

* Ha! A pun.

Page 2: WAG the Blog

Who the heck is this guy?Evan….

• Recently started as a data engineer at MailChimp

• Has used WordPress off and on for about 6-7 years

• Has used Ansible for about a two years now

• Probably drinks more coffee than you*

• Definitely has written more bad code than you**

More Snark @EvanVolgas

Less Snark https://evan.is/

* No seriously, he has a problem** See above

Page 3: WAG the Blog

Important DisclaimersI believe…. • Google Exists • You can use it • Reading code in slides is boring • Working with servers is fun • Elvis is still alive*

* You’re not fooling anybody Matt… or should I say Elvis?

Page 4: WAG the Blog

Who cares about servers? (bias / opinion alert)

Think about the question:

How does the internet work?*

https://ma.ttias.be/the-best-tech-question-to-ask-in-a-job-interview/

My opinion: As professionals who earn a living on the internet, we owe it to ourselves and the people we work with to understand the technologies we are using on a deep level.

That includes understanding more about servers than most people would ever stop and think about in the first place.

* Laws, sausages, and software… all things you don’t want to see get made

Page 5: WAG the Blog

Ansible• Ansible is OSS that was written to make configuring

and managing servers less of a pain in the neck • The name Ansible comes from a sci-fi novel by

Ursula K. Le Guin. The term was popularized by Orson Scott-Card in Ender’s Game.

• In many sci-fi books, an Ansible is a device that can remotely control large fleets of ships all across the galaxy

• In our world, Ansible can connect to an arbitrarily large number of servers over SSH and run commands on them, commands that you yourself could run if you were SSH’d into all of the machines yourself

We read sci-fi all day. It’s a hard NOC life for those of us in software

Page 6: WAG the Blog

How Ansible Works in a NutshellAnsible…• Runs playbooks or “plays” against groups of servers • Each play may be compromised of one or more “roles.” Roles are groups of

things you want to do on your servers and are usually where all the work in Ansible really happens

• Appropriate role scoping is subjective but an example of a role might be “Install and configure Nginx” for example or “Install and configure IP Tables.” Don’t worry about defining an appropriate scope for a role just yet. Instead, read Other People’s Code and start forming opinions on what works and what doesn’t

• Every role may have variables, tasks, templates, and/or defaults associated with it. Here again, OPC will be very helpful.

• The hosts in your Ansible inventory can also have variables assigned to them. This is some serious secret sauce right here and you should definitely pay attention to this

Using footnotes in slides is a terrible idea isn’t it?

Page 7: WAG the Blog

Ansible: Examples / Discussion• TLR*: https://github.com/evanv/tlr

• Trellis: https://github.com/roots/trellis

• WordPress Ansible: https://github.com/lamosty/wordpress-ansible

• AnsiPress: https://github.com/codeablehq/AnsiPress

• Ansible-WordPress: https://github.com/Oefenweb/ansible-wordpress

* Whoever owns this repo is probably very smart, funny, attractive, & great at at giving presentations

Page 8: WAG the Blog

Ansible: Examples ReviewRoles may include variables, which have different levels of precedence

For example, host variables “win” against role defaults

See http://docs.ansible.com/ansible/playbooks_variables.html for info about the rules

You can (and often do) break your inventory into different host groups that you can target with different playbooks

Can you believe they let this guy speak at WordCamp?

Page 9: WAG the Blog

Git• Git is an open source Version Control System (VCS) • Git is distributed — developers have full copies of the

code and its history on their local environments and then push changes to a central shared location

• Workflows (eg https://www.atlassian.com/git/tutorials/comparing-workflows/centralized-workflow and http://blog.endpoint.com/2014/05/git-workflows-that-work.html) and opinions about them abound.

• Ignore the flame wars. Just do what works for you and your team.

He probably doesn’t know anything about Linux either

Page 10: WAG the Blog

WordPress and Git• If you read one article, read this: http://

stevegrunwell.github.io/wordpress-git/

• If you read two articles, read https://deliciousbrains.com/storing-wordpress-in-git/

• If you read three articles, read https://markjaquith.wordpress.com/2011/06/24/wordpress-local-dev-tips/

* Whatever you do, don’t read four articles. Four is nature’s limit. Watch Monty Python. That shalt read three articles. Five is right out.

Page 11: WAG the Blog

What’s Git Got to Do with This?

• You *definitely* want to keep your Ansible playbooks and roles under version control

• You can use Ansible to install Git on your servers.

• You can also (and will, probably, once you suffer the pain of learning to use them) use Ansible in connection with CI tools like Travis / Circle / BuildBot / etc.

Jedi mind trick? Nope. Continuous integration. Not sure what that is? See slide 4.

Page 12: WAG the Blog

Why are we here again?

• You should absolutely take a look at Trellis: https://github.com/roots/trellis and VVV (https://github.com/Varying-Vagrant-Vagrants/VVV)

• You should also take a look at provision.sh in VVV (https://github.com/Varying-Vagrant-Vagrants/VVV/blob/develop/provision/provision.sh) and compare that to Trellis. Quite a bit different, no? But awfully similar too.

* Learning how the internet works is a lot like learning emacs except people who know how the internet works still get invited to parties sometimes

• The internet is not magic. But it is complicated. And the more you work with servers, the more you will be exposed to its complexity and the more you will start* to understand it

Page 13: WAG the Blog

The moment we’ve all been waiting for….

Let’s provision a server!

Where’s Wapuu?

Page 14: WAG the Blog

Concluding remarks• Earlier I mentioned role scoping in Ansible and also claimed that

you definitely want your Ansible scripts in Git • Let’s decimate look at OPC https://www.digitalocean.com/

community/tutorials/how-to-automate-installing-wordpress-on-ubuntu-14-04-using-ansible

• Your server config will change. You’ll make mistakes. Make your config a living document. Use Git.

• https://github.com/MisfitIdeas/wag-the-blog

Hell is OPC… unless OPC is Rich Hickey’s