[BUG] `x509.private_key_managed` states do not honor all `file.managed` arguments
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
In the documentation, it's said for x509.private_key_managed salt states:
Any kwargs supported by file.managed are supported.
But it's wrong it only honors part of it
salt/states/x509.py:225:def _get_file_args(name, **kwargs):
salt/states/x509.py-226- valid_file_args = [
salt/states/x509.py-227- "user",
salt/states/x509.py-228- "group",
salt/states/x509.py-229- "mode",
salt/states/x509.py-230- "makedirs",
salt/states/x509.py-231- "dir_mode",
salt/states/x509.py-232- "backup",
salt/states/x509.py-233- "create",
salt/states/x509.py-234- "follow_symlinks",
salt/states/x509.py-235- "check_cmd",
salt/states/x509.py-236- ]
salt/states/x509.py-237- file_args = {}
salt/states/x509.py-238- extra_args = {}
salt/states/x509.py-239- for k, v in kwargs.items():
salt/states/x509.py-240- if k in valid_file_args:
salt/states/x509.py-241- file_args[k] = v
salt/states/x509.py-242- else:
salt/states/x509.py-243- extra_args[k] = v
salt/states/x509.py-244- file_args["name"] = name
salt/states/x509.py-245- return file_args, extra_args
Not sure every kwargs of file.managed are needed here but to me at least replace could be helpful if we do not want to replace the key when it already exists
(Right now as a workaround I use an unless: test -f "my_key_path" on my x509.private_key_managed state)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in salt/states/x509.py at _get_file_args and compare its accepted arguments with the file.managed arguments described in the documentation. Check how x509.private_key_managed handles replace and other file.managed kwargs; done means the supported arguments are honored consistently with the documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100