Search test library by skills or roles
⌘ K

Adaface Sample Ansible Questions

Here are some sample Ansible questions from our premium questions library (10273 non-googleable questions).

Skills

🧐 Question

Medium

Execution Order and Handlers
Task Execution
Handlers
Error Handling
Solve
Analyze the following Ansible playbook, which is designed to set up and verify a web server. Determine the correct order of task execution, including the handler invocation:
 image
In what order will the tasks and handlers be executed?
A: Install web server, Start web server, Verify web server, Notify failure, Restart web server (if notified)
            B: Install web server, Start web server, Restart web server (if notified), Verify web server, Notify failure (if failed)
            C: Install web server, Restart web server (if notified), Start web server, Verify web server, Notify failure (if failed)
            D: Install web server, Start web server, Verify web server, Notify failure (if failed), Restart web server (if notified)
            E: Install web server, Verify web server, Start web server, Restart web server (if notified), Notify failure (if failed)
            F: Install web server, Start web server, Verify web server (if previous task failed), Notify failure, Restart web server (if notified)

Medium

Task Execution Control
Loop Control
Error Handling
Jinja2 Templating
Solve
You are a senior Ansible engineer tasked with writing a playbook to configure a set of web servers. The playbook should iterate over a list of packages and install them. However, if a package installation fails, the playbook should record the failed package name and continue with the next package without failing the entire playbook. The playbook also needs to generate a report at the end, listing all successfully installed packages and any that failed to install. Below is the pseudo code for the main task:
 image
Select the correct way to complete this playbook:
A: Add a block with a rescue section after the loop to capture failed packages.
            B: Use failed_when in the loop to prevent the task from failing and update the lists accordingly.
            C: Use a when condition inside the loop to check package_result.failed and update the lists.
            D: Add a handler triggered on package installation failure to update the failed_packages list.
            E: Use a Jinja2 template in a separate task to generate the report after the loop.
            F: Implement a custom Ansible module for package installation and failure handling.

Easy

Variable Assignment in Playbooks
Conditional Statements
Variable Management
Solve
Consider an Ansible playbook that is designed to set up a web server. The playbook needs to assign a variable named `webserver_port` based on the operating system of the target host. The default port should be 80, but if the target host is running Ubuntu, the port should be set to 8080. Below is the pseudo code for the task:
 image
Choose the correct statement regarding the execution of this task:
A: The task will fail because the comparison in the conditional statement is incorrect.
            B: The task will assign port 8080 for all Debian-based distributions, including Ubuntu.
            C: The task will always assign port 80, regardless of the operating system.
            D: The task will assign port 8080 only if the `ansible_os_family` variable is exactly 'Ubuntu'.
            E: The task will fail because `set_fact` does not support conditional assignments.
            F: The task will assign port 8080 for Ubuntu and port 80 for all other operating systems.
🧐 Question🔧 Skill

Medium

Execution Order and Handlers
Task Execution
Handlers
Error Handling

2 mins

Ansible
Solve

Medium

Task Execution Control
Loop Control
Error Handling
Jinja2 Templating

2 mins

Ansible
Solve

Easy

Variable Assignment in Playbooks
Conditional Statements
Variable Management

2 mins

Ansible
Solve
🧐 Question🔧 Skill💪 Difficulty⌛ Time
Execution Order and Handlers
Task Execution
Handlers
Error Handling
Ansible
Medium2 mins
Solve
Task Execution Control
Loop Control
Error Handling
Jinja2 Templating
Ansible
Medium2 mins
Solve
Variable Assignment in Playbooks
Conditional Statements
Variable Management
Ansible
Easy2 mins
Solve

Trusted by recruitment teams in enterprises globally

Amazon Morgan Stanley Vodafone United Nations HCL PayPal Bosch WeWork Optimum Solutions Deloitte Microsoft NCS Doubtnut Sokrati J&T Express Capegemini

We evaluated several of their competitors and found Adaface to be the most compelling. Great library of questions that are designed to test for fit rather than memorization of algorithms.


Swayam Narain, CTO, Affable

hashtag image heart icon Swayam
customers across world
Join 1500+ companies in 80+ countries.
Try the most candidate friendly skills assessment tool today.
g2 badges
Ready to streamline your recruitment efforts with Adaface?
Ready to streamline your recruitment efforts with Adaface?
logo
40 min tests.
No trick questions.
Accurate shortlisting.
ada
Ada
● Online
Previous
Score: NA
Next
✖️