gpt4 book ai didi

ansible - Mac 上Ansible 需要手动创建/etc/ansible/hosts 吗?

转载 作者:行者123 更新时间:2023-12-05 03:10:46 24 4
gpt4 key购买 nike

根据 http://docs.ansible.com/ansible/intro_installation.html

Once running the env-setup script you’ll be running from checkout and the default inventory file will be /etc/ansible/hosts.

我需要创建一个 /etc/ansible/hosts 文件吗?

在此下方有一个警告:

Note ANSIBLE_INVENTORY is available starting at 1.9 and substitutes the deprecated > ANSIBLE_HOSTS

那么,我是否应该使用主机文件的替代品?

最佳答案

Do I need to create an /etc/ansible/hosts file?

从技术上讲,这个路径中的这个文件不是 Ansible 运行所必需的。

inventory file ,因为它被调用,是必需的,但它可以放在文件系统的其他地方,并且是在命令行 (-i) 中引用的路径,在 ansible.cfg 文件中(在您的主目录或当前目录中)或环境变量 (ANSIBLE_INVENTORY)。

来自 OS X 上 Homebrew 的 Ansible 将文件放在 /usr/local/etc/ansible 中,以允许普通用户修改文件,而无需在 /etc 下授予帐户写权限 分支。

你甚至可以使用 an undocumented trick这允许针对临时创建的服务器列表运行 Ansible。

Note ANSIBLE_INVENTORY is available starting at 1.9 and substitutes the deprecated ANSIBLE_HOSTS

那么,我是否应该使用主机文件的替代品?

此通知表示指向 list 文件的环境变量的名称。它不是“hosts 文件的替代品”,它是ANSIBLE_HOSTS 变量的替代品

a comment in the source指出更改的原因是命名困惑。

Ansible 社区开始将包含主机和组定义的文件称为“hosts 文件”,但由于它与系统主机队列的结构不同,因此实现了一个新名称“inventory”。仍然存在一些引用(如默认文件名)。

关于ansible - Mac 上Ansible 需要手动创建/etc/ansible/hosts 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38850480/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com