Log commands and results
Goal:
As an experimenter, I'd like to keep track on all the commands that as been run during an experiment.
Implementation hints:
All the remote actions are performed through two base functions run_play
and run_ansible
.
Currently only run_play
returns a Results
datastructure. Adding the same for run_ansible
seems doable.
So a nice way to implement this would be to decorate the two functions and intercept the Results
and dump them in a file somewhere. This behaviour need to be controlled through a configuration key which provide a way to enable the behaviour globally and locally.
from enoslib.config import set_config, config_context
# set a global log file
set_config(log_results=Path(log_file)
[results will be logged to log_file]
# this can be also overriden locally
with config_context(log_results=Path(another_file):
[results will be logged to another_file]