geerlingguy/ansible-role-postgresql

Incorrect regex for global settings in configure.yml task file

jeanmonet opened this issue · 5 comments

- name: Configure global settings.
lineinfile:
dest: "{{ postgresql_config_path }}/postgresql.conf"
regexp: "^#?{{ item.option }}.+$"
line: "{{ item.option }} = '{{ item.value }}'"
state: "{{ item.state | default('present') }}"
mode: 0644
with_items: "{{ postgresql_global_config_options }}"
notify: restart postgresql

Should the following line:

regexp: "^#?{{ item.option }}.+$"

be improved as follows:

regexp: "^#?\s*{{ item.option }}\s*=.+$"
#            ^- potential space  ^-^-- space and "="

In order for regex to accurately match the correct line?

Otherwise, the regex would match any option having a certain prefix. For example the option ssl would match all other lines which start with 'ssl' such as ssl_cert_file, etc.

See for example: https://regex101.com/r/M4c2Ji/1

stale commented

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

revive :) unless this has been fixed already?

stale commented

This issue is no longer marked for closure.

stale commented

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale commented

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.