-
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
Warning for x509.certificate_managed in Salt 3001.1 #58165
Comments
The function docstring says that
I don't see |
I'm experiencing the same bug. The error message ("[…] 'replace' has been set to 'False' […]") stems from Now, when a certificate is valid (not expired, nothing changed, etc.) there's nothing to do except maybe altering some attributes of the file itself. (Just using Well, if you don't set content in AFAICS this is exactly what happens in https://github.com/saltstack/salt/blob/master/salt/states/x509.py#L675. I might be able to come up with a PR, but I have severe time constraints. If anyone is faster than me to start working on this, please let me know beforehand so we don't double the work. :-) Thanks! |
Still present in 3002.2 The solution is probably to correctly set |
is there a workaround available? |
This sort of logic should work. The problem is right now you also have to avoid #62590, which this doesn't quite do, as this state is frequently used with if current_is_valid:
file_args["contents"] = current_cert_pem
else:
file_args["contents"] = new_cert_pem
... # do append_certs
if __opts__["test"]:
if __salt__["file.file_exists"](name):
file_args["replace"] = False
ret = _certificate_file_managed(ret, file_args)
else:
ret = _certificate_file_managed(ret, file_args) |
Description
After updating to 3001.1, I now see a warning for x509.certificate_managed. This occurs whether or not replace: False is specified. Previously we didn't have to specify replace: False
salt-call state.apply ca
[WARNING ] State for file: /etc/pki/ca.crt - Neither 'source' nor 'contents' nor 'contents_pillar' nor 'contents_grains' was defined, yet 'replace' was set to 'True'. As there is no source to replace the file with, 'replace' has been set to 'False' to avoid reading the file unnecessarily.
[WARNING ] State for file: /etc/pki/ca.crt - Neither 'source' nor 'contents' nor 'contents_pillar' nor 'contents_grains' was defined, yet 'replace' was set to 'True'. As there is no source to replace the file with, 'replace' has been set to 'False' to avoid reading the file unnecessarily.
Setup
Attached ca.init.sls
ca.init.sls.txt
Steps to Reproduce the behavior
[INFO ] Completed state [/etc/pki/issued_certs] at time 16:58:30.441131 (duration_in_ms=2.562)
[DEBUG ] LazyLoaded x509.get_pem_entry
[DEBUG ] LazyLoaded x509.private_key_managed
[INFO ] Running state [/etc/pki/ca.crt] at time 16:58:30.445676
[WARNING ] State for file: /etc/pki/ca.crt - Neither 'source' nor 'contents' nor 'contents_pillar' nor 'contents_grains' was defined, yet 'replace' was set to 'True'. As there is no source to replace the file with, 'replace' has been set to 'False' to avoid reading the file unnecessarily.
[INFO ] Running state [/etc/pki/ca.crt] at time 16:58:30.463342
[INFO ] Executing state x509.certificate_managed for [/etc/pki/ca.crt]
[WARNING ] State for file: /etc/pki/ca.crt - Neither 'source' nor 'contents' nor 'contents_pillar' nor 'contents_grains' was defined, yet 'replace' was set to 'True'. As there is no source to replace the file with, 'replace' has been set to 'False' to avoid reading the file unnecessarily.
[INFO ] Certificate /etc/pki/ca.crt is valid and up to date
[INFO ] Completed state [/etc/pki/ca.crt] at time 16:58:30.472753 (duration_in_ms=9.411)
Expected behavior
Behavior is almost as expected minus the warning message.
Screenshots
NA
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Additional context
NA
The text was updated successfully, but these errors were encountered: