1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #6862/91a68187 backport][stable-7] opkg: add executable parameter (#6870)

opkg: add executable parameter (#6862)

* opkg: add executable parameter

* add changelog frag

* Update plugins/modules/opkg.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 91a681870e)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2023-07-06 19:55:58 +00:00 committed by GitHub
parent 330b0304ef
commit 9b21b0d31c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- opkg - add ``executable`` parameter allowing to specify the path of the ``opkg`` command (https://github.com/ansible-collections/community.general/pull/6862).

View file

@ -66,6 +66,11 @@ options:
- Update the package DB first.
default: false
type: bool
executable:
description:
- The executable location for C(opkg).
type: path
version_added: 7.2.0
requirements:
- opkg
- python
@ -106,6 +111,7 @@ EXAMPLES = '''
force: overwrite
'''
import os
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
@ -118,6 +124,7 @@ class Opkg(StateModuleHelper):
force=dict(choices=["", "depends", "maintainer", "reinstall", "overwrite", "downgrade", "space",
"postinstall", "remove", "checksum", "removal-of-dependent-packages"]),
update_cache=dict(default=False, type='bool'),
executable=dict(type="path"),
),
)
@ -138,15 +145,18 @@ class Opkg(StateModuleHelper):
value = None
return cmd_runner_fmt.as_optval("--force-")(value, ctx_ignore_none=True)
dir, cmd = os.path.split(self.vars.executable) if self.vars.executable else (None, "opkg")
self.runner = CmdRunner(
self.module,
command="opkg",
command=cmd,
arg_formats=dict(
package=cmd_runner_fmt.as_list(),
state=cmd_runner_fmt.as_map(state_map),
force=cmd_runner_fmt.as_func(_force),
update_cache=cmd_runner_fmt.as_bool("update")
update_cache=cmd_runner_fmt.as_bool("update"),
),
path_prefix=dir,
)
if self.vars.update_cache: