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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章