Red Hat Certified Engineer RHCE · Free Practice Question Hard
Question 16
You are tasked with automating a multi-tier application deployment that requires roles for the database, web server, and application server. How would you organize these roles and use them in a single playbook to deploy the entire application stack?
-
A
Organizing Roles for Multi-Tier Application Deployment
Structure roles for the database, web, and application servers:
- roles/
- db/
- tasks/
- web/
- tasks/
- app/
- tasks/
Use the roles in a single playbook:
- - hosts: db_servers
- roles:
- - db
- - hosts: web_servers
- roles:
- - web
- - hosts: app_servers
- roles:
- - app
This deploys the entire multi-tier application stack.
-
B
This is a performance based question and not multiple choice. Therefore the answer is in #1. If you require additional explanation, please ask your question in the Q&A section.
Reveal correct answer
Correct answer: A
A.
This solution demonstrates how to organize and use Ansible roles to automate a multi-tier application deployment, which includes database, web, and application servers. Roles in Ansible allow for reusable, modular, and structured automation tasks. Here, three roles (db, web, and app) are created and structured under the roles/ directory. A single playbook applies these roles to their respective server groups: db_servers for the database, web_servers for the web server, and app_servers for the application server. This structure ensures clean separation of concerns, modularity, and scalability, allowing the deployment of the entire application stack efficiently.
Line-by-Line Explanation:
Role Structure:
roles/Base directory where roles are stored.
db/The role directory for database-related tasks.
tasks/Contains the tasks file (
main.yml) for database configuration.
web/Role directory for web server tasks.
tasks/Contains the tasks for setting up the web server.
app/Role directory for application server tasks.
tasks/Contains the tasks for deploying the application.
Playbook:
- hosts: db_serversTargets the group of database servers defined in the inventory file.
roles:Specifies the roles to be applied to the current host group.
- dbApplies the
dbrole for configuring database servers.
- hosts: web_serversTargets the group of web servers.
roles:Begins the role section for the web servers.
- webApplies the
webrole to configure web servers.
- hosts: app_serversTargets the group of application servers.
roles:Begins the role section for the application servers.
- appApplies the
approle for deploying the application.
Key Notes:
Roles provide modularity by breaking tasks into reusable components for each server tier (database, web, and app).
The roles/ directory follows a standard Ansible structure, making it organized and easy to manage.
A single playbook can apply roles to specific server groups (
db_servers,web_servers,app_servers) defined in the inventory.This approach ensures separation of responsibilities, scalability, and clean configuration for multi-tier deployments.
Using roles simplifies complex deployments by focusing on individual server configurations while maintaining overall consistency.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
