Free Ansible MCQ Questions and Answers — Questions and Answers
Question 1: Describe Ansible.
- A tool for containerization
- A tool for configuration management (Correct answer)
- A database management tool
- A programming language
Correct answer: A tool for configuration management
Ansible is an open-source automation engine designed for configuration management, application deployment, and task automation. It helps manage and configure computer systems, deploy software, and orchestrate more advanced IT tasks across multiple machines. It is not primarily a containerization tool, database tool, or programming language itself.
Question 2: Which language is used to write Ansible?
- Python (Correct answer)
- Ruby
- Java
- Perl
Correct answer: Python
Ansible is primarily written in Python. This choice of language contributes to its flexibility, extensibility, and ease of integration with other tools and scripts. Its modules and core logic are developed in Python, making it accessible to a broad community of developers.
Question 3: What does the Ansible playbook serve as?
- To write Python code for automation
- To install the Ansible tool
- To manage the Docker containers
- To define the configuration and deployment steps (Correct answer)
Correct answer: To define the configuration and deployment steps
An Ansible playbook is a YAML-formatted file that defines a set of tasks to be executed on managed hosts. It serves as the blueprint for automation, describing the desired state of a system, specifying configurations to apply, packages to install, services to manage, and other deployment steps. Playbooks are central to Ansible's functionality.
Question 4: An Ansible module is what?
- A pre-defined set of variables
- A collection of tasks
- A script that runs on the target host
- A function that performs a specific task (Correct answer)
Correct answer: A function that performs a specific task
An Ansible module is a discrete unit of code that performs a specific task on managed nodes. These modules are the building blocks of Ansible playbooks, providing the actual functionality for automation, such as installing packages, managing services, copying files, or executing commands. Each module is designed to be idempotent, meaning it can be run multiple times without causing unintended changes.
Question 5: How is the target hosts' communication with Ansible handled?
- Telnet
- SSH (Correct answer)
- VNC
- RDP
Correct answer: SSH
Ansible communicates with its managed nodes (target hosts) primarily over standard SSH (Secure Shell) protocol. This agentless approach means there's no need to install any special software or agents on the target machines, simplifying setup and maintenance. It leverages existing SSH infrastructure for secure and reliable communication.
Question 6: An Ansible inventory file is what?
- A file that defines the playbook steps
- A file that contains the list of target hosts (Correct answer)
- A file that contains the module definitions
- A file that contains the variables
Correct answer: A file that contains the list of target hosts
An Ansible inventory file is a plain text file, typically in INI or YAML format, that lists the managed nodes or servers that Ansible will operate on. It organizes these hosts into groups, allowing for targeted execution of playbooks and commands. This file is crucial for defining the infrastructure Ansible will manage.
Question 7: What is the Ansible inventory file's default location?
- /etc/ansible/inventory
- /etc/ansible/hosts (Correct answer)
- /etc/ansible/inventory.ini
- /etc/ansible/hosts.ini
Correct answer: /etc/ansible/hosts
By default, Ansible looks for its inventory file at `/etc/ansible/hosts`. This is a standard location for system-wide configuration files on Linux systems. Users can, however, specify a different inventory file using the `-i` flag when running Ansible commands, allowing for flexible project-specific inventories.
Describe Ansible.