Ansible 之 Inventory配置

一、Inventory作用

Inventory 是 Ansible 管理主机信息的配置文件,相当于系统HOSTS文件的功能,默认存放在/etc/ansible/hosts。为方便批量管理主机,便捷使用其中的主机分组,Ansible 通过Inventory 来定义其主机和组。

二、Inventory 配置更改

[root@Ansible ansible]# vi ansible.cfg 
[defaults]
# some basic default values...
inventory      = /etc/ansible/inventory/       #将Inventory定义为目录,目录下所有文件均可使用

[root@Ansible ansible]# ll
total 20
-rw-r--r-- 1 root root 19989 Jan 18 21:54 ansible.cfg
drwxr-xr-x 2 root root    54 Jan 18 23:45 inventory
drwxr-xr-x 2 root root     6 Dec 18 12:50 roles
[root@Ansible ansible]# ll inventory/
total 12
-rw-r--r-- 1 root root 1056 Jan 18 08:27 hosts
-rw-r--r-- 1 root root   72 Jan 18 22:17 songxin_test
-rwxr-xr-x 1 root root  496 Jan 18 23:41 test.py

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐