Basic Concepts

These concepts are common to all uses of Ansible, including network automation. You need to understand them to use Ansible for network automation. This basic introduction provides the background you need to follow the examples in this guide.

管理机

任何安装了 Ansbile 的服务器,你都可以使用 ansible or ansible-playbook 命令。 任何安装了 Ansbile 的机器都可以做为管理节点,便携式计算机,共享桌面和服务器都可以。 你可以配置多个管理节点。唯一需要注意的是,管理节点不支持 Windows 系统。

受控节点

Ansbile 管理的服务器或者网络设备都称为受控节点。 受控节点有时候也叫做 “hosts” ( 主机 ). 受控节点不需要安装 Ansible.

Inventory 仓库

Inventory 仓库是保存受控节点信息的列表, 因为有时候也叫 “hostfile”, 类似于系统的 hosts 文件。 Inventory 仓库可以以 IP 的方式指定受控节点。 Inventory 同样可以组织管理节点、新增、嵌套组等方式,非常便于扩展。 更多请参考 the Working with Inventory

Modules 模块

Modules 模块是 Ansible 执行代码的最小单元。 每个模块都是特殊用途,从特殊类型的数据库用户管理,到特殊类型的网络设备 VLAN 接口管理。 你可以在通过执行单个任务调用一个模块,也可以通过 playbook 同时调用执行钓具模块。 在链接中查看 Ansible 总共包括了多少个模块。:ref:` 模块列表 <modules_by_category>`.

Tasks 任务

Ansible 执行操作的最小单位。 ad-hoc 更适合临时执行命令的执行场景。

Playbooks 任务剧本

Playbooks 是任务列表的组合,通常会把常用的命令列表通过正确的语法写入到 playbook中。 Playbook 可以像普通 tasks 一样调用变量, 其使用 YAML 语法,便于读、写、分享、理解。更多请参考 Intro to Playbooks.