--- status: stable type: concept tags: - devops updated: 2026-02-27 title: Inventory - Ansible created: 2025-12-17 --- # Inventory - Ansible Особенности Ansible: 1. Подключение по SSH 2. Agentless - нет программ на клиентах Структура файла `hosts.ini` ```text-xml 192.168.0.1 192.168.0.2 [web] # группа серверов 192.168.0.3 192.168.0.4 ``` Можно использовать псевдонимы, вместо ip ```text app ansible_host=ip_server1 db ansible_host=ip_server2 web ansible_host=ip_server3 ``` Другие полезные параметры **inventory**: - `ansible_connection: ssh/winrm/local/docker` - тип подключения к серверу - `ansible_port: 22/5986` - порт подключения - `ansible_user: root` - логин для входа по ssh (или др.) - `ansible_ssh_pass: password` или `ansible_password: password` - пароль для входа по ssh. Группы для объединения групп: ```text [mail_internal] mail1.serv [mail_external] mail2.serv [mail_all:children] mail_internal mail_external ``` Помимо `ini`-формата, можно использовать YAML-файлы: ```yaml all: children: webservers: hosts: web1.example.com: ansible_host: 192.168.1.10 ansible_user: admin web2.example.com: ansible_host: 192.168.1.11 vars: ansible_port: 22 ansible_python_interpreter: /usr/bin/python3 databases: hosts: db1.example.com: db2.example.com: production: children: webservers: databases: ```