Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for non-zero Salt return codes #706

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion testinfra/modules/salt.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Salt(InstanceModule):
Run ``salt-call sys.doc`` to get a complete list of functions
"""

def __call__(self, function, args=None, local=False, config=None):
def __call__(self, function, args=None, local=False, config=None, expect_rc=None):
args = args or []
if isinstance(args, str):
args = [args]
Expand All @@ -44,6 +44,8 @@ def __call__(self, function, args=None, local=False, config=None):
cmd_args.append(config)
cmd += " %s" + len(args) * " %s"
cmd_args += [function] + args
if expect_rc is not None:
return json.loads(self.run_expect(expect_rc, cmd, *cmd_args).stdout)
return json.loads(self.check_output(cmd, *cmd_args))["local"]

def __repr__(self):
Expand Down