mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Add docs for ansible-core 2.13 use
local testing shows fine, adding here as example for other filters/tests
* Update plugins/filter/random_mac.py
* Improve docs.
* Remove wrong 'positional'.
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e62a56e15c
)
Co-authored-by: Brian Coca <bcoca@users.noreply.github.com>
This commit is contained in:
parent
348d2c26de
commit
020fa081d7
1 changed files with 29 additions and 0 deletions
|
@ -20,6 +20,35 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
name: random_mac
|
||||||
|
short_description: Generate a random MAC address
|
||||||
|
description:
|
||||||
|
- Generates random networking interfaces MAC addresses for a given prefix.
|
||||||
|
options:
|
||||||
|
_input:
|
||||||
|
description: A string prefix to use as a basis for the random MAC generated.
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
seed:
|
||||||
|
description:
|
||||||
|
- A randomization seed to initialize the process, used to get repeatable results.
|
||||||
|
- If no seed is provided, a system random source such as C(/dev/urandom) is used.
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = '''
|
||||||
|
- name: Random MAC given a prefix
|
||||||
|
debug:
|
||||||
|
msg: "{{ '52:54:00' | community.general.random_mac }}"
|
||||||
|
# => '52:54:00:ef:1c:03'
|
||||||
|
|
||||||
|
- name: With a seed
|
||||||
|
debug:
|
||||||
|
msg: "{{ '52:54:00' | community.general.random_mac(seed=inventory_hostname) }}"
|
||||||
|
'''
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from random import Random, SystemRandom
|
from random import Random, SystemRandom
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue