I am using the community.general.ini_file plugin to alter the configuration of InfluxDB (in /etc/influxdb/influxdb.conf). I have modify_inactive_option enabled to replace commented out options with the ones I write in the playbook, yet ansible still adds the options on a new line instead of replacing the ones that are there.
At first I thought there was a problem with the # symbol used for commented out options instead of semicolons.
Then I looked at the regex used and I realized the problem was not in the comment symbol, but in the fact that there are spaces in front of it.
My request is to change the regex matcher used in the match_opt function of plugins/modules/ini_file.py from the current value of
re.match('([#;]?)( |\t)*(%s)( |\t)*(=|$)( |\t)*(.*)' % option, line)
to something like
re.match('( |\t)*([#;]?)( |\t)*(%s)( |\t)*(=|$)( |\t)*(.*)' % option, line)
to allow for spaces in front of the comment symbol.
I was also thinking it could be useful to use \s to match whitespace instead of the currently used group ( |\t), unless of course there is a reason to only matches spaces and tabs, but not other whitespace characters.
I can imagine my case with InfluxDB is just one out of many different types of ini formats, so I think it would be valuable to get feedback on the impact of this change for others before implementing it.
Issue Type
Feature Idea
Component Name
ini_file
Additional Information
Current behaviour (on fresh InfluxDB install where all four of these options have been commented out):
options are added on a new line, the commented versions are not replaced
Requested behaviour:
commented options are replaced even when whitespace occurs before # or ;
Extract of /etc/influxdb/influxdb.conf on fresh install:
[data]
# Whether queries should be logged before execution. Very useful for troubleshooting, but will
# log any sensitive data contained within a query.
# query-log-enabled = true
[http]
# Determines whether the Flux query endpoint is enabled.
# flux-enabled = false
# Determines whether user authentication is enabled over HTTP/HTTPS.
# auth-enabled = false
# Determines whether HTTP request logging is enabled.
# log-enabled = true
Summary
I am using the community.general.ini_file plugin to alter the configuration of InfluxDB (in /etc/influxdb/influxdb.conf). I have modify_inactive_option enabled to replace commented out options with the ones I write in the playbook, yet ansible still adds the options on a new line instead of replacing the ones that are there. At first I thought there was a problem with the
#
symbol used for commented out options instead of semicolons. Then I looked at the regex used and I realized the problem was not in the comment symbol, but in the fact that there are spaces in front of it.My request is to change the regex matcher used in the match_opt function of plugins/modules/ini_file.py from the current value of
re.match('([#;]?)( |\t)*(%s)( |\t)*(=|$)( |\t)*(.*)' % option, line)
to something likere.match('( |\t)*([#;]?)( |\t)*(%s)( |\t)*(=|$)( |\t)*(.*)' % option, line)
to allow for spaces in front of the comment symbol. I was also thinking it could be useful to use\s
to match whitespace instead of the currently used group( |\t)
, unless of course there is a reason to only matches spaces and tabs, but not other whitespace characters.I can imagine my case with InfluxDB is just one out of many different types of ini formats, so I think it would be valuable to get feedback on the impact of this change for others before implementing it.
Issue Type
Feature Idea
Component Name
ini_file
Additional Information
Current behaviour (on fresh InfluxDB install where all four of these options have been commented out): options are added on a new line, the commented versions are not replaced
Requested behaviour: commented options are replaced even when whitespace occurs before # or ;
Example playbook:
Extract of /etc/influxdb/influxdb.conf on fresh install:
Code of Conduct