86

Sometimes my saltmaster hangs for a while on salt '*' test.ping waiting for downed minions to reply. Is there a way so see a list of connected minions, regardless of whether they respond to test.ping?

0

6 Answers 6

101

The official answer:

salt-run manage.up

Also useful are:

salt-run manage.status

salt-run manage.down
3
  • 2
    "salt-run -d" Gives a full list of all the modules you can run with salt-run, well worth a read Oct 23, 2015 at 6:12
  • 6
    salt-run manage.versions is also quite useful (reports minions' running versions and compares them to the master's)
    – sxc731
    Nov 7, 2016 at 14:29
  • 2
    Note that salt-run manage.up and manage.status appears to do a test.ping under the hood. At least, when I ran manage.up, it showed on the minions logs as test.ping..... If you want to ensure it doesn't need to send anything, use alived or one of the other manage functions
    – sdfgeoff
    Apr 26, 2019 at 8:04
13

From the master type:

ls -1 /var/cache/salt/master/minions

or:

ls -1 /etc/salt/pki/master/minions

Entering a faulty salt query (ex. salt '*' -) will also return a list of all the minions each followed by a message stating that the command is not available. You can grep/cut away the extraneous characters. Neither of these options are particularly elegant and the later doesn't address the timeout but it works while I'm looking for an answer to a similar question; "How to list all associated minions via the saltstack python api?".

2
  • I think something must have changed /var/cache/salt/master/minions appears to be a non-existent location now, /etc/salt/pki/master/minions is still good to go.
    – Oly Dungey
    Nov 30, 2015 at 16:46
  • @OlyDungey Maybe it is distribution dependent. What Linux distribution were you using at that time ?
    – SebMa
    Sep 2, 2022 at 8:52
9

There are few new commands that makes it much more easier,

salt-run manage.alived Print a list of all minions that are up according to Salt's presence detection (no commands will be sent to minions)

salt-run manage.allowed Print a list of all minions that are up according to Salt's presence detection (no commands will be sent to minions)

salt-run manage.not_alived Print a list of all minions that are NOT up according to Salt's presence detection (no commands will be sent)

salt-run manage.not_allowed Print a list of all minions that are NOT up according to Salt's presence detection (no commands will be sent)

salt-run manage.not_joined Print a list of all minions that are NOT up according to Salt's presence detection (no commands will be sent)

7

"salt-key -L" will list all minions that whose public keys you've accepted on your master.

1
  • 2
    Thanks, but this lists accepted minion keys, not connected minions. Aug 28, 2013 at 9:37
5

I think one can use the grains module to achieve this:

salt '*' grains.get id
-6

To make ping to all minions, try on salt master node:

salt '*' test.ping 
1
  • 5
    Have you read the question? It specifically is about alternatives to your method because this doesn't work in some cases.
    – Sven
    Jul 22, 2016 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.