mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
onepassword_info: replace subprocess.Popen() with run_command() (#11193)
* onepassword_info: replace subprocess.Popen() with run_command() * add changelog frag * Update plugins/modules/onepassword_info.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
2
changelogs/fragments/11193-onepassword-info-popen.yml
Normal file
2
changelogs/fragments/11193-onepassword-info-popen.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- onepassword_info - execute external commands using Ansible construct (https://github.com/ansible-collections/community.general/pull/11193).
|
||||||
@@ -159,8 +159,6 @@ import json
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from subprocess import Popen, PIPE
|
|
||||||
|
|
||||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
@@ -193,9 +191,7 @@ class OnePasswordInfo:
|
|||||||
args += [to_bytes("--session=") + self.token]
|
args += [to_bytes("--session=") + self.token]
|
||||||
|
|
||||||
command = [self.cli_path] + args
|
command = [self.cli_path] + args
|
||||||
p = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE)
|
rc, out, err = module.run_command(command, data=command_input, check_rc=False, binary_data=True, encoding=None)
|
||||||
out, err = p.communicate(input=command_input)
|
|
||||||
rc = p.wait()
|
|
||||||
if not ignore_errors and rc != expected_rc:
|
if not ignore_errors and rc != expected_rc:
|
||||||
raise AnsibleModuleError(to_native(err))
|
raise AnsibleModuleError(to_native(err))
|
||||||
return rc, out, err
|
return rc, out, err
|
||||||
|
|||||||
Reference in New Issue
Block a user