Fixed modules using Popen (#24558)
* Fixed modules using Popen * Reverted change in mysql_db, Popen is required to pipe compressed archives to mysqlpull/4420/head
parent
495a809f46
commit
921bc0599b
|
@ -97,8 +97,6 @@ EXAMPLES = '''
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
class BackendProp(object):
|
class BackendProp(object):
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
|
@ -114,9 +112,8 @@ class BackendProp(object):
|
||||||
'--backend-name', backend_name,
|
'--backend-name', backend_name,
|
||||||
'-n', '-X', '-s'
|
'-n', '-X', '-s'
|
||||||
] + password_method
|
] + password_method
|
||||||
process = subprocess.Popen(my_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
rc, stdout, stderr = self._module.run_command(my_command)
|
||||||
stdout, stderr = process.communicate()
|
if rc == 0:
|
||||||
if process.returncode == 0:
|
|
||||||
return stdout
|
return stdout
|
||||||
else:
|
else:
|
||||||
self._module.fail_json(msg="Error message: " + str(stderr))
|
self._module.fail_json(msg="Error message: " + str(stderr))
|
||||||
|
@ -132,9 +129,8 @@ class BackendProp(object):
|
||||||
'--set', name + ":" + value,
|
'--set', name + ":" + value,
|
||||||
'-n', '-X'
|
'-n', '-X'
|
||||||
] + password_method
|
] + password_method
|
||||||
process = subprocess.Popen(my_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
rc, stdout, stderr = self._module.run_command(my_command)
|
||||||
stdout, stderr = process.communicate()
|
if rc == 0:
|
||||||
if process.returncode == 0:
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
self._module.fail_json(msg="Error message: " + stderr)
|
self._module.fail_json(msg="Error message: " + stderr)
|
||||||
|
|
|
@ -50,13 +50,10 @@ EXAMPLES = '''
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
def gather_lldp(module):
|
||||||
def gather_lldp():
|
|
||||||
cmd = ['lldpctl', '-f', 'keyvalue']
|
cmd = ['lldpctl', '-f', 'keyvalue']
|
||||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
rc, output, err = module.run_command(cmd)
|
||||||
(output, err) = proc.communicate()
|
|
||||||
if output:
|
if output:
|
||||||
output_dict = {}
|
output_dict = {}
|
||||||
lldp_entries = output.split("\n")
|
lldp_entries = output.split("\n")
|
||||||
|
@ -80,7 +77,7 @@ def gather_lldp():
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule({})
|
module = AnsibleModule({})
|
||||||
|
|
||||||
lldp_output = gather_lldp()
|
lldp_output = gather_lldp(module)
|
||||||
try:
|
try:
|
||||||
data = {'lldp': lldp_output['lldp']}
|
data = {'lldp': lldp_output['lldp']}
|
||||||
module.exit_json(ansible_facts=data)
|
module.exit_json(ansible_facts=data)
|
||||||
|
|
|
@ -104,12 +104,10 @@ RETURN = '''
|
||||||
...
|
...
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from subprocess import Popen, PIPE
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, BOOLEANS_TRUE
|
from ansible.module_utils.basic import AnsibleModule, BOOLEANS_TRUE
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GConf2Preference(object):
|
class GConf2Preference(object):
|
||||||
def __init__(self, ansible, key, value_type, value,
|
def __init__(self, ansible, key, value_type, value,
|
||||||
direct=False, config_source=""):
|
direct=False, config_source=""):
|
||||||
|
@ -158,11 +156,7 @@ class GConf2Preference(object):
|
||||||
cmd += "--unset {0}".format(self.key)
|
cmd += "--unset {0}".format(self.key)
|
||||||
|
|
||||||
# Start external command
|
# Start external command
|
||||||
process = Popen([cmd], stdout=PIPE, stderr=PIPE, shell=True)
|
rc, out, err = self.ansible.run_command(cmd, use_unsafe_shell=True)
|
||||||
|
|
||||||
# In either case, we will capture the output
|
|
||||||
out = process.stdout.read()
|
|
||||||
err = process.stderr.read()
|
|
||||||
|
|
||||||
if len(err) > 0:
|
if len(err) > 0:
|
||||||
if fail_onerr:
|
if fail_onerr:
|
||||||
|
|
Loading…
Reference in New Issue