Skip to content

comment

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version historical.

Synopsis

  • Use programming language conventions to turn the input string into an embeddable comment.

Parameters

Parameter Defaults / Choices Comments
_input
string
required
String to comment.
beginning
string
Indicator of the start of a comment block, only available for styles that support multiline comments.
decoration
string
Indicator for comment or intermediate comment depending on the style.
end
string
Indicator the end of a comment block, only available for styles that support multiline comments.
newline
string
Default: \n
Indicator of comment end of line, only available for styles that support multiline comments.
postfix
string
Indicator of the end of each line inside a comment block, only available for styles that support multiline comments.
postfix_count
int
Default: 1
Number of times to add a postfix at the end of a line, when a prefix exists and is usable.
prefix
string
Token to start each line inside a comment block, only available for styles that support multiline comments.
prefix_count
int
Default: 1
Number of times to add a prefix at the start of a line, when a prefix exists and is usable.
style
string
Default: plain
Choices: plain, decoration, erlang, c, cblock, xml
Comment style to use.

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 Values

Key Data Type Description Returned
_value string The 'commented out' string.