mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
correctly document random doc range (#33308)
* correctly document random doc range fixes #33226 * Edited for clarity.
This commit is contained in:
parent
a773bd7ad5
commit
08f1d1972e
1 changed files with 6 additions and 6 deletions
|
@ -160,26 +160,26 @@ To get a random item from a list::
|
|||
"{{ ['a','b','c']|random }}"
|
||||
# => 'c'
|
||||
|
||||
To get a random number from 0 to supplied end::
|
||||
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::
|
||||
|
||||
{{ 100 |random(step=10) }}
|
||||
{{ 101 |random(step=10) }}
|
||||
# => 70
|
||||
|
||||
Get a random number from 1 to 100 but in steps of 10::
|
||||
|
||||
{{ 100 |random(1, 10) }}
|
||||
{{ 101 |random(1, 10) }}
|
||||
# => 31
|
||||
{{ 100 |random(start=1, step=10) }}
|
||||
{{ 101 |random(start=1, step=10) }}
|
||||
# => 51
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue