As PHP developers, we often find ourselves managing our own web servers and performing the same commands over and over again for each new server and website that we wish to deploy. We’ve heard about the benefits of tools like Puppet and Chef, but the time and effort involved in learning, setting up, and using those tools is prohibitive and we usually decide that using SSH, relying on bash history and even some helper scripts is easier than learning something new.
However, there is an alternative: Ansible.
Ansible is a fantastic tool that removes a lot of the pain and tedium from setting up and managing servers of all shapes and sizes. It is incredibly easy to use, fast to set up, and it will definitely save you a significant amount of time and energy, even if you only spend a few minutes learning the basics. It gives you the power to provision servers, deploy applications and make configuration changes without touching SSH, logging into remote servers to run commands manually, or hunting through your bash history file while copy-pasting commands across multiple terminal windows.
The purpose of this talk is to demonstrate, live on stage, the entire process of deploying two different PHP applications onto two freshly installed web servers using only Ansible. It will cover the basics, such as installing system packages and modifying configuration files, through to more advanced topics, such as using the git module, installing and running composer, and even automatically setting up randomly generated database passwords. All of this will be achieved without a single SSH connection or any manual steps.
There will be no slides or screenshots. Just a text editor and a local terminal window. (Oh, and numerous backup plans, if the demo gods aren’t kind!) The IP addresses of our deployment servers will be shared at the start, and over the course of the talk they will transition from rejecting all HTTP requests to serving our PHP applications, for a triumphant finish at the end.
Tutorials & documentation
- Ansible documentation
- List of all Ansible modules
- Automating your PHP application deployment process with Ansible (DigitalOcean tutorial series)
- How to configure Apache using Ansible on Ubuntu (DigitalOcean tutorial)
PHP NZ Conference 2015
- Conference Website