mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +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:
parent
64dc009ea7
commit
f2731e1dac
2 changed files with 3 additions and 5 deletions
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 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue