From 229967145ec7150747c3fe6e0adf8bff932f55f6 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 21 Nov 2023 14:40:59 -0600 Subject: [PATCH] Add comment about pass_context --- lib/ansible/plugins/filter/core.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index 1aadde7cb7f..2305392a37c 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -230,6 +230,9 @@ def from_yaml_all(data): return data +# context prevents this filter from being treated as a constant +# and evaluated at compile time, and instead defers evaluation +# to execution time @pass_context def rand(context, end, start=None, step=None, seed=None): if seed is None: @@ -249,7 +252,9 @@ def rand(context, end, start=None, step=None, seed=None): else: raise AnsibleFilterError('random can only be used on sequences and integers') - +# context prevents this filter from being treated as a constant +# and evaluated at compile time, and instead defers evaluation +# to execution time @pass_context def randomize_list(context, mylist, seed=None): try: @@ -275,6 +280,9 @@ def get_hash(data, hashtype='sha1'): return h.hexdigest() +# context prevents this filter from being treated as a constant +# and evaluated at compile time, and instead defers evaluation +# to execution time @pass_context def get_encrypted_password(context, password, hashtype='sha512', salt=None, salt_size=None, rounds=None, ident=None): passlib_mapping = {