Note
This module is part of ansible-base and included in all Ansible installations. In most cases, you can use the short module name sequence even without specifying the collections: keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.
New in version 1.0: of ansible.builtin
{{ 1 + item|int }}.range filter as an alternative.| Parameter | Choices/Defaults | Configuration | Comments |
|---|---|---|---|
| count integer | Default: 0 | number of elements in the sequence, this is not to be used with end | |
| end integer | Default: 0 | number at which to end the sequence, dont use this with count | |
| format string | return a string with the generated number formatted in | ||
| start integer | Default: 0 | number at which to start the sequence | |
| stride integer | increments between sequence numbers, the default is 1 unless the end is less than the start, then it is -1. |
- name: create some test users
user:
name: "{{ item }}"
state: present
groups: "evens"
with_sequence: start=0 end=32 format=testuser%02x
- name: 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
- name: a simpler way to use the sequence plugin create 4 groups
group:
name: "group{{ item }}"
state: present
with_sequence: count=4
- name: the final countdown
debug: msg={{item}} seconds to detonation
with_sequence: end=0 start=10
- name: Use of variable
debug:
msg: "{{ item }}"
with_sequence: start=1 end="{{ end_at }}"
vars:
- end_at: 10
Common return values are documented here, the following are the fields unique to this lookup:
| Key | Returned | Description |
|---|---|---|
| _list list / elements=string | success | A list containing generated sequence of items |
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/ansible/builtin/sequence_lookup.html