Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds doc for new slice filter #35904

Merged
merged 4 commits into from
Feb 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/docsite/rst/playbooks_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ To create a UUID from a string (new in version 1.9)::
To cast values as certain types, such as when you input a string as "True" from a vars_prompt and the system
doesn't know it is a boolean value::

- debug:
- debug:
msg: test
when: some_string_value | bool

Expand All @@ -904,6 +904,17 @@ To make use of one attribute from each item in a list of complex variables, use
# get a comma-separated list of the mount points (e.g. "/,/mnt/stuff") on a host
{{ ansible_mounts|map(attribute='mount')|join(',') }}

.. versionadded:: 2.5

The `slice` filter can be used to extract the values of specific keys from a
hash::

{{ {'x': 1, 'y': 2, 'z': 3 } | slice(['x', 'z']) }}

This will result in::

[1, 2]

To get date object from string use the `to_datetime` filter, (new in version in 2.2)::

# get amount of seconds between two dates, default date format is %Y-%m-%d %H:%M:%S but you can pass your own one
Expand All @@ -919,7 +930,7 @@ This set of filters returns a list of combined lists.
To get permutations of a list::

- name: give me largest permutations (order matters)
debug:
debug:
msg: "{{ [1,2,3,4,5]|permutations|list }}"

- name: give me permutations of sets of three
Expand Down