From e62a56e15c634a75bc3be7bbbc056ba982480af8 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 27 Apr 2022 17:13:05 -0400 Subject: [PATCH] Add docs for ansible-core 2.13 use (#4202) * 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 --- plugins/filter/random_mac.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/filter/random_mac.py b/plugins/filter/random_mac.py index 7d25555aa9..fdcff4d9da 100644 --- a/plugins/filter/random_mac.py +++ b/plugins/filter/random_mac.py @@ -20,6 +20,35 @@ from __future__ import (absolute_import, division, print_function) __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 from random import Random, SystemRandom