From e20591d6dc8d597de3aeea267eed55359fb892e8 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 15 Nov 2023 18:32:46 -0600 Subject: [PATCH] Ensure that random filter isn't treated as a constant --- lib/ansible/plugins/filter/core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index 474e743962e..26718a92aae 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -21,7 +21,7 @@ from collections.abc import Mapping from functools import partial from random import Random, SystemRandom, shuffle -from jinja2.filters import pass_environment +from jinja2.filters import pass_environment, pass_context from ansible.errors import AnsibleError, AnsibleFilterError, AnsibleFilterTypeError from ansible.module_utils.six import string_types, integer_types, reraise, text_type @@ -230,8 +230,8 @@ def from_yaml_all(data): return data -@pass_environment -def rand(environment, end, start=None, step=None, seed=None): +@pass_context +def rand(context, end, start=None, step=None, seed=None): if seed is None: r = SystemRandom() else: