mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-08 14:20:04 -07:00
random_pet: Random pet name generator (#2479)
A lookup plugin to generate random pet names based upon criteria. Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
e2dfd42dd4
commit
5d0a7f40f2
5 changed files with 142 additions and 0 deletions
3
tests/integration/targets/lookup_random_pet/aliases
Normal file
3
tests/integration/targets/lookup_random_pet/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 Petname Python package
|
||||
pip:
|
||||
name: petname
|
9
tests/integration/targets/lookup_random_pet/runme.sh
Executable file
9
tests/integration/targets/lookup_random_pet/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 "$@"
|
25
tests/integration/targets/lookup_random_pet/test.yml
Normal file
25
tests/integration/targets/lookup_random_pet/test.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Call plugin
|
||||
set_fact:
|
||||
result1: "{{ query('community.general.random_pet', words=3) }}"
|
||||
result2: "{{ query('community.general.random_pet', length=3) }}"
|
||||
result3: "{{ query('community.general.random_pet', prefix='kubernetes') }}"
|
||||
result4: "{{ query('community.general.random_pet', separator='_') }}"
|
||||
result5: "{{ query('community.general.random_pet', words=2, length=6, prefix='kubernetes', separator='_') }}"
|
||||
|
||||
- name: Check results
|
||||
assert:
|
||||
that:
|
||||
- result1 | length == 1
|
||||
- result1[0].split('-') | length == 3
|
||||
- result2 | length == 1
|
||||
- result2[0].split('-')[0] | length <= 3
|
||||
- result3 | length == 1
|
||||
- result3[0].split('-')[0] == 'kubernetes'
|
||||
- result4 | length == 1
|
||||
- result4[0].split('_') | length == 2
|
||||
- result5 | length == 1
|
||||
- result5[0].split('_') | length == 3
|
||||
- result5[0].split('_')[0] == 'kubernetes'
|
Loading…
Add table
Add a link
Reference in a new issue