ansible.builtin.comment filter – comment out a string
Note
This filter plugin is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
plugin name
comment
.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.comment
for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same filter plugin name.
Synopsis
Use programming language conventions to turn the input string into an embeddable comment.
Input
This describes the input of the filter, the value before | ansible.builtin.comment
.
Parameter |
Comments |
---|---|
String to comment. |
Positional parameters
This describes positional parameters of the filter. These are the values positional1
, positional2
and so on in the following
example: input | ansible.builtin.comment(positional1, positional2, ...)
Parameter |
Comments |
---|---|
Comment style to use. Choices:
|
Keyword parameters
This describes keyword parameters of the filter. These are the values key1=value1
, key2=value2
and so on in the following
example: input | ansible.builtin.comment(key1=value1, key2=value2, ...)
Parameter |
Comments |
---|---|
Indicator of the start of a comment block, only available for styles that support multiline comments. |
|
Indicator for comment or intermediate comment depending on the style. |
|
Indicator the end of a comment block, only available for styles that support multiline comments. |
|
Indicator of comment end of line, only available for styles that support multiline comments. Default: |
|
Indicator of the end of each line inside a comment block, only available for styles that support multiline comments. |
|
Number of times to add a postfix at the end of a line, when a prefix exists and is usable. Default: |
|
Token to start each line inside a comment block, only available for styles that support multiline comments. |
|
Number of times to add a prefix at the start of a line, when a prefix exists and is usable. Default: |
Notes
Note
When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters:
input | ansible.builtin.comment(positional1, positional2, key1=value1, key2=value2)
Examples
# commented => #
# # Plain style (default)
# #
commented: "{{ 'Plain style (default)' | comment }}"
# not going to show that here ...
verycustom: "{{ "Custom style" | comment('plain', prefix='#######\n#', postfix='#\n#######\n ###\n #') }}"
Return Value
Key |
Description |
---|---|
The ‘commented out’ string. Returned: success |
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.