Junior — Middle
Can you explain how server configuration and management automation is carried out using Ansible?
sobes.tech AI
Answer from AI
Ansible is a tool for automating configuration and server management, which operates on a "push" principle — the control server sends instructions to target machines.
Main mechanisms:
- Inventory — a list of servers to manage.
- Playbooks — YAML files describing tasks to be performed on servers.
- Modules — ready-made scripts for executing specific actions (installing packages, copying files, starting services).
Automation process:
- You describe the desired state of servers in a playbook.
- Ansible connects to servers via SSH (without installing agents).
- Executes tasks sequentially, ensuring idempotency (if the state already matches, no changes will be made).
Example of a simple playbook to install nginx:
- hosts: webservers
become: yes
tasks:
- name: Install nginx
apt:
name: nginx
state: present
Thus, Ansible allows centralized and repeatable management of server configurations without manual actions.