mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
ssh_pre_flight: fail on retcode not stderr
This commit is contained in:
parent
1e13d5e473
commit
2e66002894
3 changed files with 21 additions and 7 deletions
1
changelog/58439.fixed
Normal file
1
changelog/58439.fixed
Normal file
|
@ -0,0 +1 @@
|
|||
When using ssh_pre_flight if there is a failure, fail on retcode not stderr.
|
|
@ -1058,7 +1058,7 @@ class Single:
|
|||
)
|
||||
else:
|
||||
stdout, stderr, retcode = self.run_ssh_pre_flight()
|
||||
if stderr:
|
||||
if retcode != 0:
|
||||
log.error(
|
||||
"Error running ssh_pre_flight script {}".format(
|
||||
self.ssh_pre_file
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Test for ssh_pre_flight roster option
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
|
@ -18,7 +16,7 @@ class SSHPreFlightTest(SSHCase):
|
|||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(SSHPreFlightTest, self).setUp()
|
||||
super().setUp()
|
||||
self.roster = os.path.join(RUNTIME_VARS.TMP, "pre_flight_roster")
|
||||
self.data = {
|
||||
"ssh_pre_flight": os.path.join(RUNTIME_VARS.TMP, "ssh_pre_flight.sh")
|
||||
|
@ -31,7 +29,7 @@ class SSHPreFlightTest(SSHCase):
|
|||
self.custom_roster(self.roster, self.data)
|
||||
|
||||
with salt.utils.files.fopen(self.data["ssh_pre_flight"], "w") as fp_:
|
||||
fp_.write("touch {0}".format(self.test_script))
|
||||
fp_.write("touch {}".format(self.test_script))
|
||||
|
||||
@slowTest
|
||||
def test_ssh_pre_flight(self):
|
||||
|
@ -40,7 +38,7 @@ class SSHPreFlightTest(SSHCase):
|
|||
ensure the script runs successfully
|
||||
"""
|
||||
self._create_roster()
|
||||
ret = self.run_function("test.ping", roster_file=self.roster)
|
||||
assert self.run_function("test.ping", roster_file=self.roster)
|
||||
|
||||
assert os.path.exists(self.test_script)
|
||||
|
||||
|
@ -55,11 +53,26 @@ class SSHPreFlightTest(SSHCase):
|
|||
self.run_function("test.ping", wipe=False)
|
||||
assert not os.path.exists(self.test_script)
|
||||
|
||||
ret = self.run_function(
|
||||
assert self.run_function(
|
||||
"test.ping", ssh_opts="--pre-flight", roster_file=self.roster, wipe=False
|
||||
)
|
||||
assert os.path.exists(self.test_script)
|
||||
|
||||
@slowTest
|
||||
def test_ssh_run_pre_flight_failure(self):
|
||||
"""
|
||||
test ssh_pre_flight when there is a failure
|
||||
in the script.
|
||||
"""
|
||||
self._create_roster()
|
||||
with salt.utils.files.fopen(self.data["ssh_pre_flight"], "w") as fp_:
|
||||
fp_.write("exit 2")
|
||||
|
||||
ret = self.run_function(
|
||||
"test.ping", ssh_opts="--pre-flight", roster_file=self.roster, wipe=False
|
||||
)
|
||||
assert ret["retcode"] == 2
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
make sure to clean up any old ssh directories
|
||||
|
|
Loading…
Add table
Reference in a new issue