Hadron / carthage

Carthage is an Infrastructure as Code (IAC) framework
Other
8 stars 4 forks source link

Add tail_ansible_log #25

Open hartmans opened 2 years ago

hartmans commented 2 years ago

It would be nice to be able to tail a log to stdout (or a web page) while some ansible task is running. I'm imagining carthage.ansible gaining a tail_ansible_log function. You start run_playbook (or a role task) as a future, start up tail_ansible_log, and then when the future for the ansible task completes, you kill off the tail, code something like:

ansible_task = loop.create_task(ainjector(run_playbook, ...))
try:
    tail_task = loop.create_task(ainjector(tail_ansible_log, sys.stdout))
    return await ansible_task
finally:
    tail_task.cancel()

cc: @kdienes who will certainly wish that update_aptly already did this. I plan to implement as soon as I have the support in core.