path: A file name in which we are going to find and replace
regexp: the regular expression to search the string you want
In our case,
() – Grouping of Regular Expression and to create backreferences, which will make it easy to perform backreference while replacing. ^ – Matches the Start of a Line ServerName – Matches a Literal String \s – Matches a whitespace .* – matches one or more of any character/numeral ( not new line) $ – matches the end of line
replace: A string, with which you want to replace the matched String
In our case,
\1 – backreference indicator and represents the first group we have matched. in our case, it is the result of (^ServerName\s)
backup: To tell ansible to backup the file before making any changes.