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

[PR #6198/6fa833fe backport][stable-6] pipx: Allow injected modules to add apps (#6238)

pipx: Allow injected modules to add apps (#6198)

* pipx: Allow injected modules to add apps

Add support for pipx inject's "--include-apps" parameter.

* add changelog fragment

* fix pipx test ("install_apps", not "include_apps")

* fix pipx test -- add a second invocation for install_apps

* Update changelogs/fragments/6198-pipx-inject-install-apps.yml

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

* Update plugins/modules/pipx.py

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

---------

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

Co-authored-by: Paul Aurich <paul@darkrain42.org>
This commit is contained in:
patchback[bot] 2023-03-26 09:45:48 +02:00 committed by GitHub
parent 5e1508e0df
commit 9cd3f37686
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 2 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- pipx - optional ``install_apps`` parameter added to install applications from injected packages (https://github.com/ansible-collections/community.general/pull/6198).

View file

@ -32,6 +32,7 @@ def pipx_runner(module, command, **kwargs):
state=fmt.as_map(_state_map), state=fmt.as_map(_state_map),
name=fmt.as_list(), name=fmt.as_list(),
name_source=fmt.as_func(fmt.unpack_args(lambda n, s: [s] if s else [n])), name_source=fmt.as_func(fmt.unpack_args(lambda n, s: [s] if s else [n])),
install_apps=fmt.as_bool("--include-apps"),
install_deps=fmt.as_bool("--include-deps"), install_deps=fmt.as_bool("--include-deps"),
inject_packages=fmt.as_list(), inject_packages=fmt.as_list(),
force=fmt.as_bool("--force"), force=fmt.as_bool("--force"),

View file

@ -47,10 +47,17 @@ options:
If the application source, such as a package with version specifier, or an URL, If the application source, such as a package with version specifier, or an URL,
directory or any other accepted specification. See C(pipx) documentation for more details. directory or any other accepted specification. See C(pipx) documentation for more details.
- When specified, the C(pipx) command will use I(source) instead of I(name). - When specified, the C(pipx) command will use I(source) instead of I(name).
install_apps:
description:
- Add apps from the injected packages.
- Only used when I(state=inject).
type: bool
default: false
version_added: 6.5.0
install_deps: install_deps:
description: description:
- Include applications of dependent packages. - Include applications of dependent packages.
- Only used when I(state=install) or I(state=upgrade). - Only used when I(state=install), I(state=upgrade), or I(state=inject).
type: bool type: bool
default: false default: false
inject_packages: inject_packages:
@ -161,6 +168,7 @@ class PipX(StateModuleHelper):
'inject', 'upgrade', 'upgrade_all', 'reinstall', 'reinstall_all', 'latest']), 'inject', 'upgrade', 'upgrade_all', 'reinstall', 'reinstall_all', 'latest']),
name=dict(type='str'), name=dict(type='str'),
source=dict(type='str'), source=dict(type='str'),
install_apps=dict(type='bool', default=False),
install_deps=dict(type='bool', default=False), install_deps=dict(type='bool', default=False),
inject_packages=dict(type='list', elements='str'), inject_packages=dict(type='list', elements='str'),
force=dict(type='bool', default=False), force=dict(type='bool', default=False),
@ -271,7 +279,7 @@ class PipX(StateModuleHelper):
self.do_raise("Trying to inject packages into a non-existent application: {0}".format(self.vars.name)) self.do_raise("Trying to inject packages into a non-existent application: {0}".format(self.vars.name))
if self.vars.force: if self.vars.force:
self.changed = True self.changed = True
with self.runner('state index_url force editable pip_args name inject_packages', check_mode_skip=True) as ctx: with self.runner('state index_url install_apps install_deps force editable pip_args name inject_packages', check_mode_skip=True) as ctx:
ctx.run() ctx.run()
self._capture_results(ctx) self._capture_results(ctx)

View file

@ -190,6 +190,15 @@
- licenses - licenses
register: inject_pkgs_ansible_lint register: inject_pkgs_ansible_lint
- name: inject packages with apps
community.general.pipx:
state: inject
name: ansible-lint
inject_packages:
- black
install_apps: true
register: inject_pkgs_apps_ansible_lint
- name: cleanup ansible-lint - name: cleanup ansible-lint
community.general.pipx: community.general.pipx:
state: absent state: absent
@ -203,6 +212,9 @@
- inject_pkgs_ansible_lint is changed - inject_pkgs_ansible_lint is changed
- '"ansible-lint" in inject_pkgs_ansible_lint.application' - '"ansible-lint" in inject_pkgs_ansible_lint.application'
- '"licenses" in inject_pkgs_ansible_lint.application["ansible-lint"]["injected"]' - '"licenses" in inject_pkgs_ansible_lint.application["ansible-lint"]["injected"]'
- inject_pkgs_apps_ansible_lint is changed
- '"ansible-lint" in inject_pkgs_apps_ansible_lint.application'
- '"black" in inject_pkgs_apps_ansible_lint.application["ansible-lint"]["injected"]'
- uninstall_ansible_lint is changed - uninstall_ansible_lint is changed
############################################################################## ##############################################################################