有没有办法在剧本中定义可靠的库存路径?

Is there a way to define the ansible inventory path inside the playbook?

我正在尝试找到一种方法来在剧本中而不是在 ansible.cfg 文件中或通过在剧本执行期间使用 -i 来指定库存路径。这可能吗?

没有。无法在 playbook 中定义 ansible inventory 路径。

引用自Ansible Configuration Settings

"Ansible supports a few ways of providing configuration variables, mainly through environment variables, command line switches and an ini file named ansible.cfg