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:
parent
9546bbb55e
commit
d25554df9d
2 changed files with 14 additions and 9 deletions
2
changelogs/fragments/3554-opkg-name.yml
Normal file
2
changelogs/fragments/3554-opkg-name.yml
Normal 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)."
|
|
@ -20,19 +20,20 @@ description:
|
|||
options:
|
||||
name:
|
||||
description:
|
||||
- name of package to install/remove
|
||||
- Name of package(s) to install/remove.
|
||||
aliases: [pkg]
|
||||
required: true
|
||||
type: str
|
||||
type: list
|
||||
elements: str
|
||||
state:
|
||||
description:
|
||||
- state of the package
|
||||
- State of the package.
|
||||
choices: [ 'present', 'absent', 'installed', 'removed' ]
|
||||
default: present
|
||||
type: str
|
||||
force:
|
||||
description:
|
||||
- opkg --force parameter used
|
||||
- The C(opkg --force) parameter used.
|
||||
choices:
|
||||
- ""
|
||||
- "depends"
|
||||
|
@ -48,10 +49,10 @@ options:
|
|||
type: str
|
||||
update_cache:
|
||||
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.
|
||||
aliases: ['update-cache']
|
||||
default: "no"
|
||||
default: false
|
||||
type: bool
|
||||
requirements:
|
||||
- opkg
|
||||
|
@ -76,7 +77,9 @@ EXAMPLES = '''
|
|||
|
||||
- name: Remove foo and bar
|
||||
community.general.opkg:
|
||||
name: foo,bar
|
||||
name:
|
||||
- foo
|
||||
- bar
|
||||
state: absent
|
||||
|
||||
- name: Install foo using overwrite option forcibly
|
||||
|
@ -170,7 +173,7 @@ def install_packages(module, opkg_path, packages):
|
|||
def main():
|
||||
module = AnsibleModule(
|
||||
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"]),
|
||||
force=dict(default="", choices=["", "depends", "maintainer", "reinstall", "overwrite", "downgrade", "space", "postinstall", "remove",
|
||||
"checksum", "removal-of-dependent-packages"]),
|
||||
|
@ -187,7 +190,7 @@ def main():
|
|||
if p["update_cache"]:
|
||||
update_package_db(module, opkg_path)
|
||||
|
||||
pkgs = p["name"].split(",")
|
||||
pkgs = p["name"]
|
||||
|
||||
if p["state"] in ["present", "installed"]:
|
||||
install_packages(module, opkg_path, pkgs)
|
||||
|
|
Loading…
Reference in a new issue