ansible 清单文件位置是 /etc/ansible/hosts 还是 /etc/hosts?
ansible inventory file location is it /etc/ansible/hosts or /etc/hosts?
我对库存文件的创建有一个基本的疑问,库存文件名的位置是否是
/etc/ansible/hosts
或 /etc/hosts
?
如果两者相同,那么为什么我们需要不同的清单文件设置?
谢谢,
萨蒂亚拉詹 M
Ansible 的默认 Inventory 文件的位置是 /etc/ansible/hosts。但是您可以通过 ansible.cfg.
中的清单指令覆盖清单文件 location/path
/etc/hosts 的用途完全不同,我建议您阅读一下。引用askubuntu,/etc/hosts file
的目的和格式
Purpose
The hosts file is one of several system facilities that assists in
addressing network nodes in a computer network. It is a common part of
an operating system's Internet Protocol (IP) implementation, and
serves the function of translating human-friendly hostnames into
numeric protocol addresses, called IP addresses, that identify and
locate a host in an IP network. In some operating systems, the hosts
file's content is used preferentially to other methods, such as the
Domain Name System (DNS), but many systems implement name service
switches (e.g., nsswitch.conf for Linux and Unix) to provide
customization. Unlike the DNS, the hosts file is under the direct
control of the local computer's administrator
File content
The hosts file contains lines of text consisting of an IP address in
the first text field followed by one or more host names. Each field is
separated by white space (blanks or tabulation characters). Comment
lines may be included; they are indicated by a hash character (#) in
the first position of such lines. Entirely blank lines in the file are
ignored. For example, a typical hosts file may contain the following:
This is an example of the hosts file
127.0.0.1 localhost loopback ::1 localhost This example only contains entries for the loopback addresses of the system and their
host names, a typical default content of the hosts file. The example
illustrates that an IP address may have multiple host names, and that
a host name may be mapped to several IP addresses.
我对库存文件的创建有一个基本的疑问,库存文件名的位置是否是
/etc/ansible/hosts
或 /etc/hosts
?
如果两者相同,那么为什么我们需要不同的清单文件设置?
谢谢, 萨蒂亚拉詹 M
Ansible 的默认 Inventory 文件的位置是 /etc/ansible/hosts。但是您可以通过 ansible.cfg.
中的清单指令覆盖清单文件 location/path/etc/hosts 的用途完全不同,我建议您阅读一下。引用askubuntu,/etc/hosts file
的目的和格式Purpose
The hosts file is one of several system facilities that assists in addressing network nodes in a computer network. It is a common part of an operating system's Internet Protocol (IP) implementation, and serves the function of translating human-friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network. In some operating systems, the hosts file's content is used preferentially to other methods, such as the Domain Name System (DNS), but many systems implement name service switches (e.g., nsswitch.conf for Linux and Unix) to provide customization. Unlike the DNS, the hosts file is under the direct control of the local computer's administrator
File content
The hosts file contains lines of text consisting of an IP address in the first text field followed by one or more host names. Each field is separated by white space (blanks or tabulation characters). Comment lines may be included; they are indicated by a hash character (#) in the first position of such lines. Entirely blank lines in the file are ignored. For example, a typical hosts file may contain the following:
This is an example of the hosts file
127.0.0.1 localhost loopback ::1 localhost This example only contains entries for the loopback addresses of the system and their host names, a typical default content of the hosts file. The example illustrates that an IP address may have multiple host names, and that a host name may be mapped to several IP addresses.