mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 06:31:23 -07:00
parent
2f33c1a1a1
commit
5553b20828
206 changed files with 1853 additions and 1870 deletions
|
@ -25,20 +25,20 @@
|
|||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import glob
|
||||
import select
|
||||
import os
|
||||
import pickle
|
||||
import platform
|
||||
import select
|
||||
import shlex
|
||||
import subprocess
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.six import PY2, b
|
||||
from ansible.module_utils._text import to_bytes, to_text
|
||||
|
||||
|
||||
def sysv_is_enabled(name):
|
||||
'''
|
||||
This function will check if the service name supplied
|
||||
|
@ -48,6 +48,7 @@ def sysv_is_enabled(name):
|
|||
'''
|
||||
return bool(glob.glob('/etc/rc?.d/S??%s' % name))
|
||||
|
||||
|
||||
def get_sysv_script(name):
|
||||
'''
|
||||
This function will return the expected path for an init script
|
||||
|
@ -62,6 +63,7 @@ def get_sysv_script(name):
|
|||
|
||||
return result
|
||||
|
||||
|
||||
def sysv_exists(name):
|
||||
'''
|
||||
This function will return True or False depending on
|
||||
|
@ -71,6 +73,7 @@ def sysv_exists(name):
|
|||
'''
|
||||
return os.path.exists(get_sysv_script(name))
|
||||
|
||||
|
||||
def fail_if_missing(module, found, service, msg=''):
|
||||
'''
|
||||
This function will return an error or exit gracefully depending on check mode status
|
||||
|
@ -87,6 +90,7 @@ def fail_if_missing(module, found, service, msg=''):
|
|||
else:
|
||||
module.fail_json(msg='Could not find the requested service %s: %s' % (service, msg))
|
||||
|
||||
|
||||
def daemonize(module, cmd):
|
||||
'''
|
||||
Execute a command while detaching as a deamon, returns rc, stdout, and stderr.
|
||||
|
@ -100,10 +104,10 @@ def daemonize(module, cmd):
|
|||
'''
|
||||
|
||||
# init some vars
|
||||
chunk = 4096 #FIXME: pass in as arg?
|
||||
chunk = 4096 # FIXME: pass in as arg?
|
||||
errors = 'surrogate_or_strict'
|
||||
|
||||
#start it!
|
||||
# start it!
|
||||
try:
|
||||
pipe = os.pipe()
|
||||
pid = os.fork()
|
||||
|
@ -162,7 +166,7 @@ def daemonize(module, cmd):
|
|||
fds = [p.stdout, p.stderr]
|
||||
|
||||
# loop reading output till its done
|
||||
output = { p.stdout: b(""), p.sterr: b("") }
|
||||
output = {p.stdout: b(""), p.sterr: b("")}
|
||||
while fds:
|
||||
rfd, wfd, efd = select.select(fds, [], fds, 1)
|
||||
if (rfd + wfd + efd) or p.poll():
|
||||
|
@ -207,6 +211,7 @@ def daemonize(module, cmd):
|
|||
# py2 and py3)
|
||||
return pickle.loads(to_bytes(return_data, errors=errors))
|
||||
|
||||
|
||||
def check_ps(module, pattern):
|
||||
|
||||
# Set ps flags
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue