From f32bcd34ef06ea5956cb1c47e180955c8f5a1c4a Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:21:21 +0100 Subject: [PATCH] [PR #11193/f2731e1d backport][stable-12] onepassword_info: replace subprocess.Popen() with run_command() (#11208) 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 --------- (cherry picked from commit f2731e1dac7cc795831a9f369a445a85b806a7de) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein --- changelogs/fragments/11193-onepassword-info-popen.yml | 2 ++ plugins/modules/onepassword_info.py | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/11193-onepassword-info-popen.yml diff --git a/changelogs/fragments/11193-onepassword-info-popen.yml b/changelogs/fragments/11193-onepassword-info-popen.yml new file mode 100644 index 0000000000..fe0dfc79ab --- /dev/null +++ b/changelogs/fragments/11193-onepassword-info-popen.yml @@ -0,0 +1,2 @@ +minor_changes: + - onepassword_info - execute external commands using Ansible construct (https://github.com/ansible-collections/community.general/pull/11193). diff --git a/plugins/modules/onepassword_info.py b/plugins/modules/onepassword_info.py index 2f3616ee16..fd9e461139 100644 --- a/plugins/modules/onepassword_info.py +++ b/plugins/modules/onepassword_info.py @@ -159,8 +159,6 @@ import json import os import re -from subprocess import Popen, PIPE - from ansible.module_utils.common.text.converters import to_bytes, to_native from ansible.module_utils.basic import AnsibleModule @@ -193,9 +191,7 @@ class OnePasswordInfo: args += [to_bytes("--session=") + self.token] command = [self.cli_path] + args - p = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) - out, err = p.communicate(input=command_input) - rc = p.wait() + rc, out, err = module.run_command(command, data=command_input, check_rc=False, binary_data=True, encoding=None) if not ignore_errors and rc != expected_rc: raise AnsibleModuleError(to_native(err)) return rc, out, err