mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Revert range change (#50155)
* Revert "Fix incorrect examples with random filter (#50137)" This reverts commit9a7dbd5213
. The correction is incomplete and also based on a 'fix' that was supposed to have been reverted already * Revert "Added `+1` to the `end` in `random` filter so that it was inclusive (#27215)" This reverts commitea2b89c7ae
. reverted fix as agreed at the time, but missed by maintainers.
This commit is contained in:
parent
eab3b02cb3
commit
b0c28f86de
2 changed files with 3 additions and 3 deletions
|
@ -395,7 +395,7 @@ To get a random item from a list::
|
||||||
|
|
||||||
To get a random number between 0 and a specified number::
|
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'
|
# => '21 * * * * root /script/from/cron'
|
||||||
|
|
||||||
Get a random number from 0 to 100 but in steps of 10::
|
Get a random number from 0 to 100 but in steps of 10::
|
||||||
|
@ -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::
|
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
|
Shuffle Filter
|
||||||
|
|
|
@ -213,7 +213,7 @@ def rand(environment, end, start=None, step=None, seed=None):
|
||||||
start = 0
|
start = 0
|
||||||
if not step:
|
if not step:
|
||||||
step = 1
|
step = 1
|
||||||
return r.randrange(start, end + 1, step)
|
return r.randrange(start, end, step)
|
||||||
elif hasattr(end, '__iter__'):
|
elif hasattr(end, '__iter__'):
|
||||||
if start or step:
|
if start or step:
|
||||||
raise AnsibleFilterError('start and step can only be used with integer values')
|
raise AnsibleFilterError('start and step can only be used with integer values')
|
||||||
|
|
Loading…
Reference in a new issue