avi
avi

Reputation: 9636

How do I get status, logs of last run `state.highstate` in Salt?

I applied state using:

$sudo salt 'api-*' state.highstate -l debug -v

Some states failed and I scrolled down, fixed some and now I can't scroll up (my terminal doesn't save full session) to see the stdout.

Now I don't want to run high state again. I checked jobs.lookup_jid, but it doesn't display anything useful.

Upvotes: 6

Views: 9380

Answers (3)

Bilal Baqar
Bilal Baqar

Reputation: 248

You can get the job id from jobs.list_jobs

$> salt-run jobs.list_jobs --out=json
{
    "20190308173940124336": {
        "Function": "state.apply", 
        "Target": "dev-baqar-service-0", 
        "User": "ubuntu", 
        "StartTime": "2019, Mar 08 17:39:40.124336", 
        "Target-type": "glob", 
        "Arguments": []
    }
}

and then run the following to get the highstate output:

salt-run jobs.lookup_jid 20190308173940124336 --out=highstate

Upvotes: 1

Erik
Erik

Reputation: 305

jobs.lookup_jid gives you the return data from that job. If you don't know the job ID, you can list recently-run jobs using salt-run jobs.list_jobs:

# salt-run jobs.list_jobs
20150924134212132446:
    ----------
    Arguments:
    Function:
        test.ping
    StartTime:
        2015, Sep 24 13:42:12.132446
    Target:
        saltmine
    Target-type:
        glob
    User:
        root

It's not clear which logs you want. If you want logs from the minion, you can try tailing the minion log using salt <minion_id> cmd.run 'tail -n100 /var/log/salt/minion.

Upvotes: 1

Christian Stade-Schuldt
Christian Stade-Schuldt

Reputation: 4861

You could check the log files at /var/log/salt/minion

Upvotes: 1

Related Questions