The Ansible lineinfile module is designed to search a file for a line, and ensure that it is present or absent. lineinfile is very effective at that particular task. However, when the line has to be in a certain place or before or after a certain line, lineinfile becomes a hassle to manage.
Most people on IRC (#ansible) tend to agree, lineinfile is not a very good module in practice. Even Brain Coca says to avoid the lineinfile module. But, there is one use case I have found where line in file really excels.
If you are not using the Mozilla SSL Configuration Generator you are really missing out. It is a great tool that is super easy to use to maintain recommended SSL/TLS configurations on all your HTTP endpoints.
We recently had a task