mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-10 14:05:07 +00:00
pipx, pipx_info: refactor (#11640)
* pipx, pipx_info: refactor * add changelog frag
This commit is contained in:
parent
8568594453
commit
bc98b2aa3b
4 changed files with 21 additions and 24 deletions
|
|
@ -7,6 +7,8 @@ from __future__ import annotations
|
|||
import json
|
||||
import typing as t
|
||||
|
||||
from ansible.module_utils.facts.compat import ansible_facts
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
|
|
@ -38,7 +40,7 @@ _state_map = dict(
|
|||
)
|
||||
|
||||
|
||||
def pipx_runner(module: AnsibleModule, command, **kwargs) -> CmdRunner:
|
||||
def pipx_runner(module: AnsibleModule, executable, **kwargs) -> CmdRunner:
|
||||
arg_formats = dict(
|
||||
state=cmd_runner_fmt.as_map(_state_map),
|
||||
name=cmd_runner_fmt.as_list(),
|
||||
|
|
@ -59,6 +61,11 @@ def pipx_runner(module: AnsibleModule, command, **kwargs) -> CmdRunner:
|
|||
version=cmd_runner_fmt.as_fixed("--version"),
|
||||
)
|
||||
arg_formats["global"] = cmd_runner_fmt.as_bool("--global")
|
||||
if executable:
|
||||
command = [executable]
|
||||
else:
|
||||
facts = ansible_facts(module, gather_subset=["python"])
|
||||
command = [facts["python"]["executable"], "-m", "pipx"]
|
||||
|
||||
runner = CmdRunner(
|
||||
module,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue