Junior — Middle
Can you list the main objects and components used in Ansible for automation of configurations?
sobes.tech AI
Answer from AI
Main objects and components of Ansible for configuration automation:
- Inventory — a list of managed hosts and groups to which tasks will be applied.
- Playbook — a YAML file describing a set of tasks to be executed on hosts.
- Task — a single action, such as installing a package or copying a file.
- Module — a functional unit executed by a task (e.g.,
yummodule for installing packages,copyfor copying files). - Role — a structured set of playbooks, tasks, variables, and files for reuse and code organization.
- Variable — parameters that can be used to configure the behavior of playbooks and roles.
- Handler — a task that is executed only when notified (e.g., restarting a service after configuration change).
- Facts — information about target hosts, automatically gathered before executing tasks.
Example of a simple playbook that installs nginx:
- hosts: webservers
tasks:
- name: Install nginx
apt:
name: nginx
state: present
become: yes