community.general.random_pet 查询 – 生成随机宠物名称
注意
此查询插件是 community.general 集合 (版本 10.1.0) 的一部分。
如果您正在使用 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他需求才能使用此查询插件,有关详细信息,请参见 需求。
要在 playbook 中使用它,请指定:community.general.random_pet
。
community.general 3.1.0 中的新增功能
概要
生成可作为资源唯一标识符的随机宠物名称。
需求
以下需求在执行此查询的本地控制器节点上需要。
关键字参数
这描述了查询的关键字参数。这些是在以下示例中的值 key1=value1
,key2=value2
等:lookup('community.general.random_pet', key1=value1, key2=value2, ...)
和 query('community.general.random_pet', key1=value1, key2=value2, ...)
参数 |
注释 |
---|---|
宠物名称每个组件的最大长度。 低于 3 的值将由 petname 设置为 3。 默认值: |
|
用名称前缀的字符串。 |
|
用于分隔宠物名称中单词的字符。 默认值: |
|
宠物名称中的单词数。 默认值: |
示例
- name: Generate pet name
ansible.builtin.debug:
var: lookup('community.general.random_pet')
# Example result: 'loving-raptor'
- name: Generate pet name with 3 words
ansible.builtin.debug:
var: lookup('community.general.random_pet', words=3)
# Example result: 'fully-fresh-macaw'
- name: Generate pet name with separator
ansible.builtin.debug:
var: lookup('community.general.random_pet', separator="_")
# Example result: 'causal_snipe'
- name: Generate pet name with length
ansible.builtin.debug:
var: lookup('community.general.random_pet', length=7)
# Example result: 'natural-peacock'
返回值
键 |
描述 |
---|---|
包含随机宠物名称的一个元素列表 返回:成功 |