community / community.general / 8.5.0 / lookup / random_words Return a number of random words | "added in version" 4.0.0 of community.general" Authors: Thomas Sjögren (@konstruktoid)community.general.random_words (8.5.0) — lookup
Install with ansible-galaxy collection install community.general:==8.5.0
collections: - name: community.general version: 8.5.0
Returns a number of random words. The output can for example be used for passwords.
See U(https://xkcd.com/936/) for background.
- name: Generate password with default settings ansible.builtin.debug: var: lookup('community.general.random_words')
# 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)
# 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')
# 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='')
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
_raw: description: A single-element list containing random words. elements: str type: list