# Found the 'lineinfile' module previously non-intuitive? It's better now.

**URL:** <https://forum.ansible.com/t/found-the-lineinfile-module-previously-non-intuitive-its-better-now/11874>\
**Category:** Ansible Project\
**Created:** [September 8, 2012, 1:37pm UTC](https://forum.ansible.com/t/found-the-lineinfile-module-previously-non-intuitive-its-better-now/11874 "2012-09-08T13:37:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 8, 2012, 1:37pm UTC](https://forum.ansible.com/t/found-the-lineinfile-module-previously-non-intuitive-its-better-now/11874/1 "2012-09-08T13:37:08Z")

</div>

I've just pushed a fix that changes the "regexp does not match line"  
logic to allow the regexp to match a /portion/ of the line, so you no  
longer have to write out a full regex.

This is what it should have been anyway, and makes the module much  
easier to use.

Example:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action: lineinfile name=/var/lib/pgsql/data/pg\_hba.conf  
line="host ansible\_commander ansible\_commander 127.0.0.1/32 password"  
insertafter=BOF regexp="ansible\_commander"

No visible regex evil anywhere, and you can still change the database  
line and it won't try to put it back.

Just be careful and supply a decent enough regular expression or it  
will not stop adding lines.
