From 63134a3a6c44f23a5ad1c33dad3f659f906db078 Mon Sep 17 00:00:00 2001 From: Thayne Harbaugh Date: Tue, 9 Feb 2016 14:51:39 -0700 Subject: [PATCH 1/3] Add minion.kill to modules --- salt/modules/minion.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/salt/modules/minion.py b/salt/modules/minion.py index fbdbf26848..0387288bcd 100644 --- a/salt/modules/minion.py +++ b/salt/modules/minion.py @@ -85,3 +85,19 @@ def _check_minions_directories_raetkey(pki_dir): rejected = os.path.join(pki_dir, salt.key.RaetKey.REJ) return accepted, pre, rejected + + +def kill(): + ''' + Kill the salt minion. + + If you have a monitor that restarts salt-minion when it dies then this is a great way to + restart. + ''' + pid = __grains__.get('pid') + if pid: + if 'ps.kill_pid' in __salt__: + __salt__['ps.kill_pid'](pid) + else: + pid = None + return {'killed':pid} From 679fb7b6396c05dd540f17e75255c8204b24df2d Mon Sep 17 00:00:00 2001 From: Thayne Harbaugh Date: Tue, 9 Feb 2016 16:25:06 -0700 Subject: [PATCH 2/3] Improve minion.kill documentation. --- salt/modules/minion.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/salt/modules/minion.py b/salt/modules/minion.py index 0387288bcd..1547214b49 100644 --- a/salt/modules/minion.py +++ b/salt/modules/minion.py @@ -91,8 +91,23 @@ def kill(): ''' Kill the salt minion. - If you have a monitor that restarts salt-minion when it dies then this is a great way to - restart. + If you have a monitor that restarts ``salt-minion`` when it dies then this is + a great way to restart after a minion upgrade. + + CLI example:: + + >$ salt minion[12] minion.kill + minion1: + ---------- + killed: + 7874 + minion2: + ---------- + killed: + 29071 + + The result of the salt command shows the process ID of the minions that were + successfully killed - in this case they were ``7874`` and ``29071``. ''' pid = __grains__.get('pid') if pid: From a52e577edbb2df92196237d32840d624e435df29 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 10 Feb 2016 12:05:57 -0700 Subject: [PATCH 3/3] Lint --- salt/modules/minion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/minion.py b/salt/modules/minion.py index 1547214b49..05e397726a 100644 --- a/salt/modules/minion.py +++ b/salt/modules/minion.py @@ -109,10 +109,10 @@ def kill(): The result of the salt command shows the process ID of the minions that were successfully killed - in this case they were ``7874`` and ``29071``. ''' - pid = __grains__.get('pid') + pid = __grains__.get('pid') if pid: if 'ps.kill_pid' in __salt__: __salt__['ps.kill_pid'](pid) else: pid = None - return {'killed':pid} + return {'killed': pid}