-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ini_file: Incorrect handling when multiple options with the same name exist #273
Comments
Files identified in the description: If these files are inaccurate, please update the |
There is no "The INI format", there are many different interpretations out there what valid INI formats should be. In particular, there is no consensus whether multiple options with the same name can exist or not (see https://en.wikipedia.org/wiki/INI_file#Duplicate_names). So this is rather a feature request than a bug, because the module documents nowhere that it supports duplicate names. Also, as the module interface is right now (with BTW, there used to be a PR adding this feature: ansible/ansible#19536 Unfortunately it does not mention the interface and all changes are gone (maybe accidentally rebased to nil). |
I've contacted author of the PR and they don't have the fork anymore. Also tried unsuccessfully reaching @StoneISStephan about it, so I guess the PR is really gone. |
Loks like whole StonelSStephan/ansible repository is gone as well. Last comments suggest that there wer some unseolved problems with that PR anyway. |
BTW: how about multpiple sections with same name? ini_file module doesn't care about them at all, all changes seem to be applied only to first [section] appeareance. Any suggestions how to handle them properly? (combine together in one section in output OR leave multiple sections but treat all the options as if they were in one section OR fail with error?) Wikipedia says that 'Interpretation of multiple section declarations with the same name also varies' as well, so all possibilities may apply :/ |
Hmm, multiple sections with the same name sound... not that simple to handle, indeed. For multiple values (in one section), a good interface would probably be having two options (mainly for backwards compatibility): For multiple sections, it probably makes sense to provide an index so that the |
This would require repeating all
About multiple section with some name: they aren't very popular anyway, so maybe just have ini_file module operate on first |
Hi there, I wanted to comment that systemd configuration frequently uses multiple options with a same name on their configuration files. Without support for multiple options with the same name in Support for multiple same-name options in Example case 1An administrator can define startup ordering by specifying multiple
Example case 2Environment variables for processes started via systemd can be defined by adding one or more
Example case 3An administrator willing to override a package-maintained configuration parameter usually create an override file, sets a blank value in order to clear the default values and, then, sets desired values after the blank one. Details are documented in systemd.unit(5) man page.
|
- restructure tests - fix error message call: fail_json() takes 1 positional argument but 2 were given
- add module option 'exclusive' (boolean) for the abbility to add single option=value entries without overwriting existing options with the same name but different values - add abbility to define multiple options with the same name but different values
* ini_file - prepare for fixing #273 - restructure tests - fix error message call: fail_json() takes 1 positional argument but 2 were given * ini_file - multiple values for one option (#273) - add module option 'exclusive' (boolean) for the abbility to add single option=value entries without overwriting existing options with the same name but different values - add abbility to define multiple options with the same name but different values * ini_file - add more tests for ini_file * ini_file - fix sanity tests * apply suggested changes: - rename 03-regressions.yml to 03-encoding.yml - fix typos - fix documentation * apply suggested changes: - test errors also for result is failed * apply suggested changes: - make state=absent also work with module option exclusive - add more tests for state=absent and module option exclusive * fix sanity test: - 02-values.yml:251:9: hyphens: too many spaces after hyphen * apply proposed changes * apply proposed changes from review - adjust version_added to 3.6.0 - small syntax change in changelog fragment
* ini_file - prepare for fixing #273 - restructure tests - fix error message call: fail_json() takes 1 positional argument but 2 were given * ini_file - multiple values for one option (#273) - add module option 'exclusive' (boolean) for the abbility to add single option=value entries without overwriting existing options with the same name but different values - add abbility to define multiple options with the same name but different values * ini_file - add more tests for ini_file * ini_file - fix sanity tests * apply suggested changes: - rename 03-regressions.yml to 03-encoding.yml - fix typos - fix documentation * apply suggested changes: - test errors also for result is failed * apply suggested changes: - make state=absent also work with module option exclusive - add more tests for state=absent and module option exclusive * fix sanity test: - 02-values.yml:251:9: hyphens: too many spaces after hyphen * apply proposed changes * apply proposed changes from review - adjust version_added to 3.6.0 - small syntax change in changelog fragment (cherry picked from commit 25267b8)
) * ini_file - prepare for fixing #273 - restructure tests - fix error message call: fail_json() takes 1 positional argument but 2 were given * ini_file - multiple values for one option (#273) - add module option 'exclusive' (boolean) for the abbility to add single option=value entries without overwriting existing options with the same name but different values - add abbility to define multiple options with the same name but different values * ini_file - add more tests for ini_file * ini_file - fix sanity tests * apply suggested changes: - rename 03-regressions.yml to 03-encoding.yml - fix typos - fix documentation * apply suggested changes: - test errors also for result is failed * apply suggested changes: - make state=absent also work with module option exclusive - add more tests for state=absent and module option exclusive * fix sanity test: - 02-values.yml:251:9: hyphens: too many spaces after hyphen * apply proposed changes * apply proposed changes from review - adjust version_added to 3.6.0 - small syntax change in changelog fragment (cherry picked from commit 25267b8) Co-authored-by: Daniel Ziegenberg <[email protected]>
SUMMARY
Option handling is inconsistent when there's multiple of them and there is seemingly no way to keep multiple options.
ISSUE TYPE
COMPONENT NAME
ini_file
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Arch Linux
STEPS TO REPRODUCE
Play:
How the file /etc/pacman.conf looks before the play:
After:
I'd like the play not to clobber existing Options, but there does not seem to be a way to do that.
Additionally, if the file looks like this, with the matching entry first, nothing is changed, which is inconsistent.
The text was updated successfully, but these errors were encountered: