mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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>
This commit is contained in:
parent
33ccabed13
commit
6fa833feed
4 changed files with 25 additions and 2 deletions
2
changelogs/fragments/6198-pipx-inject-install-apps.yml
Normal file
2
changelogs/fragments/6198-pipx-inject-install-apps.yml
Normal 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).
|
|
@ -32,6 +32,7 @@ def pipx_runner(module, command, **kwargs):
|
|||
state=fmt.as_map(_state_map),
|
||||
name=fmt.as_list(),
|
||||
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"),
|
||||
inject_packages=fmt.as_list(),
|
||||
force=fmt.as_bool("--force"),
|
||||
|
|
|
@ -47,10 +47,17 @@ options:
|
|||
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.
|
||||
- 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:
|
||||
description:
|
||||
- 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
|
||||
default: false
|
||||
inject_packages:
|
||||
|
@ -161,6 +168,7 @@ class PipX(StateModuleHelper):
|
|||
'inject', 'upgrade', 'upgrade_all', 'reinstall', 'reinstall_all', 'latest']),
|
||||
name=dict(type='str'),
|
||||
source=dict(type='str'),
|
||||
install_apps=dict(type='bool', default=False),
|
||||
install_deps=dict(type='bool', default=False),
|
||||
inject_packages=dict(type='list', elements='str'),
|
||||
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))
|
||||
if self.vars.force:
|
||||
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()
|
||||
self._capture_results(ctx)
|
||||
|
||||
|
|
|
@ -190,6 +190,15 @@
|
|||
- licenses
|
||||
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
|
||||
community.general.pipx:
|
||||
state: absent
|
||||
|
@ -203,6 +212,9 @@
|
|||
- inject_pkgs_ansible_lint is changed
|
||||
- '"ansible-lint" in inject_pkgs_ansible_lint.application'
|
||||
- '"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
|
||||
|
||||
##############################################################################
|
||||
|
|
Loading…
Reference in a new issue