community.general.random_words (8.5.0) — lookup

Return a number of random words

| "added in version" 4.0.0 of community.general"

Authors: Thomas Sjögren (@konstruktoid)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Returns a number of random words. The output can for example be used for passwords.

See U(https://xkcd.com/936/) for background.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Generate password with default settings
  ansible.builtin.debug:
    var: lookup('community.general.random_words')
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  # Example result: 'traitor gigabyte cesarean unless aspect clear'

- name: Generate password with six, five character, words
  ansible.builtin.debug:
    var: lookup('community.general.random_words', min_length=5, max_length=5)
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  # Example result: 'brink banjo getup staff trump comfy'

- name: Generate password with three capitalized words and the '-' delimiter
  ansible.builtin.debug:
    var: lookup('community.general.random_words', numwords=3, delimiter='-', case='capitalize')
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  # Example result: 'Overlabor-Faucet-Coastline'

- name: Generate password with three words without any delimiter
  ansible.builtin.debug:
    var: lookup('community.general.random_words', numwords=3, delimiter='')

Inputs

    
case:
    choices:
    - alternating
    - upper
    - lower
    - random
    - capitalize
    default: lower
    description:
    - The method for setting the case of each word in the passphrase.
    type: str

numwords:
    default: 6
    description:
    - The number of words.
    type: int

delimiter:
    default: ' '
    description:
    - The delimiter character between words.
    type: str

max_length:
    default: 9
    description:
    - Maximum length of words to make password.
    type: int

min_length:
    default: 5
    description:
    - Minimum length of words to make password.
    type: int

Outputs

_raw:
  description: A single-element list containing random words.
  elements: str
  type: list