ansible介绍及安装
Ansible 是一种无代理自动化工具,安装在单个主机(称为控制节点)上。 从控制节点,Ansible 可以通过 SSH、Powershell 远程处理和众多其他传输方式远程管理整个机器群和其他设备(称为托管节点),所有这些都通过简单的命令行界面进行,无需数据库或守护程序。
控制节点要求
对于您的控制节点(运行 Ansible 的机器),您可以使用几乎任何安装了 Python 或更高版本的类 UNIX 机器。 这包括 Red Hat、Debian、Ubuntu、macOS、BSD 和 Windows Subsystem for Linux (WSL) 发行版下的 Windows。 没有 WSL 的 Windows 本身不支持作为控制节点。
受管节点要求
受管节点(Ansible 管理的机器)不需要安装 Ansible,但需要 Python 2.7 或 Python 3.5 - 3.11 才能运行 Ansible 库代码。 受管节点还需要一个可以通过交互式 POSIX shell 通过 SSH 连接到该节点的用户帐户。
Python兼容
| ansible-core版本 | 控制节点 | 受管节点 |
|---|---|---|
| 2.9 | Python 2.7, Python 3.5+ | Python 2.6 - 2.7, Python 3.5+ |
| 2.10 | Python 2.7, Python 3.5+ | Python 2.6 - 2.7, Python 3.5+ |
| 2.11 | Python 2.7, Python 3.5 - 3.9 | Python 2.6 - 2.7, Python 3.5 - 3.9 |
| 2.12 | Python 3.8 - 3.10 | Python 2.6 - 2.7, Python 3.5 - 3.10 |
| 2.13 | Python 3.8 - 3.10 | Python 2.7, Python 3.5 - 3.10 |
| 2.14 | Python 3.9 - 3.11 | Python 2.7, Python 3.5 - 3.11 |
安装ansible
sudo yum install epel-release -y
sudo yum install ansible -y
配置文件
有个四个地方可以设置,优先级依次降低。分别是 ANSIBLE_CONFIG变量 、./ansible.cfg 、~/.ansible.cfg 、/etc/ansible/ansible.cfg
基本上可以不配置就使用,开箱即用。2.9版本官网文档配置说明传送门
验证
$ ansible --version
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ops/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

浙公网安备 33010602011771号