mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #29135 from jfindlay/ssh_except
ssh_known_hosts.present state: catch not found exc
This commit is contained in:
commit
f19355e0bb
1 changed files with 10 additions and 4 deletions
|
@ -25,6 +25,7 @@ import os
|
|||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
from salt.exceptions import CommandNotFoundError
|
||||
|
||||
|
||||
def present(
|
||||
|
@ -116,10 +117,15 @@ def present(
|
|||
ret['result'] = False
|
||||
return dict(ret, comment=comment)
|
||||
|
||||
result = __salt__['ssh.check_known_host'](user, name,
|
||||
key=key,
|
||||
fingerprint=fingerprint,
|
||||
config=config)
|
||||
try:
|
||||
result = __salt__['ssh.check_known_host'](user, name,
|
||||
key=key,
|
||||
fingerprint=fingerprint,
|
||||
config=config)
|
||||
except CommandNotFoundError as err:
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'ssh.check_known_host error: {0}'.format(err)
|
||||
return ret
|
||||
|
||||
if result == 'exists':
|
||||
comment = 'Host {0} is already in {1}'.format(name, config)
|
||||
|
|
Loading…
Add table
Reference in a new issue