salt.modules.minion#
Module to provide information about minions and handle killing and restarting minions
- salt.modules.minion.kill(timeout=15)#
Kill the salt minion.
- timeout
int seconds to wait for the minion to die.
If you have a monitor that restarts
salt-minionwhen it dies then this is a great way to restart after a minion upgrade.CLI Example:
salt minion[12] minion.kill minion1: ---------- killed: 7874 retcode: 0 minion2: ---------- killed: 29071 retcode: 0
The result of the salt command shows the process ID of the minions and the results of a kill signal to the minion in as the
retcodevalue:0is success, anything else is a failure.
- salt.modules.minion.list_()#
Return a list of accepted, denied, unaccepted and rejected keys. This is the same output as salt-key -L
CLI Example:
salt 'master' minion.list
- salt.modules.minion.restart(systemd=True, win_service=True, schedule_retry=False, retry_delay=180)#
Restart the salt minion.
The method to restart the minion will be chosen as follows:
If
minion_restart_commandis set in the minion configuration then the command specified will be used to restart the minion.If the minion is running as a systemd service then the minion will be restarted using the systemd_service module, unless
systemdis set toFalseIf the minion is running as a Windows service then the minion will be restarted using the win_service module, unless
win_serviceis set toFalseIf the salt-minion process is running in daemon mode (the
-dargument is present inargv) then the minion will be killed and restarted using the same command line arguments, if possible.If the salt-minion process is running in the foreground (the
-dargument is not present inargv) then the minion will be killed but not restarted. This behavior is intended for minion processes that are managed by a process supervisor.- systemd
If set to
Falsethen systemd will not be used to restart the minion. Defaults toTrue.- win_service
If set to
Falsethen the Windows service manager will not be used to restart the minion. Defaults toTrue.- schedule_retry
If set to
Truethen a scheduled job will be added to start the minion if it has failed to restart after the retry_delay- retry_delay
The amount of time to wait before attempting to start the minion if it has failed to restart. Defaults to 180 seconds.
CLI Examples:
salt minion[12] minion.restart minion1: ---------- comment: - Using systemctl to restart salt-minion - Service restart successful killed: None restart: ---------- retcode: 0 service_restart: ---------- result: True minion2: ---------- comment: - Using windows service manager to restart salt-minion - Service restart successful killed: None restart: ---------- retcode: 0 service_restart: ---------- result: True
The result shows that
minion1was restarted using systemd andminion2was restarted using the Windows service manager. Theservice_restartfield indicates the result of the service restart operation. Thekilledfield isNonebecause the minion was restarted using the service manager and not by killing the process. Therestartfield is empty because the minion was restarted using the service manager and not by running the command line arguments of the minion process.salt minion[12] minion.restart minion1: ---------- comment: - Restart using process argv: - /home/omniture/install/bin/salt-minion - -d - -c - /home/omniture/install/etc/salt killed: 10070 restart: ---------- stderr: stdout: retcode: 0 minion2: ---------- comment: - Using configuration minion_restart_command: - /home/omniture/install/bin/salt-minion - --not-an-option - -d - -c - /home/omniture/install/etc/salt - Restart failed killed: 10896 restart: ---------- stderr: Usage: salt-minion salt-minion: error: no such option: --not-an-option stdout: retcode: 64
The result of the command shows the process ID of
minion1that is shutdown (killed) and the results of the restart. If there is a failure in the restart it will be reflected in a non-zeroretcodeand possibly output in thestderrand/orstdoutvalues along with addition information in thecommentfield as is demonstrated withminion2.