Ansible Beginner Quiz
30 questions on Ansible Configuration.
Question 1: What is Ansible mainly used for?
- A. Graphic design
- B. Configuration management, application deployment, and task automation β (correct answer)
- C. Video editing
- D. Word processing
Explanation: Ansible allows you to automate the configuration of hundreds of servers simultaneously, installing software and changing settings automatically.
Question 2: Which company acquired and currently backs Ansible?
- A. Google
- B. Microsoft
- C. Red Hat (IBM) β (correct answer)
- D. Amazon
Explanation: Red Hat acquired Ansible in 2015 and offers an enterprise version called Ansible Automation Platform, though the core tool remains open-source.
Question 3: What is a major architectural advantage of Ansible compared to tools like Chef or Puppet?
- A. Ansible is agentless β (correct answer)
- B. Ansible requires a database
- C. Ansible only works on Windows
- D. Ansible uses a proprietary language
Explanation: Ansible does not require you to install any custom agent software on the target servers. It connects via standard SSH.
Question 4: What does Ansible use to connect to Linux servers?
- A. FTP
- B. SSH (Secure Shell) β (correct answer)
- C. HTTP
- D. Telnet
Explanation: Because it uses standard SSH, if you can log into a server via terminal, Ansible can manage it automatically.
Question 5: What language are Ansible Playbooks written in?
- A. Python
- B. JSON
- C. YAML β (correct answer)
- D. XML
Explanation: Playbooks use YAML because it is highly human-readable, allowing even non-developers to understand the configuration.
Question 6: What is the Ansible "Inventory"?
- A. A list of all software installed on the control node
- B. A file (or dynamic script) that contains a list of managed nodes (IP addresses or hostnames) that Ansible will connect to β (correct answer)
- C. A database of passwords
- D. A catalog of Ansible merchandise
Explanation: The inventory file tells Ansible *where* to run the commands. You can group IPs into categories like [webservers] and [dbservers].
Question 7: What is an Ansible "Playbook"?
- A. A manual on how to use Ansible
- B. A YAML file containing a series of plays and tasks that define the desired state of the target systems β (correct answer)
- C. A Python script
- D. A graphical dashboard
Explanation: The Playbook is your automation script. It says, "Connect to webservers, install Nginx, and start the service."
Question 8: What is an Ansible "Task"?
- A. A scheduled job in Windows
- B. The smallest unit of action in Ansible, representing a single step to be executed on a target (e.g., install a package) β (correct answer)
- C. A user role
- D. A server reboot
Explanation: Tasks are executed in sequential order from top to bottom within a Playbook.
Question 9: What is an Ansible "Module"?
- A. A physical server blade
- B. A standalone script (usually written in Python) that Ansible executes on the target node to perform a specific task (e.g., the
apt or yum module) β (correct answer)
- C. A YAML parser
- D. A network switch
Explanation: When you use the copy module in a task, Ansible packages the Python code for that module, sends it over SSH, executes it, and deletes it.
Question 10: What does Idempotency mean in the context of Ansible?
- A. The playbook runs incredibly fast
- B. Running a playbook once has a specific effect, but running it again safely results in no further changes if the system is already in the desired state β (correct answer)
- C. The playbook deletes files
- D. The playbook ignores errors
Explanation: If a task says "Create user John", running it 50 times won't create 50 users or throw 49 errors; it will simply skip the task 49 times.
Question 11: Which command is used to run a playbook named site.yml?
- A.
ansible-run site.yml
- B.
ansible-playbook site.yml β (correct answer)
- C.
ansible site.yml
- D.
run playbook site.yml
Explanation: ansible-playbook is the core command-line tool used to execute your YAML automation files.
Question 12: What is an Ansible "Ad-Hoc Command"?
- A. A command that takes hours to run
- B. A quick, single Ansible task run directly from the command line without writing a full YAML Playbook β (correct answer)
- C. A command that only runs on Windows
- D. A command that creates a backup
Explanation: Example: ansible all -m ping. This is useful for quick checks, like rebooting 50 servers at once, without needing a permanent script.
Question 13: What does the ping module do in Ansible?
- A. Sends ICMP network pings
- B. Verifies that Ansible can successfully SSH into the target nodes and execute Python scripts β (correct answer)
- C. Restarts the server
- D. Updates the OS
Explanation: Unlike the standard network ping, the Ansible ping module actually logs in and returns a "pong" if the node is manageable.
Question 14: How do you escalate privileges (run as sudo or root) in an Ansible Playbook?
- A.
sudo: yes
- B.
become: yes β (correct answer)
- C.
admin: true
- D.
root: yes
Explanation: The become directive tells Ansible to log in as the normal user and then switch to root to perform administrative tasks like installing software.
Question 15: What is Ansible Galaxy?
- A. A cloud hosting provider
- B. A public hub/repository where the community shares pre-packaged Ansible Roles and Collections β (correct answer)
- C. A video game
- D. A graphical dashboard for Ansible
Explanation: Instead of writing a playbook to install MySQL from scratch, you can download a community-tested MySQL role from Ansible Galaxy.
Question 16: What is an Ansible "Role"?
- A. A user permission level (e.g., Admin vs Guest)
- B. A structured way of organizing tasks, variables, files, and templates into reusable directories, rather than putting everything in one giant playbook β (correct answer)
- C. A physical server
- D. An SSH key
Explanation: Roles make your code modular. You can have a webserver role and a database role, applying them to different host groups cleanly.
Question 17: In an Ansible inventory file (INI format), what does [webservers] denote?
- A. A comment
- B. A group name, allowing you to target a specific collection of hosts in your playbook β (correct answer)
- C. A variable definition
- D. A module name
Explanation: You can put 10 IP addresses under [webservers] and in your playbook use hosts: webservers to apply the configuration to all 10 simultaneously.
Question 18: How do you reference a variable named http_port inside an Ansible task?
- A.
$http_port
- B.
{{ http_port }} β (correct answer)
- C.
%http_port%
- D.
var.http_port
Explanation: Ansible uses the Jinja2 templating system. Variables are always wrapped in double curly braces.
Question 19: What does the gather_facts: yes setting do at the start of a playbook?
- A. Searches the internet for information
- B. Automatically connects to the remote hosts to gather system information (like OS version, IP addresses, memory) before running tasks β (correct answer)
- C. Scans for viruses
- D. Prompts the user for input
Explanation: Facts allow you to write conditional tasks, such as "Install apt if OS is Ubuntu, install yum if OS is CentOS."
Question 20: What is "Ansible Vault"?
- A. A physical safe at Red Hat
- B. A built-in feature that encrypts sensitive files and variables (like passwords and SSL keys) so they can be safely stored in version control β (correct answer)
- C. A backup database
- D. A cloud storage service
Explanation: You use ansible-vault encrypt secret.yml to lock the file with a password.
Question 21: What is a "Handler" in Ansible?
- A. A script that handles errors
- B. A special type of task that only runs when notified by another task that a change has occurred (e.g., restarting a service only if the config file changed) β (correct answer)
- C. A user account
- D. A network routing protocol
Explanation: Handlers prevent unnecessary service restarts, maintaining high availability.
Question 22: Which module is used to ensure a specific software package is installed on a Debian/Ubuntu system?
- A.
install
- B.
software
- C.
apt β (correct answer)
- D.
pkg
Explanation: Example: apt: name=nginx state=present. For Red Hat/CentOS systems, you would use the yum or dnf module.
Question 23: How do you perform a "Dry Run" in Ansible to see what changes *would* be made without actually making them?
- A.
ansible-playbook site.yml --dry-run
- B.
ansible-playbook site.yml --check β (correct answer)
- C.
ansible-playbook site.yml --test
- D.
ansible-playbook site.yml --fake
Explanation: Check mode is a safe way to test a new playbook on production servers without breaking anything.
Question 24: What does the template module do?
- A. Downloads a website template
- B. Copies a file to the remote server while dynamically replacing Jinja2 variables (
{{ }}) inside the file with actual values β (correct answer)
- C. Creates a new playbook
- D. Formats the hard drive
Explanation: This is perfect for generating custom nginx.conf files based on the specific server's IP address and hostname.
Question 25: What does the state: present argument usually mean in an Ansible task?
- A. Delete the resource
- B. Ensure the resource (package, user, file) exists, creating it if necessary β (correct answer)
- C. Give a presentation
- D. Check if the server is online
Explanation: Conversely, state: absent tells Ansible to ensure the resource is deleted/removed.
Question 26: What is the difference between copy and fetch modules?
- A. There is no difference
- B.
copy moves files from the Control Node to the Remote Node; fetch pulls files from the Remote Node back to the Control Node β (correct answer)
- C.
copy is for Linux, fetch is for Windows
- D.
copy copies text, fetch copies images
Explanation: fetch is highly useful for grabbing log files or backup archives from 50 different servers and storing them locally.
Question 27: What does the tags attribute allow you to do?
- A. Add metadata for SEO
- B. Label specific tasks so you can choose to run only a subset of the playbook rather than the entire file β (correct answer)
- C. Tag other users in comments
- D. Rename the server
Explanation: If a playbook takes 20 minutes to run, but you only want to update the database config, you can run ansible-playbook site.yml --tags "db_config".
Question 28: What does the when statement do in a task?
- A. Schedules the task for a specific time
- B. Makes the task conditional, executing it only if the specified expression evaluates to true β (correct answer)
- C. Tells Ansible when the playbook started
- D. Pauses the playbook
Explanation: Example: when: ansible_os_family == "Debian" ensures an apt task doesn't accidentally run on a CentOS server and crash.
Question 29: What is "Ansible AWX"?
- A. The Windows version of Ansible
- B. The open-source upstream project for Red Hat Ansible Automation Platform, providing a web-based GUI, REST API, and task engine β (correct answer)
- C. A cloud hosting service
- D. A text editor
Explanation: While CLI Ansible is great for individuals, AWX/Tower provides role-based access control, scheduling, and visual dashboards for enterprise teams.
Question 30: What is a Dynamic Inventory?
- A. An inventory file that changes its own name
- B. A script that dynamically queries external APIs (like AWS or VMware) to get real-time lists of servers, rather than using a static text file β (correct answer)
- C. An inventory file with animations
- D. A database table
Explanation: In the cloud, IP addresses change constantly as servers scale up and down. Dynamic inventory ensures Ansible always knows the correct IPs.