Skip to content
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

Add modify_inactive_option option to ini_file module to ignore matching commented key:value pairs #7401

Conversation

njutn95
Copy link
Contributor

@njutn95 njutn95 commented Oct 17, 2023

SUMMARY

Add new modify_inactive_option option to the ini_file module which, when set to false, will not modify a matching commented-out (inactive) option, and will instead add a new line for the given option: value.

For example, with the file.ini that looks like this

[section]
# foo = bar

The following task

ini_file:
    path: file.ini
    section: section
    option: foo
    value: bar
    modify_inactive_option: true

will produce the following output

[section]
foo = bar

Whereas

ini_file:
    path: file.ini
    section: section
    option: foo
    value: bar
    modify_inactive_option: false

Will produce this

[section]
foo = bar
# foo = bar

Fixes #7297

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ini_file

ADDITIONAL INFORMATION

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request integration tests/integration module module plugins plugin (any type) tests tests labels Oct 17, 2023
@felixfontein felixfontein added the check-before-release PR will be looked at again shortly before release and merged if possible. label Oct 18, 2023
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@njutn95
Copy link
Contributor Author

njutn95 commented Oct 18, 2023

Thank you for reviewing it!

@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Oct 19, 2023
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will merge this mid of next week if nobody objects.

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Oct 19, 2023
@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Oct 25, 2023
@felixfontein felixfontein merged commit 6ee1f27 into ansible-collections:main Oct 25, 2023
@felixfontein
Copy link
Collaborator

@njutn95 thanks for your contribution!

etrombly pushed a commit to etrombly/community.general that referenced this pull request Oct 25, 2023
…tching commented key:value pairs (ansible-collections#7401)

* Add `modify_inactive_option` option to `ini_file` module to ignore matching commented key:value pairs

* Add changelog fragment

* Apply suggestions from code review

Co-authored-by: Felix Fontein <[email protected]>

* Minor comment fix

* Apply suggestions from code review

Co-authored-by: Felix Fontein <[email protected]>

---------

Co-authored-by: Felix Fontein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request has_issue integration tests/integration module module plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breaking change in ini_file removes comments
3 participants