Fix nagios module to recognize if file exists and is fifo pipe (#58569)
add felixfontein suggestion to changelogs/fragments/58569-nagios-fifo-fix.yaml
Co-Authored-By: Felix Fontein <felix@fontein.de>
(cherry picked from commit faf50dbace
)
This commit is contained in:
parent
6d467a8bd9
commit
6d146c89f2
2 changed files with 9 additions and 0 deletions
2
changelogs/fragments/58569-nagios-fifo-fix.yaml
Normal file
2
changelogs/fragments/58569-nagios-fifo-fix.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- nagios module - Fix nagios module to recognize if ``cmdfile`` exists and is fifo pipe.
|
|
@ -196,6 +196,7 @@ EXAMPLES = '''
|
||||||
import types
|
import types
|
||||||
import time
|
import time
|
||||||
import os.path
|
import os.path
|
||||||
|
import stat
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
@ -389,6 +390,12 @@ class Nagios(object):
|
||||||
Write the given command to the Nagios command file
|
Write the given command to the Nagios command file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not os.path.exists(self.cmdfile):
|
||||||
|
self.module.fail_json(msg='nagios command file does not exist',
|
||||||
|
cmdfile=self.cmdfile)
|
||||||
|
if not stat.S_ISFIFO(os.stat(self.cmdfile).st_mode):
|
||||||
|
self.module.fail_json(msg='nagios command file is not a fifo file',
|
||||||
|
cmdfile=self.cmdfile)
|
||||||
try:
|
try:
|
||||||
fp = open(self.cmdfile, 'w')
|
fp = open(self.cmdfile, 'w')
|
||||||
fp.write(cmd)
|
fp.write(cmd)
|
||||||
|
|
Loading…
Reference in a new issue