correctly document random doc range (#33308)

* correctly document random doc range

fixes #33226

* Edited for clarity.
pull/33335/head
Brian Coca 7 years ago committed by scottb
parent a773bd7ad5
commit 08f1d1972e

@ -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…
Cancel
Save