The hands-on lab is part of these learning paths
DevOps Engineer – Professional Certification Preparation for AWS
Introduction to Ansible
Ready for the real environment experience?
This Lab is going to keep building on what was covered in the Lab: Getting Started with Ansible.
In this Lab, you will be deploying a simple Python-based web application. This will be a basic LAMP stack, with the P representing Python.
The goal of this Lab is to introduce you to roles, templates, and handlers. Here is a quick refresher on each of these.
Roles are a way to reuse functionality by putting all of the logic for a particular use case in the same place. As an example, if you have tasks that you might run on all servers regardless of what the server is used for, that logic might be put in a role called common.
And if you have logic to configure a web server, then you may have another role named webserver. And whenever you need to install a new web application, you can include these two roles in your playbook.
Templates at their core are a way to copy files to a remote server. However, the difference between templates and static files is that templates will be processed before they are copied to the remote host. This allows you to include variables, conditionals, loops, etc. Ansible uses Jinja2 as its template engine.
Handlers are basically tasks that are run when some event happens. As an example, if you change a web server’s configuration file, you will need to restart the web server service. This is an ideal use case for handlers.
Before you start
This Lab includes YAML and Python, and both are sensitive to whitespace. This means the potential for running into errors caused by copy and paste is higher. It is something to keep in mind as you proceed.
Nano will be used for editing any text files. However, if you have your own preference you can use it. If you are new to nano, here is the high level info:
Once in nano, you can close out by pressing CTRL+X.
When closing nano, it will prompt you to save if you have made any changes. To do that press the Y key.
If you chose to save, it will ask you for the filename, if the filename is already set, then you can press the Enter/Return key.
That is how we will save files going forward. CTRL+X to close out of nano, then press Y to save, then press Enter to save to the file name listed.
July 13th, 2018 - Updated to use the latest version of Ansible
About the Author
With in-depth experience in solution design, large scale infrastructure and capacity planning; Vincenzo is the man with the plan when it comes to hands-on learning. With years of knowledge and capabilities with both AWS and Microsoft Azure, Vincenzo really knows how to simplify the core assets of the task at hand and acts as a true Oracle for the cloud world.