community.general.hiera 查找 – 从 Hiera 数据中获取信息
注意
此查找插件是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了这个集合。 它不包含在 ansible-core
中。 要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。 您需要其他要求才能使用此查找插件,有关详细信息,请参阅 要求。
要在剧本中使用它,请指定:community.general.hiera
。
概要
使用 Hiera 作为 ENC 从 Puppetmaster 节点检索数据。
要求
执行此查找的本地控制器节点需要满足以下要求。
hiera (命令行实用程序)
术语
参数 |
注释 |
---|---|
要在 Puppetmaster 上查找的键列表。 |
关键字参数
这描述了查找的关键字参数。 这些是以下示例中的值 key1=value1
、key2=value2
等:lookup('community.general.hiera', key1=value1, key2=value2, ...)
和 query('community.general.hiera', key1=value1, key2=value2, ...)
参数 |
注释 |
---|---|
备注
注意
当关键字和位置参数一起使用时,位置参数必须在关键字参数之前列出:
lookup('community.general.hiera', term1, term2, key1=value1, key2=value2)
和query('community.general.hiera', term1, term2, key1=value1, key2=value2)
示例
# All this examples depends on hiera.yml that describes the hierarchy
- name: "a value from Hiera 'DB'"
ansible.builtin.debug:
msg: "{{ lookup('community.general.hiera', 'foo') }}"
- name: "a value from a Hiera 'DB' on other environment"
ansible.builtin.debug:
msg: "{{ lookup('community.general.hiera', 'foo environment=production') }}"
- name: "a value from a Hiera 'DB' for a concrete node"
ansible.builtin.debug:
msg: "{{ lookup('community.general.hiera', 'foo fqdn=puppet01.localdomain') }}"
返回值
键 |
描述 |
---|---|
与输入键关联的值 已返回: 成功 |