mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-08 22:30:04 -07:00
add random_words lookup plugin, based on the xkcdpass module (#3588)
* add random_words lookup plugin, based on the xkcdpass module Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com> * add maintainer in BOTMETA Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com> * Update plugins/lookup/random_words.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/lookup/random_words.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/lookup/random_words.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/lookup/random_words.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/lookup/random_words.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update tests/integration/targets/lookup_random_words/test.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update tests/integration/targets/lookup_random_words/test.yml Co-authored-by: Felix Fontein <felix@fontein.de> * ignore E402, place imports below documentation Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
73acdaa489
commit
c40db6789a
6 changed files with 167 additions and 0 deletions
3
tests/integration/targets/lookup_random_words/aliases
Normal file
3
tests/integration/targets/lookup_random_words/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
shippable/posix/group2
|
||||
skip/aix
|
||||
skip/python2.6 # lookups are controller only, and we no longer support Python 2.6 on the controller
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Install xkcdpass Python package
|
||||
pip:
|
||||
name: xkcdpass
|
9
tests/integration/targets/lookup_random_words/runme.sh
Executable file
9
tests/integration/targets/lookup_random_words/runme.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
set -eux
|
||||
|
||||
ANSIBLE_ROLES_PATH=../ \
|
||||
ansible-playbook dependencies.yml -v "$@"
|
||||
|
||||
ANSIBLE_ROLES_PATH=../ \
|
||||
ansible-playbook test.yml -v "$@"
|
28
tests/integration/targets/lookup_random_words/test.yml
Normal file
28
tests/integration/targets/lookup_random_words/test.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Call random_words plugin
|
||||
set_fact:
|
||||
result1: "{{ query('community.general.random_words') }}"
|
||||
result2: "{{ query('community.general.random_words', min_length=5, max_length=5) }}"
|
||||
result3: "{{ query('community.general.random_words', delimiter='!') }}"
|
||||
result4: "{{ query('community.general.random_words', numwords=3, delimiter='-', case='capitalize') }}"
|
||||
result5: "{{ query('community.general.random_words', numwords=3, delimiter='') }}"
|
||||
|
||||
- name: Check results
|
||||
assert:
|
||||
that:
|
||||
- result1 | length == 1
|
||||
- result1[0] | length >= 35
|
||||
- result2 | length == 1
|
||||
- result2[0] | length == 35
|
||||
- result3 | length == 1
|
||||
- result3[0].count("!") == 5
|
||||
- result4 | length == 1
|
||||
- result4[0] | length >= 17
|
||||
- result4[0] | length <= 29
|
||||
- result4[0] | regex_findall("[A-Z]") | length == 3
|
||||
- result4[0].count("-") == 2
|
||||
- result5 | length == 1
|
||||
- result5[0] | length >= 18
|
Loading…
Add table
Add a link
Reference in a new issue