Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert range change #50155

Merged
merged 2 commits into from Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docsite/rst/user_guide/playbooks_filters.rst
Expand Up @@ -395,7 +395,7 @@ To get a random item from a list::

To get a random number between 0 and a specified number::

"{{ 59 | random }} * * * * root /script/from/cron"
"{{ 60 | random }} * * * * root /script/from/cron"
# => '21 * * * * root /script/from/cron'

Get a random number from 0 to 100 but in steps of 10::
Expand All @@ -412,7 +412,7 @@ Get a random number from 1 to 100 but in steps of 10::

As of Ansible version 2.3, it's also possible to initialize the random number generator from a seed. This way, you can create random-but-idempotent numbers::

"{{ 59 | random(seed=inventory_hostname) }} * * * * root /script/from/cron"
"{{ 60 | random(seed=inventory_hostname) }} * * * * root /script/from/cron"


Shuffle Filter
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/plugins/filter/core.py
Expand Up @@ -213,7 +213,7 @@ def rand(environment, end, start=None, step=None, seed=None):
start = 0
if not step:
step = 1
return r.randrange(start, end + 1, step)
return r.randrange(start, end, step)
elif hasattr(end, '__iter__'):
if start or step:
raise AnsibleFilterError('start and step can only be used with integer values')
Expand Down