mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 15:04:02 -07:00
[PR #10743/469e557b backport][stable-11] monit: handle arbitrary error status (#10760)
monit: handle arbitrary error status (#10743)
* handle arbitrary error status
* add changelog fragment
* mock module in test
* Update changelogs/fragments/10743-monit-handle-unknown-status.yml
---------
(cherry picked from commit 469e557b95
)
Co-authored-by: Simon Kelly <skelly@dimagi.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
d90eb6444a
commit
dda872c3e6
3 changed files with 10 additions and 2 deletions
|
@ -174,7 +174,11 @@ class Monit(object):
|
|||
status_val = status_val.split(' | ')[0]
|
||||
if ' - ' not in status_val:
|
||||
status_val = status_val.replace(' ', '_')
|
||||
return getattr(Status, status_val)
|
||||
try:
|
||||
return getattr(Status, status_val)
|
||||
except AttributeError:
|
||||
self.module.warn("Unknown monit status '%s', treating as execution failed" % status_val)
|
||||
return Status.EXECUTION_FAILED
|
||||
else:
|
||||
status_val, substatus = status_val.split(' - ')
|
||||
action, state = substatus.split()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue