pyinfra-dev / pyinfra-dev/pyinfra
Combined output for facts with custom success codes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6k
- Forks
- 548
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 13
Description
Problem
Currently, when getting facts, only the stdout is returned in case of success. Now beccause we support success_exit_codes in fact fetching like this after #755:
from pyinfra import facts, host
fact = host.get_fact(
facts.server.Command,
"somefailingcommand",
success_exit_codes=[0, 27, 55])
# Now fact only contains stdout and won't contain stderr.
The fact only has stdout but becuse the "succuess" was kind hacked by suggesting a list of OK codes, the only stdout is returned but the actualy output of the command is on stderr which is igonred.
Possible solutions
One possible solution is to add something like returned_combined_output kind of keyword argument that combines stdout and stderr regardless of the status code. That would require changes in pyinfra itself.
Other workaround is to issue your shell commands like this by redirecting and combining stdout and stderr together:
somefailingcommand 2>&1
I am not sure, open to ideas and suggestions.
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 by tracing facts.server.Command and the success_exit_codes behavior introduced after #755. Decide how combined stdout and stderr should be exposed when a custom success code is accepted. Done means the chosen behavior is implemented and covered for successful commands whose output is on stderr.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100