Ansible
一句话解释
Ansible 是打开-源 automation tool 那个配置服务器 and 部署 software using 简单 YAML playbooks.
用大白话说
Ansible is a tool for automating configuration management and application deployment. Instead of manually SSH-ing into servers to install packages and configure services, you write playbooks in YAML that describe the desired state.
Ansible is agentless — it doesn't require any software installed on the target servers. It uses SSH to connect and run commands. This makes it simple to set up and use.
A playbook contains tasks like "安装 nginx", "复制这个配置 file", "开始这个 service". Ansible runs these tasks on your servers in order. It is idempotent — running the same playbook multiple times produces the same result, so you can safely run it again and again.
示例
- name: Install and start nginx
hosts: webservers
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Start nginx
service:
name: nginx
state: started
enabled: yes这个 playbook 安装 nginx on 所有服务器 in 'webservers' 分组 and ensures 它是 运行.
工作原理
- You write a playbook in YAML describing tasks to run.
- You define an inventory file listing your target servers.
ansible-playbookconnects via SSH and runs tasks in order.- Ansible checks the current state and only makes changes if needed (idempotent).
常见混淆
容易混淆的对象: Terraform
关键区别: Ansible 配置 existing 服务器 (安装 software, manages files); Terraform 创建服务器它们自己 (infrastructure provisioning).
相关术语
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。