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:
parent
330b0304ef
commit
9b21b0d31c
2 changed files with 14 additions and 2 deletions
2
changelogs/fragments/6862-opkg-exec.yml
Normal file
2
changelogs/fragments/6862-opkg-exec.yml
Normal 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).
|
|
@ -66,6 +66,11 @@ options:
|
||||||
- Update the package DB first.
|
- Update the package DB first.
|
||||||
default: false
|
default: false
|
||||||
type: bool
|
type: bool
|
||||||
|
executable:
|
||||||
|
description:
|
||||||
|
- The executable location for C(opkg).
|
||||||
|
type: path
|
||||||
|
version_added: 7.2.0
|
||||||
requirements:
|
requirements:
|
||||||
- opkg
|
- opkg
|
||||||
- python
|
- python
|
||||||
|
@ -106,6 +111,7 @@ EXAMPLES = '''
|
||||||
force: overwrite
|
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.cmd_runner import CmdRunner, cmd_runner_fmt
|
||||||
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
|
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",
|
force=dict(choices=["", "depends", "maintainer", "reinstall", "overwrite", "downgrade", "space",
|
||||||
"postinstall", "remove", "checksum", "removal-of-dependent-packages"]),
|
"postinstall", "remove", "checksum", "removal-of-dependent-packages"]),
|
||||||
update_cache=dict(default=False, type='bool'),
|
update_cache=dict(default=False, type='bool'),
|
||||||
|
executable=dict(type="path"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -138,15 +145,18 @@ class Opkg(StateModuleHelper):
|
||||||
value = None
|
value = None
|
||||||
return cmd_runner_fmt.as_optval("--force-")(value, ctx_ignore_none=True)
|
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.runner = CmdRunner(
|
||||||
self.module,
|
self.module,
|
||||||
command="opkg",
|
command=cmd,
|
||||||
arg_formats=dict(
|
arg_formats=dict(
|
||||||
package=cmd_runner_fmt.as_list(),
|
package=cmd_runner_fmt.as_list(),
|
||||||
state=cmd_runner_fmt.as_map(state_map),
|
state=cmd_runner_fmt.as_map(state_map),
|
||||||
force=cmd_runner_fmt.as_func(_force),
|
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:
|
if self.vars.update_cache:
|
||||||
|
|
Loading…
Reference in a new issue