Hacker News new | past | comments | ask | show | jobs | submit login
Lineinfile be damned (chrisshort.net)
3 points by oaf357 on Sept 6, 2016 | hide | past | favorite | 3 comments



It seems to me that the regular expressions used in the module's "regexp" and "insertafter"/"insertbefore" parameters could mess it all up in case the config files contain comments with the used strings, e.g. "# Following won't work without SSLEngine enabled".

Perhaps use the beginning-of-line anchor, e.g. "^[ \t]SSLEngine on[ \t]".

The trailing whitespace can be problematic as well - what if I have a line " SSLEngine on", that is, no whitespace after "on" ?


This is a valid concern. Thanks for pointing it out. I will update the article.


Glad to have helped. I find that whenever you do something non-trivial with regular expressions, it is a good idea to have someone else look at it, as no two minds work alike, and they can see what you don't.

I see you only updated the regex in one of the playbook tasks in your article. The issue I pointed out apply to all of the tasks, however, and also for "regexp", as well as "insertafter/before" parameters.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: