From e962da8b9de7ae38ec1146179dda9a03b3e1e5b7 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 10:29:22 +0200 Subject: [PATCH] pipx: add required_if fo upgrade and reinstall (#5100) (#5102) * pipx: add required_if for upgrade and reinstall * add changelog fragment (cherry picked from commit 83317419d7249051e75b1a5c84879677df79f056) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/5100-pipx-req-if.yaml | 2 ++ plugins/modules/packaging/language/pipx.py | 3 ++- tests/integration/targets/pipx/tasks/main.yml | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5100-pipx-req-if.yaml diff --git a/changelogs/fragments/5100-pipx-req-if.yaml b/changelogs/fragments/5100-pipx-req-if.yaml new file mode 100644 index 0000000000..8986503eb7 --- /dev/null +++ b/changelogs/fragments/5100-pipx-req-if.yaml @@ -0,0 +1,2 @@ +minor_changes: + - pipx - module fails faster when ``name`` is missing for states ``upgrade`` and ``reinstall`` (https://github.com/ansible-collections/community.general/pull/5100). diff --git a/plugins/modules/packaging/language/pipx.py b/plugins/modules/packaging/language/pipx.py index 968d0f7d82..36117bacea 100644 --- a/plugins/modules/packaging/language/pipx.py +++ b/plugins/modules/packaging/language/pipx.py @@ -164,7 +164,8 @@ class PipX(StateModuleHelper): ('state', 'install', ['name']), ('state', 'absent', ['name']), ('state', 'uninstall', ['name']), - # missing upgrade and reinstall requiring 'name' + ('state', 'upgrade', ['name']), + ('state', 'reinstall', ['name']), ('state', 'inject', ['name', 'inject_packages']), ], supports_check_mode=True, diff --git a/tests/integration/targets/pipx/tasks/main.yml b/tests/integration/targets/pipx/tasks/main.yml index ff6d921697..7013880ad4 100644 --- a/tests/integration/targets/pipx/tasks/main.yml +++ b/tests/integration/targets/pipx/tasks/main.yml @@ -24,7 +24,6 @@ community.general.pipx: name: tox register: install_tox_again - ignore_errors: yes - name: install application tox again force community.general.pipx: @@ -61,12 +60,24 @@ state: reinstall register: reinstall_tox_324 +- name: reinstall without name + community.general.pipx: + state: reinstall + register: reinstall_noname + ignore_errors: yes + - name: upgrade tox 3.24.0 community.general.pipx: name: tox state: upgrade register: upgrade_tox_324 +- name: upgrade without name + community.general.pipx: + state: upgrade + register: upgrade_noname + ignore_errors: yes + - name: downgrade tox 3.24.0 community.general.pipx: name: tox @@ -94,6 +105,8 @@ - downgrade_tox_324.application.tox.version == '3.24.0' - uninstall_tox_324 is changed - "'tox' not in uninstall_tox_324.application" + - upgrade_noname is failed + - reinstall_noname is failed ############################################################################## - name: ensure application ansible-lint is uninstalled