community.general.random_pet lookup – Generates random pet names

Note

This lookup plugin is part of the community.general collection (version 4.8.3).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.random_pet.

New in version 3.1.0: of community.general

Synopsis

  • Generates random pet names that can be used as unique identifiers for the resources.

Requirements

The below requirements are needed on the local controller node that executes this lookup.

Parameters

Parameter

Comments

length

integer

The maximal length of every component of the pet name.

Values below 3 will be set to 3 by petname.

Default: 6

prefix

string

A string to prefix with the name.

separator

string

The character to separate words in the pet name.

Default: “-“

words

integer

The number of words in the pet name.

Default: 2

Examples

- 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'

Return Values

Common return values are documented here, the following are the fields unique to this lookup:

Key

Description

_raw

list / elements=string

A one-element list containing a random pet name

Returned: success

Authors

  • Abhijeet Kasurde (@Akasurde)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.