Skip to content

Commit

Permalink
pipx: add required_if fo upgrade and reinstall (ansible-collections#5100
Browse files Browse the repository at this point in the history
)

* pipx: add required_if for upgrade and reinstall

* add changelog fragment
  • Loading branch information
russoz authored and Dušan Markovič committed Nov 7, 2022
1 parent f945e37 commit 377ff30
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/5100-pipx-req-if.yaml
Original file line number Diff line number Diff line change
@@ -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).
3 changes: 2 additions & 1 deletion plugins/modules/packaging/language/pipx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 14 additions & 1 deletion tests/integration/targets/pipx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 377ff30

Please sign in to comment.