-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[BUG] file.comment ignore_missing not working #65501
Comments
It seems that it is getting past this block where it would return early due to Lines 6177 to 6188 in 53f54d0
@nicholasmhughes any ideas? |
I think the regex hates your The
and matches the line even when it shouldn't because we're using a negative look-ahead (which I kinda hate, but can't think of a good way to avoid...) The test cases are single characters without newline characters. I'll have to play with this some more to see the best way to fix it for this use case. |
@nicholasmhughes ah, I see! To help with testing, here is another example: openssh-server_comment_authenticationmethods_sshd_config:
file.comment:
- name: "/etc/ssh/sshd_config"
- regex: ^AuthenticationMethods[ \t]+.*$
- char: "# NEXT LINE COMMENT SALTSTACK openssh-server_comment_authenticationmethods_sshd_config\n# "
- ignore_missing: True Though in this case this match is not present in the file at all (commented or uncommented). Because of that maybe this one is not having the same issue for me. |
Near as I can tell, this might be best fixed by adding another parameter. Essentially what you're trying to do is comment the line with one |
Yeah, that would make sense. I can't immediately think of any caveats to decouple the search and find/replace. It'd probably be a good idea to include a newline example in the updated documentation so it is clear why you would separate them. That's easy to make backward compatible too:
|
played around with the regex some more and I think |
…ltiline char (cherry picked from commit c5fbfa1) # Conflicts: # salt/states/file.py
…ltiline char (cherry picked from commit c5fbfa1) # Conflicts: # salt/states/file.py
(cherry picked from commit c5fbfa1) # Conflicts: # salt/states/file.py
Description
The
ignore_missing
option onfile.comment
is not working.Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Please be as specific as possible and give set-up details.
Steps to Reproduce the behavior
Line in
/etc/ssh/sshd_config
is already commented out (not via Saltstack) so there is no match:Expected behavior
State should pass.
Screenshots
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Additional context
Related pull: #62045
The text was updated successfully, but these errors were encountered: