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

Improve opkg module (#3554)

* Allow name to be a YAML list as well, and be more lenient when splitting strings by comma.

* General docs improvements.
This commit is contained in:
Felix Fontein 2021-10-14 21:14:32 +02:00 committed by GitHub
parent 9546bbb55e
commit d25554df9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- "opkg - allow ``name`` to be a YAML list of strings (https://github.com/ansible-collections/community.general/issues/572, https://github.com/ansible-collections/community.general/pull/3554)."

View file

@ -20,19 +20,20 @@ description:
options: options:
name: name:
description: description:
- name of package to install/remove - Name of package(s) to install/remove.
aliases: [pkg] aliases: [pkg]
required: true required: true
type: str type: list
elements: str
state: state:
description: description:
- state of the package - State of the package.
choices: [ 'present', 'absent', 'installed', 'removed' ] choices: [ 'present', 'absent', 'installed', 'removed' ]
default: present default: present
type: str type: str
force: force:
description: description:
- opkg --force parameter used - The C(opkg --force) parameter used.
choices: choices:
- "" - ""
- "depends" - "depends"
@ -48,10 +49,10 @@ options:
type: str type: str
update_cache: update_cache:
description: description:
- update the package db first - Update the package DB first.
- Alias C(update-cache) has been deprecated and will be removed in community.general 5.0.0. - Alias C(update-cache) has been deprecated and will be removed in community.general 5.0.0.
aliases: ['update-cache'] aliases: ['update-cache']
default: "no" default: false
type: bool type: bool
requirements: requirements:
- opkg - opkg
@ -76,7 +77,9 @@ EXAMPLES = '''
- name: Remove foo and bar - name: Remove foo and bar
community.general.opkg: community.general.opkg:
name: foo,bar name:
- foo
- bar
state: absent state: absent
- name: Install foo using overwrite option forcibly - name: Install foo using overwrite option forcibly
@ -170,7 +173,7 @@ def install_packages(module, opkg_path, packages):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
name=dict(aliases=["pkg"], required=True), name=dict(aliases=["pkg"], required=True, type="list", elements="str"),
state=dict(default="present", choices=["present", "installed", "absent", "removed"]), state=dict(default="present", choices=["present", "installed", "absent", "removed"]),
force=dict(default="", choices=["", "depends", "maintainer", "reinstall", "overwrite", "downgrade", "space", "postinstall", "remove", force=dict(default="", choices=["", "depends", "maintainer", "reinstall", "overwrite", "downgrade", "space", "postinstall", "remove",
"checksum", "removal-of-dependent-packages"]), "checksum", "removal-of-dependent-packages"]),
@ -187,7 +190,7 @@ def main():
if p["update_cache"]: if p["update_cache"]:
update_package_db(module, opkg_path) update_package_db(module, opkg_path)
pkgs = p["name"].split(",") pkgs = p["name"]
if p["state"] in ["present", "installed"]: if p["state"] in ["present", "installed"]:
install_packages(module, opkg_path, pkgs) install_packages(module, opkg_path, pkgs)