community.general
community.general copied to clipboard
ini_file - support optional spaces around section names
ini_file - Support optional spaces between section names and their surrounding brackets
SUMMARY
Some ini files have spaces between some of their section names and the brackets that enclose them. This is documented in the openssl.cnf(5)
man page. In order to manage files such as openssl.cnf
with ini_file before now, one would have to include spaces in the section name like this:
section: ' crypto_policy '
option: Options
value: UnsafeLegacyRenegotiation
This change implements matching section headers with such optional spaces, removing the need to include those spaces in the task's section:
parameter. Existing tasks using the workaround above will continue to work, even in cases where spaces in section headers are subsequently removed.
ISSUE TYPE
- Bugfix Pull Request
COMPONENT NAME
ini_file
ADDITIONAL INFORMATION
Here's an actual "legacy" production ini_file task
. Note the spaces in the section name. These spaces have been necessary because the target file has these spaces already.
- name: Configure UnsafeLegacyRenegotiation in /etc/pki/tls/openssl.cnf
community.general.ini_file:
path: /etc/pki/tls/openssl.cnf
section: ' crypto_policy '
option: Options
value: UnsafeLegacyRenegotiation
state: present
exclusive: false
create: false
backup: true
After this change, those spaces are no longer necessary. Furthermore, the above task will continue to work even if someone removes the spaces from the target file's crypto_policy
section header.