- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Core Tech
Build a Reusable Ansible Role with Templates and Ansible Vault
Ansible roles let you package automation once and reuse it across hosts and teams. In this lab, you'll build a role that installs and configures Redis, render its configuration from a Jinja2 template, protect its password with Ansible Vault, and validate the role with ansible-lint, check mode, and a repeat run before sharing it.
Lab Info
Table of Contents
-
Challenge
Create a role that installs and runs Redis
Generate a role skeleton with ansible-galaxy, remove the directories the role doesn't need, and add tasks that install Redis and keep it enabled and running. Then apply the role to both cache servers with a short playbook.
-
Challenge
Render the Redis configuration from a Jinja2 template
Define role defaults for the bind address, port, memory limit, and persistence, and render redis.conf from a Jinja2 template with one conditional. Restart Redis only when the configuration changes, then override one default for a single host.
-
Challenge
Protect the Redis password with Ansible Vault
Encrypt the Redis password in a vault file for the cache servers, reference it in the template so Redis requires authentication, and confirm that Redis rejects clients that don't send the password.
-
Challenge
Validate the role before sharing it
Fix the issues that ansible-lint reports, preview a configuration change with check mode, apply it, and run the playbook again to prove that the role makes no further changes.
-
Challenge
The last objective
Welcome to the final objective! This is your last chance to experiment in the environment. Clicking **End Lab **will end this little world that flittered into existence just for you.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.