diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2021-06-04 00:12:27 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 13:42:27 -0500 |
commit | 6987150d40f49a4b6fa92d9a18665f317b18090f (patch) | |
tree | 3993ed3a072a61b63d1b9d346d8b5a809ffd5df6 /docs | |
parent | ee38c4244b2dcc69df4c307ced4b49217fa79134 (diff) | |
download | ansible-6987150d40f49a4b6fa92d9a18665f317b18090f.tar.gz |
[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 <akasurde@redhat.com>
Co-authored-by: Sandra McCann <samccann@redhat.com>
Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/docsite/rst/user_guide/playbooks_filters.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst index 26b9b75c25..083a2d264d 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 <https://docs.python.org/3.8/library/hashlib.html>`_, password_hash depends on `passlib <https://passlib.readthedocs.io/en/stable/lib/passlib.hash.html>`_. The `crypt <https://docs.python.org/3.8/library/crypt.html>`_ is used as a fallback if ``passlib`` is not installed. .. versionadded:: 2.7 |