-
Notifications
You must be signed in to change notification settings - Fork 24k
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
Allow multiple options in ini_file #19536
Conversation
how does this interact with deletion and updates? |
The behavior is exactly the same when unique=yes (default) |
The test
|
cc @jpmens are you up for reviewing and/or testing this change out and let us know so we can take action on this? |
choices: [ "yes", "no" ] | ||
default: "yes" | ||
description: | ||
- If set to 'no', the option could appears several times in the section with diferent values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change the world could by may.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Looks good to me. Small language nit in doc; if you'd please fix that. |
shipit |
hey I was wondering in which ansible version i can expect this feature? |
When will this PR get merged? Edit: I tested this by manually merging the changes.
ansible-playbook output (-vv):
For my use case, this is not an issue, but I can imaging that you'd only want to have "state changed" when there was an actual change. This might be fixable if values got written to the bottom of a section, instead of at the beginning. Edit2: From what I see, the code does not really know where a section ends. Would be nice if the code extracted the current section ini_lines option_changed = newline not in section_ini_lines in order not to change values that are already defined in all sections [customer1] if we'd run a playbook that defines for customer1 the permissions that are already granted, [customer1] on the second call of ini_file module, as the module writes to <section_index + 1> |
There is also a typo in the PR: mgs = 'option added' should be: msg = 'option added' |
msg = 'option changed' | ||
ini_lines[index] = newline | ||
else: | ||
mgs = 'option added' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be:
msg = 'option added'
closed my mistake... |
Some ini files will allow an option to appear several times
with different values (e.g. systemd services files)
Add a new option, 'unique', defaulting to yes, to specifie if
a option can appears once or multiples times.
ISSUE TYPE
COMPONENT NAME
ini_file
ANSIBLE VERSION
2.4.0
SUMMARY
Options in a ini file can appear multiple times in the same section. Until now, only one was allowed, deleting the rest.
[default]
path=/usr/bin
path=/usr/sbin
This change is