I have ORIGINAL .conf
file which includes multiple commented lines (header). I need to throw an error if the ORIGINAL "comments only" file has any uncommented lines added during the installation process. If there is any line other than starting with #
/comment, I want to throw a warning.
I was thinking if Ansible is able to do that.
So far, I came with some ideas:
Loop through the ORIGINAL file, creating a COPY of the current ORIGINAL file, but copy only lines starting with #
/comments (header) from the ORIGINAL (possibly any empty white space lines too)
After that, the COPY file will have only commented lines(header) and empty/white space lines, excluded of any other lines.
Then do the diff/compare original and copy. If the COPY file which has only commented lines (header), doesn't match the ORIGINAL file, that means uncommented lines are present in the ORIGINAL and I need to throw an error.
Ohter ideas:
- warning if uncommented line was added after last commented line
- Lines in file present starting with character other than
#
- Count uncommented lines and throw error if more than 0 present
- End of file has changed warning
- Endoffile/ last line is in state as uncommented
I think that is in some ways a hack solution using Ansible.