Inventory configuration of Ansible

One, the role of Inventory

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

Two, Inventory configuration changes

[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

Guess you like

Origin blog.51cto.com/12965094/2596919