【问题标题】:From an Ansible inventory file, is it possible to include variables from another file?从 Ansible 清单文件中,是否可以包含来自另一个文件的变量?
【发布时间】:2017-06-06 19:11:19
【问题描述】:

我的 Ansible 主机文件:

mybox.mydomain.com ansible_ssh_pass={{mypassword}}

变量“mypassword”在文件“variables.yml”中定义:

mypassword = somepassword

有没有办法可以将“variables.yml”中的变量包含在我的主机文件中?否则,当我尝试运行一些 Ansible 命令时,会出现错误

the field 'password' has an invalid value, which appears to include a variable that is undefined. The error was: 'mypassword' is undefined

我问这个是因为最终我想使用 .yml 文件中的 Vault 加密变量(因为这是 Vault 加密单个变量的唯一方法)

【问题讨论】:

    标签: ansible ansible-inventory


    【解决方案1】:

    variables.yml 放入库存附近的group_vars/all/variables.yml

    这会将variables.yml 中的所有内容加载为清单中每个主机的组变量。

    【讨论】:

    • 非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    • 2010-09-13
    • 2021-09-25
    • 2021-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多