Skip to content

Commit

Permalink
Merge pull request ansible#7705 from smoothify/random-nocache
Browse files Browse the repository at this point in the history
Ensure random jinja filter doesn't get cached in loops.
  • Loading branch information
jimi-c committed Jun 10, 2014
2 parents 2c9cba0 + e3530dc commit 3fe7d53
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ansible/runner/filter_plugins/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ansible.utils import md5s
from distutils.version import LooseVersion, StrictVersion
from random import SystemRandom
from jinja2.filters import environmentfilter

def to_nice_yaml(*a, **kw):
'''Make verbose, human readable yaml'''
Expand Down Expand Up @@ -185,7 +186,8 @@ def version_compare(value, version, operator='eq', strict=False):
except Exception, e:
raise errors.AnsibleFilterError('Version comparison: %s' % e)

def rand(end, start=None, step=None):
@environmentfilter
def rand(environment, end, start=None, step=None):
r = SystemRandom()
if isinstance(end, (int, long)):
if not start:
Expand Down

0 comments on commit 3fe7d53

Please sign in to comment.