summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDeric Crago <deric.crago@gmail.com>2018-09-27 11:52:50 -0400
committerToshio Kuratomi <a.badger@gmail.com>2018-11-05 15:10:52 -0800
commit58cd460952ace1bbbd682e2cfa468297e5937638 (patch)
treef11fff4264d4d29595a9aa36828645c74bbdc58c /docs
parente3a2bf97a79a9e2cf02c3377533a29b013aa8523 (diff)
downloadansible-58cd460952ace1bbbd682e2cfa468297e5937638.tar.gz
moved 'strftime' filter into 'Other Useful Filters' section (#45801)
(cherry picked from commit 065b7ac3001eebe8fb8de3a93098e49814811b4b)
Diffstat (limited to 'docs')
-rw-r--r--docs/docsite/rst/user_guide/playbooks_filters.rst42
1 files changed, 21 insertions, 21 deletions
diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst
index a48f149ad7..4d42eeb5d2 100644
--- a/docs/docsite/rst/user_guide/playbooks_filters.rst
+++ b/docs/docsite/rst/user_guide/playbooks_filters.rst
@@ -1012,7 +1012,7 @@ To search a string with a regex, use the "regex_search" filter::
# will return empty if it cannot find a match
{{ 'ansible' | regex_search('(foobar)') }}
-
+
# case insensitive search in multiline mode
{{ 'foo\nBAR' | regex_search("^bar", multiline=True, ignorecase=True) }}
@@ -1036,7 +1036,7 @@ To replace text in a string with regex, use the "regex_replace" filter::
# convert "localhost:80" to "localhost"
{{ 'localhost:80' | regex_replace(':80') }}
-
+
# add "https://" prefix to each item in a list
{{ hosts | map('regex_replace', '^(.*)$', 'https://\\1') | list }}
@@ -1161,6 +1161,25 @@ To get date object from string use the `to_datetime` filter, (new in version in
# get amount of days between two dates. This returns only number of days and discards remaining hours, minutes, and seconds
{{ (("2016-08-14 20:00:12" | to_datetime) - ("2015-12-25" | to_datetime('%Y-%m-%d'))).days }}
+.. versionadded:: 2.4
+
+To format a date using a string (like with the shell date command), use the "strftime" filter::
+
+ # Display year-month-day
+ {{ '%Y-%m-%d' | strftime }}
+
+ # Display hour:min:sec
+ {{ '%H:%M:%S' | strftime }}
+
+ # Use ansible_date_time.epoch fact
+ {{ '%Y-%m-%d %H:%M:%S' | strftime(ansible_date_time.epoch) }}
+
+ # Use arbitrary epoch value
+ {{ '%Y-%m-%d' | strftime(0) }} # => 1970-01-01
+ {{ '%Y-%m-%d' | strftime(1441357287) }} # => 2015-09-04
+
+.. note:: To get all string possibilities, check https://docs.python.org/2/library/time.html#time.strftime
+
Combination Filters
````````````````````
@@ -1186,25 +1205,6 @@ Combinations always require a set size::
Also see the :ref:`zip_filter`
-.. versionadded:: 2.4
-
-To format a date using a string (like with the shell date command), use the "strftime" filter::
-
- # Display year-month-day
- {{ '%Y-%m-%d' | strftime }}
-
- # Display hour:min:sec
- {{ '%H:%M:%S' | strftime }}
-
- # Use ansible_date_time.epoch fact
- {{ '%Y-%m-%d %H:%M:%S' | strftime(ansible_date_time.epoch) }}
-
- # Use arbitrary epoch value
- {{ '%Y-%m-%d' | strftime(0) }} # => 1970-01-01
- {{ '%Y-%m-%d' | strftime(1441357287) }} # => 2015-09-04
-
-.. note:: To get all string possibilities, check https://docs.python.org/2/library/time.html#time.strftime
-
Debugging Filters
`````````````````