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

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>
This commit is contained in:
Alexei Znamensky 2023-07-07 07:15:17 +12:00 committed by GitHub
parent 9d8bec14c0
commit 91a681870e
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. - 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: