In this video we look at how we can use Ansible to install and configure all the 'common' software packages and settings that we want every single time we build or provision a new server.
For me, this is one of the best features of Ansible.
Sure, we can deploy all kinds of cool software using a combination of Ansible Galaxy and our playbooks, but having a really nice base to work from - that is until now - would have meant building a standard master image with all our common software pre-installed.
Now, reading that you may very well be thinking: what could building our server this way offer that simply using / cloning a standard master does not?
It's a good question.
We also seem to be cloning from a master image here, so how are these two setups different anyway?
Let's explore the separate processes and look at how the two situations work out.
As software developers we are taught from very early in our careers that we should keep things DRY (Don't Repeat Yourself).
A prudent move therefore, should we be in a situation where we frequently need new base server images to be provisioned, would be to install our Ubuntu Server (as an example, but it could be any other OS), patch it up to date, install all the common things we need - git, ssh, fail2ban, etc - and then shut that machine down.
We might have added in some standard user accounts, but more often than not, we would keep this machine as generic as possible.
We call that machine our Master, Gold Image, or some other fancy term.
We never use that machine directly.
Instead, every time we need it, we take a clone of that image and then customise the clone to our needs.
If we discover some time later that we should have also installed a backup agent, added in another user account, or set up a specific user group then bad news, we not only need to edit our Master image, but also our clones.
What started out as a seemingly good idea has quite quickly become a maintainence headache.
Remember that Master image that I just slagged off? Well, we still need it. Arf.
But not quite.
We could get away with building a brand new Ubuntu Server VM (or physical, if you're so inclined / rich enough) every time we need a new build. But why bother, if cloning only takes a few seconds compared to >10 mins to build the same image we already have.
Next, we configure an Ansible Playbook to install and configure all the common tools, user accounts, settings, and anything else we need.
There is effort involved in this - one time to set it up (skip that bit if you wish by using mine), then a few tweaks in the future as you refine / improve your process.
Need to add in another user?
No problem, tweak the
defaults/main.yml - or wherever else you have your User config - and run your playbook against your entire infrastructure. Bosh. All done. No headaches.
Same goes for backup agents, user groups, additional software you forget... anything!
The rigidity is gone.
This video assumes you have been following along with the tutorial series.
If you have, watching this should hold no surprises. Either clone my repo or make your own and get started creating your perfect server config.
If you haven't watched any other videos in this series then I hope watching this opens your eyes to the power of Ansible.
The best thing is that whilst this just installs the basics, this can be the base of every other machine you build. Want a RabbitMQ server? Awesome, grab a RabbitMQ role from Ansible Galaxy and you're good to go. But even better, run your common role first and you also have a RabbitMQ with all your settings, users, groups, security tweaks... the works. Perfect, every time.
Ansible. Is. Freaking. Awesome!
If you have found this video helpful, please consider sharing. I really appreciate it.
|1||How To Install Ubuntu Server in Oracle VirtualBox||10:21|
|2||How to Rename our Ubuntu Server||02:00|
|3||Installing Ansible on Ubuntu Server||00:33|
|4||Safety First, Safety Second - Snapshots are like Ctrl+Z||00:11|
|5||Managing the Ansible Inventory Hosts File||02:16|
|6||Ansible Ad Hoc Commands||04:27|
|7||Introduction to Ansible Playbooks||02:14|
|10||Git Your Deploy Just Right||05:34|
|12||Looping in Ansible with_items||04:34|
|13||Ansible Files For Beginners||06:14|
|14||Variable Precedence - Where To Put Your Role Vars?||04:13|
|16||Ansible Inventory With Our Own Hosts Files||06:57|
|17||How to Manage Users with Ansible||08:32|
|18||Ansible Vault Tutorial||03:48|
|19||Ansible Galaxy Tutorial||10:03|
|20||Real World Ansible - Common Role Walkthrough||06:19|
|21||Ansible MySQL Tutorial||13:44|
|22||Ansible Symfony and nginx||09:37|