Skip to content

Commit 8569814

Browse files
russozfelixfontein
authored andcommitted
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 <[email protected]> --------- Co-authored-by: Felix Fontein <[email protected]> (cherry picked from commit f2731e1)
1 parent cc7ba79 commit 8569814

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- onepassword_info - execute external commands using Ansible construct (https://github.com/ansible-collections/community.general/pull/11193).

plugins/modules/onepassword_info.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@
159159
import os
160160
import re
161161

162-
from subprocess import Popen, PIPE
163-
164162
from ansible.module_utils.common.text.converters import to_bytes, to_native
165163
from ansible.module_utils.basic import AnsibleModule
166164

@@ -193,9 +191,7 @@ def _run(self, args, expected_rc=0, command_input=None, ignore_errors=False):
193191
args += [to_bytes("--session=") + self.token]
194192

195193
command = [self.cli_path] + args
196-
p = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE)
197-
out, err = p.communicate(input=command_input)
198-
rc = p.wait()
194+
rc, out, err = module.run_command(command, data=command_input, check_rc=False, binary_data=True, encoding=None)
199195
if not ignore_errors and rc != expected_rc:
200196
raise AnsibleModuleError(to_native(err))
201197
return rc, out, err

0 commit comments

Comments
 (0)