From 08f1d1972edd59ab90742dc684f93d5898135b12 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 28 Nov 2017 04:26:36 -0500 Subject: [PATCH] correctly document random doc range (#33308) * correctly document random doc range fixes #33226 * Edited for clarity. --- docs/docsite/rst/playbooks_filters.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/docsite/rst/playbooks_filters.rst b/docs/docsite/rst/playbooks_filters.rst index e14fe6a4df..3b3be825fd 100644 --- a/docs/docsite/rst/playbooks_filters.rst +++ b/docs/docsite/rst/playbooks_filters.rst @@ -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