mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixed modules using Popen (#24558)
* Fixed modules using Popen * Reverted change in mysql_db, Popen is required to pipe compressed archives to mysql
This commit is contained in:
parent
495a809f46
commit
921bc0599b
3 changed files with 8 additions and 21 deletions
|
@ -97,8 +97,6 @@ EXAMPLES = '''
|
|||
RETURN = '''
|
||||
'''
|
||||
|
||||
import subprocess
|
||||
|
||||
|
||||
class BackendProp(object):
|
||||
def __init__(self, module):
|
||||
|
@ -114,9 +112,8 @@ class BackendProp(object):
|
|||
'--backend-name', backend_name,
|
||||
'-n', '-X', '-s'
|
||||
] + password_method
|
||||
process = subprocess.Popen(my_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
if process.returncode == 0:
|
||||
rc, stdout, stderr = self._module.run_command(my_command)
|
||||
if rc == 0:
|
||||
return stdout
|
||||
else:
|
||||
self._module.fail_json(msg="Error message: " + str(stderr))
|
||||
|
@ -132,9 +129,8 @@ class BackendProp(object):
|
|||
'--set', name + ":" + value,
|
||||
'-n', '-X'
|
||||
] + password_method
|
||||
process = subprocess.Popen(my_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
if process.returncode == 0:
|
||||
rc, stdout, stderr = self._module.run_command(my_command)
|
||||
if rc == 0:
|
||||
return True
|
||||
else:
|
||||
self._module.fail_json(msg="Error message: " + stderr)
|
||||
|
|
|
@ -50,13 +50,10 @@ EXAMPLES = '''
|
|||
|
||||
'''
|
||||
|
||||
import subprocess
|
||||
|
||||
|
||||
def gather_lldp():
|
||||
def gather_lldp(module):
|
||||
cmd = ['lldpctl', '-f', 'keyvalue']
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
(output, err) = proc.communicate()
|
||||
rc, output, err = module.run_command(cmd)
|
||||
if output:
|
||||
output_dict = {}
|
||||
lldp_entries = output.split("\n")
|
||||
|
@ -80,7 +77,7 @@ def gather_lldp():
|
|||
def main():
|
||||
module = AnsibleModule({})
|
||||
|
||||
lldp_output = gather_lldp()
|
||||
lldp_output = gather_lldp(module)
|
||||
try:
|
||||
data = {'lldp': lldp_output['lldp']}
|
||||
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.pycompat24 import get_exception
|
||||
|
||||
|
||||
|
||||
class GConf2Preference(object):
|
||||
def __init__(self, ansible, key, value_type, value,
|
||||
direct=False, config_source=""):
|
||||
|
@ -158,11 +156,7 @@ class GConf2Preference(object):
|
|||
cmd += "--unset {0}".format(self.key)
|
||||
|
||||
# Start external command
|
||||
process = Popen([cmd], stdout=PIPE, stderr=PIPE, shell=True)
|
||||
|
||||
# In either case, we will capture the output
|
||||
out = process.stdout.read()
|
||||
err = process.stderr.read()
|
||||
rc, out, err = self.ansible.run_command(cmd, use_unsafe_shell=True)
|
||||
|
||||
if len(err) > 0:
|
||||
if fail_onerr:
|
||||
|
|
Loading…
Reference in a new issue