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>
pull/58795/head
Klaas Demter 5 years ago committed by Felix Fontein
parent 8ff97edd1a
commit faf50dbace

@ -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 time
import os.path
import stat
from ansible.module_utils.basic import AnsibleModule
@ -389,6 +390,12 @@ class Nagios(object):
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:
fp = open(self.cmdfile, 'w')
fp.write(cmd)

Loading…
Cancel
Save