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

Breaking change in ini_file removes comments #7297

Closed
1 task done
rightaway opened this issue Sep 20, 2023 · 11 comments · Fixed by #7401
Closed
1 task done

Breaking change in ini_file removes comments #7297

rightaway opened this issue Sep 20, 2023 · 11 comments · Fixed by #7401
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type)

Comments

@rightaway
Copy link

Summary

Setting option: opt and value: value now removes a line matching it with a comment.

If the file has a description like this the whole # opt: val line will be removed. It's new breaking behavior. Not good because the removed line can be useful documentation.

# Set this value
# opt: val

Issue Type

Bug Report

Component Name

ini_file

Ansible Version

$ ansible --version
ansible [core 2.15.4]
  config file = /etc/ansible/ansible.cfg
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

Configuration

$ ansible-config dump --only-changed

OS / Environment

No response

Steps to Reproduce

Expected Results

Doesn't remove the line.

Actual Results

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) labels Sep 20, 2023
@felixfontein
Copy link
Collaborator

This is a result of #6575. As you can see in the discussion of that PR, depending on how the module was used it was already doing that before, and that behavior got broken at some point, so this change was in fact reverting an earlier breaking change.

If someone wants to implement that, it would probably be good to be able to configure the behavior, since both behaviors (using 'commented-out' options, or keeping them) have both good reasons for and against.

@njutn95
Copy link
Contributor

njutn95 commented Oct 17, 2023

@felixfontein I've made a PR (#7401) to make this a configurable option. @rightaway please confirm if this is what you were looking for.

@rightaway
Copy link
Author

Yes but please make modify_inactive_option false as default. It worked that way for years and most people have probably not noticed yet that it changed because it was so recent and are expecting old behavior. The recent change was breaking and it needs to go back to original to prevent destroying original configuration for thousands of files.

@felixfontein
Copy link
Collaborator

For the reason explained above (#7297 (comment)) the behavior it has now was intended for a long time, so it should not be disabled by default.

@njutn95
Copy link
Contributor

njutn95 commented Oct 19, 2023

@rightaway While I sort of agree with you that #6575 might be a breaking change (even though it was a fix of a breaking change), this has already undergone two 'breaking changes', making a third one will make things even worse IMO, especially considering that it's been half a year since then, so it's not a bug fix anymore.

@rightaway
Copy link
Author

Can a global option be added to ansible config so it doesn't need to be updated in thousands of places and many repositories without destroying original configuration?

@felixfontein
Copy link
Collaborator

No, there's no way to configure something like that for modules, but you can use module defaults to set that option for a play.

@rightaway
Copy link
Author

Default should never be something destructive that loses information. Merge was hasty. Is there RFC process for community to discuss these things for future breaking changes?

@felixfontein
Copy link
Collaborator

The process of proposing changes to a module is a Pull Request on GitHub. If you want to be informed for new PRs for the ini_file module, add yourself to notify: for ini_file here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type)
Projects
None yet
4 participants