From 6987150d40f49a4b6fa92d9a18665f317b18090f Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Fri, 4 Jun 2021 00:12:27 +0530 Subject: [PATCH] [bp-2.11] filters: Add a note about seed (#74874) While using ``seed`` parameter of the 'random' filter, behavior changes between Python 2 and Python 3. Added a note about this in the documentation. Fixes: #63784 Signed-off-by: Abhijeet Kasurde Co-authored-by: Sandra McCann Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com> --- docs/docsite/rst/user_guide/playbooks_filters.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst index 26b9b75c256..083a2d264d2 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters.rst @@ -875,6 +875,10 @@ You can initialize the random number generator from a seed to create random-but- "{{ 60 | random(seed=inventory_hostname) }} * * * * root /script/from/cron" +.. note:: + + If you use the ``seed`` parameter, you will get a different result with Python 3 and Python 2. This may break procedures such as password generation when you upgrade the version of Python used on your Ansible controller. + Shuffling a list ---------------- @@ -894,6 +898,9 @@ You can initialize the shuffle generator from a seed to generate a random-but-id The shuffle filter returns a list whenever possible. If you use it with a non 'listable' item, the filter does nothing. +.. note:: + + If you use the ``seed`` parameter, you will get a different result with Python 3 and Python 2. This may break procedures such as password generation when you upgrade the version of Python used on your Ansible controller. .. _list_filters: @@ -1326,6 +1333,10 @@ An idempotent method to generate unique hashes per system is to use a salt that {{ 'secretpassword' | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) }} # => "$6$43927$lQxPKz2M2X.NWO.gK.t7phLwOKQMcSq72XxDZQ0XzYV6DlL1OD72h417aj16OnHTGxNzhftXJQBcjbunLEepM0" +.. note:: + + If you use the ``seed`` parameter, you will get a different result with Python 3 and Python 2. This may break procedures such as password generation when you upgrade the version of Python used on your Ansible controller. + Hash types available depend on the control system running Ansible, 'hash' depends on `hashlib `_, password_hash depends on `passlib `_. The `crypt `_ is used as a fallback if ``passlib`` is not installed. .. versionadded:: 2.7