mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Fix 'sequence' lookup shortcut syntax and documentation (#22989)
* fix 'sequence' lookup shortcut syntax and documentation * Update playbooks_loops.rst Minor edits for grammar and clarity. * Update playbooks_loops.rst Another tweak for clarity.
This commit is contained in:
parent
1abc73da68
commit
c1b3d6a51f
3 changed files with 37 additions and 17 deletions
|
@ -277,10 +277,12 @@ The authorized_key pattern is exactly where it comes up most.
|
|||
Looping over Integer Sequences
|
||||
``````````````````````````````
|
||||
|
||||
``with_sequence`` generates a sequence of items in ascending numerical order. You
|
||||
can specify a start, end, and an optional step value.
|
||||
``with_sequence`` generates a sequence of items. You
|
||||
can specify a start value, an end value, an optional "stride" value that specifies the number of steps to increment the sequence, and an optional printf-style format string.
|
||||
|
||||
Arguments should be specified in key=value pairs. If supplied, the 'format' is a printf style string.
|
||||
Arguments should be specified as key=value pair strings.
|
||||
|
||||
A simple shortcut form of the arguments string is also accepted: ``[start-]end[/stride][:format]``.
|
||||
|
||||
Numerical values can be specified in decimal, hexadecimal (0x3f8) or octal (0600).
|
||||
Negative numbers are not supported. This works as follows::
|
||||
|
@ -303,27 +305,20 @@ Negative numbers are not supported. This works as follows::
|
|||
name: "{{ item }}"
|
||||
state: present
|
||||
groups: "evens"
|
||||
with_sequence:
|
||||
- start: 0
|
||||
- end: 32
|
||||
- format: testuser%02x
|
||||
with_sequence: start=0 end=32 format=testuser%02x
|
||||
|
||||
# create a series of directories with even numbers for some reason
|
||||
- file:
|
||||
dest: "/var/stuff/{{ item }}"
|
||||
state: directory
|
||||
with_sequence:
|
||||
- start: 4
|
||||
- end: 16
|
||||
- stride: 2
|
||||
with_sequence: start=4 end=16 stride=2
|
||||
|
||||
# a simpler way to use the sequence plugin
|
||||
# create 4 groups
|
||||
- group:
|
||||
name: "group{{ item }}"
|
||||
state: present
|
||||
with_sequence:
|
||||
count: 4
|
||||
with_sequence: count=4
|
||||
|
||||
.. _random_choice:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue