saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.11k stars 5.47k forks source link

Showing progress with 'salt' command #46665

Open kfdm opened 6 years ago

kfdm commented 6 years ago

One very minor advantage Ansible has for new users is that when you run a command, ansible-playbook it gives you progress about what steps are executing.

If you run the command on the minion side with salt-call, you can get some general output by adding -l info though it's a touch noisy if you don't know what you're looking for.

If you add state_events: True to your master configuration, then you can view the general progress by running salt-run state.events though this can also be a touch noisy.

If you run salt ... there is only the final report when everything is finished.

What would it take to be able to more easily watch the progress of a running state? Is this something that would make sense as an extension to the salt command or perhaps building it as a salt-run command would be better.

The local client provides a cmd_async command that returns a jobid which could be used to filter events

Are there perhaps any other race conditions that one would need to be aware of?

Copied from: https://groups.google.com/d/msgid/salt-users/afa89988-d358-40de-a451-9417bdb90206%40googlegroups.com.

oijkn commented 1 year ago

What is the X/28 tasks complete?

floridop commented 1 year ago

Hi and thanks for looking into this. It is one of my main reasons to use ansible instead on machines that can be reached directly via ssh.

It would be nice to have something like machineX/stateY status

At least printed out when states have been completed or failed or anything, however they did

It would of course be nicer to know which task in the state is being processed, but for me is more about debugging in that case.

winternet-studio commented 1 year ago

This is definitely needed. Why aren't the devs picking up on this?

What information do people want? X/28 tasks complete Or List of all task ID and status e.g. Running/InProgress, Stable/Same/Identical, Changed/Mocked, Skipped, Failed

Not jut the number of tasks completed, but like an event log for each task that is being done. Output should include the minion name, the current task ID that is running, the time stamp, the event type (started/finished/failed/etc) and maybe a few other key information that could be available and useful. It should be sort of an abbreviated version of the report that is shown after the command is complete - but should all fit in one line per event. I guess that line could even include "task X of 28" (for the given minion) in abbreviated format "X/28", to show the total progress.

Best would be to see this on the salt master where the command is executed, but even if I would have to run a command on the minions to see this info I would be very happy. Even if we would simply need to just do a tail -f on a log file I would be exhilarated!! Seems like writing to a log file at least would be something very easy to implement!

raqua commented 1 year ago

I hacked the log myself hooking to the events, so this is how it looks. That is what I would like it to look.

13:36:33 Starting Salt...
13:36:33 Started at: Tue May  9 13:36:33 CEST 2023
13:36:33 
13:36:41 Preparing ...
13:36:59    1/396       dev --> Install Nginx
13:36:59    2/396       dev --> Setup Nginx configuration file
13:37:00    3/396       dev --> Setup Exite configuration file for Nginx
13:37:00    4/396       dev --> Setup main.key for Nginx
13:37:00    5/396       dev --> Setup main.crt for Nginx
13:37:01    6/396       dev --> Setup Inbound.xsl for Nginx
13:37:01    7/396       dev --> Setup Outbound.xsl for Nginx
13:37:01    8/396       dev --> Setup inbound-outbound.xsd for Nginx
13:37:01    9/396       dev --> Start Nginx
13:37:02   10/396       dev --> Install Haproxy
13:37:02   11/396       dev --> Setup haproxy configuration file
13:37:02   12/396       dev --> Set up exite.pem certificate for haproxy
13:37:02   13/396       dev --> Ensure Haproxy is running
13:37:02   14/396       dev --> Ensure Haproxy is running
13:37:03   15/396       dev --> Ensure "tree" package is installed
13:37:03   16/396       dev --> Cron job that removes old log files
13:37:03   17/396       dev --> Ensure there is no hourly triggered log rotation
13:37:03   18/396       dev --> Ensure there is no daily triggered log rotation
13:37:03   19/396       dev --> Remove old log rotation for containers logs
13:37:04   20/396       dev --> Add default Linux log rotation caller and logger script
13:37:04   21/396       dev --> Cron job that will trigger default Linux log rotation on exact time
13:37:04   22/396       dev --> Add log rotation caller and logger script
13:37:04   23/396       dev --> Cron job that will trigger log rotation on exact time
13:37:04   24/396       dev --> Install bind
13:37:05   25/396       dev --> Setup Bind configuration file
13:37:05   26/396       dev --> Setup Bind internal overrides zone file
13:37:06   27/396       dev --> Install Java
13:37:06   28/396       dev --> Start docker
13:37:06   29/396       dev --> Installing Docker python module
13:37:06   30/396       dev --> Add startDockers.sh script
13:37:06   31/396       dev --> Ensure Jenkins user exists
.....

My solution has some issues, namely that it only shows what was already finished and not what goes on and that the number of expected events are only guessed based on previous run, which is highly incorrect and only makes sense if one does test run before.