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:

    Use the roles in a single playbook:

    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:

  1. roles/

    • Base directory where roles are stored.

  2. db/

    • The role directory for database-related tasks.

  3. tasks/

    • Contains the tasks file (main.yml) for database configuration.

  4. web/

    • Role directory for web server tasks.

  5. tasks/

    • Contains the tasks for setting up the web server.

  6. app/

    • Role directory for application server tasks.

  7. tasks/

    • Contains the tasks for deploying the application.

Playbook:

  1. - hosts: db_servers

    • Targets the group of database servers defined in the inventory file.

  2. roles:

    • Specifies the roles to be applied to the current host group.

  3. - db

    • Applies the db role for configuring database servers.

  4. - hosts: web_servers

    • Targets the group of web servers.

  5. roles:

    • Begins the role section for the web servers.

  6. - web

    • Applies the web role to configure web servers.

  7. - hosts: app_servers

    • Targets the group of application servers.

  8. roles:

    • Begins the role section for the application servers.

  9. - app

    • Applies the app role 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.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need