mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-30 16:41:21 -07:00
pipx: add new states (#8809)
* ensure minimum version of pip * ensure pipx 1.7.0 is installed * pipx: add new states/params * add tests * add license to json file * Update plugins/modules/pipx.py Co-authored-by: Felix Fontein <felix@fontein.de> * fix uninject tests * add changelog frag * fix doc per review * refactor license out of pipx spec file * Update plugins/modules/pipx.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update tests/integration/targets/pipx/files/spec.json.license Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
7e978c77b4
commit
43f8adf1a5
10 changed files with 377 additions and 11 deletions
|
@ -247,3 +247,12 @@
|
|||
block:
|
||||
- name: Include testcase for PR 8793 --global
|
||||
ansible.builtin.include_tasks: testcase-8793-global.yml
|
||||
|
||||
- name: Include testcase for PR 8809 install-all
|
||||
ansible.builtin.include_tasks: testcase-8809-install-all.yml
|
||||
|
||||
- name: Include testcase for PR 8809 pin
|
||||
ansible.builtin.include_tasks: testcase-8809-pin.yml
|
||||
|
||||
- name: Include testcase for PR 8809 injectpkg
|
||||
ansible.builtin.include_tasks: testcase-8809-uninjectpkg.yml
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Set up environment
|
||||
environment:
|
||||
PATH: /usr/local/bin:{{ ansible_env.PATH }}
|
||||
block:
|
||||
- name: Uninstall pycowsay and black
|
||||
community.general.pipx:
|
||||
state: uninstall
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- black
|
||||
- pycowsay
|
||||
|
||||
- name: Uninstall pycowsay and black (again)
|
||||
community.general.pipx:
|
||||
state: uninstall
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- black
|
||||
- pycowsay
|
||||
register: uninstall_all_1
|
||||
|
||||
- name: Use install-all
|
||||
community.general.pipx:
|
||||
state: install-all
|
||||
spec_metadata: spec.json
|
||||
register: install_all
|
||||
|
||||
- name: Run pycowsay (should succeed)
|
||||
ansible.builtin.command: pycowsay Moooooooo!
|
||||
changed_when: false
|
||||
register: what_the_cow_said
|
||||
|
||||
- name: Which cow?
|
||||
ansible.builtin.command: which pycowsay
|
||||
changed_when: false
|
||||
register: which_cow
|
||||
|
||||
- name: Uninstall pycowsay and black (again)
|
||||
community.general.pipx:
|
||||
state: uninstall
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- black
|
||||
- pycowsay
|
||||
register: uninstall_all_2
|
||||
|
||||
- name: Assert uninstall-all
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- uninstall_all_1 is not changed
|
||||
- install_all is changed
|
||||
- "'Moooooooo!' in what_the_cow_said.stdout"
|
||||
- "'/usr/local/bin/pycowsay' in which_cow.stdout"
|
||||
- uninstall_all_2 is changed
|
69
tests/integration/targets/pipx/tasks/testcase-8809-pin.yml
Normal file
69
tests/integration/targets/pipx/tasks/testcase-8809-pin.yml
Normal file
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Set up environment
|
||||
environment:
|
||||
PATH: /usr/local/bin:{{ ansible_env.PATH }}
|
||||
block:
|
||||
- name: Uninstall pycowsay and black
|
||||
community.general.pipx:
|
||||
state: uninstall
|
||||
name: pycowsay
|
||||
|
||||
# latest is 0.0.0.2
|
||||
- name: Install pycowsay 0.0.0.1
|
||||
community.general.pipx:
|
||||
state: install
|
||||
name: pycowsay
|
||||
source: pycowsay==0.0.0.1
|
||||
|
||||
- name: Pin cowsay
|
||||
community.general.pipx:
|
||||
state: pin
|
||||
name: pycowsay
|
||||
register: pin_cow
|
||||
|
||||
- name: Upgrade pycowsay
|
||||
community.general.pipx:
|
||||
state: upgrade
|
||||
name: pycowsay
|
||||
|
||||
- name: Get pycowsay version
|
||||
community.general.pipx_info:
|
||||
name: pycowsay
|
||||
register: cow_info_1
|
||||
|
||||
- name: Unpin cowsay
|
||||
community.general.pipx:
|
||||
state: unpin
|
||||
name: pycowsay
|
||||
register: unpin_cow
|
||||
|
||||
- name: Upgrade pycowsay
|
||||
community.general.pipx:
|
||||
state: upgrade
|
||||
name: pycowsay
|
||||
|
||||
- name: Get pycowsay version
|
||||
community.general.pipx_info:
|
||||
name: pycowsay
|
||||
register: cow_info_2
|
||||
|
||||
- name: Uninstall pycowsay and black (again)
|
||||
community.general.pipx:
|
||||
state: uninstall
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- black
|
||||
- pycowsay
|
||||
register: uninstall_all_2
|
||||
|
||||
- name: Assert uninstall-all
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- pin_cow is changed
|
||||
- cow_info_1 == "0.0.0.1"
|
||||
- unpin_cow is changed
|
||||
- cow_info_2 != "0.0.0.1"
|
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Set up environment
|
||||
environment:
|
||||
PATH: /usr/local/bin:{{ ansible_env.PATH }}
|
||||
block:
|
||||
- name: Uninstall pycowsay and black
|
||||
community.general.pipx:
|
||||
state: uninstall
|
||||
name: pycowsay
|
||||
|
||||
# latest is 0.0.0.2
|
||||
- name: Install pycowsay 0.0.0.1
|
||||
community.general.pipx:
|
||||
state: install
|
||||
name: pycowsay
|
||||
source: pycowsay==0.0.0.1
|
||||
|
||||
- name: Pin cowsay
|
||||
community.general.pipx:
|
||||
state: pin
|
||||
name: pycowsay
|
||||
register: pin_cow
|
||||
|
||||
- name: Upgrade pycowsay
|
||||
community.general.pipx:
|
||||
state: upgrade
|
||||
name: pycowsay
|
||||
|
||||
- name: Get pycowsay version
|
||||
community.general.pipx_info:
|
||||
name: pycowsay
|
||||
register: cow_info_1
|
||||
|
||||
- name: Unpin cowsay
|
||||
community.general.pipx:
|
||||
state: unpin
|
||||
name: pycowsay
|
||||
register: unpin_cow
|
||||
|
||||
- name: Upgrade pycowsay
|
||||
community.general.pipx:
|
||||
state: upgrade
|
||||
name: pycowsay
|
||||
|
||||
- name: Get pycowsay version
|
||||
community.general.pipx_info:
|
||||
name: pycowsay
|
||||
register: cow_info_2
|
||||
|
||||
- name: Uninstall pycowsay and black (again)
|
||||
community.general.pipx:
|
||||
state: uninstall
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- black
|
||||
- pycowsay
|
||||
register: uninstall_all_2
|
||||
|
||||
- name: Assert uninstall-all
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- pin_cow is changed
|
||||
- cow_info_1 == "0.0.0.1"
|
||||
- unpin_cow is changed
|
||||
- cow_info_2 != "0.0.0.1"
|
|
@ -3,17 +3,17 @@
|
|||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: ensure application pylint is uninstalled
|
||||
- name: Ensure application pylint is uninstalled
|
||||
community.general.pipx:
|
||||
name: pylint
|
||||
state: absent
|
||||
|
||||
- name: install application pylint
|
||||
- name: Install application pylint
|
||||
community.general.pipx:
|
||||
name: pylint
|
||||
register: install_pylint
|
||||
|
||||
- name: inject packages
|
||||
- name: Inject packages
|
||||
community.general.pipx:
|
||||
state: inject
|
||||
name: pylint
|
||||
|
@ -21,7 +21,7 @@
|
|||
- licenses
|
||||
register: inject_pkgs_pylint
|
||||
|
||||
- name: inject packages with apps
|
||||
- name: Inject packages with apps
|
||||
community.general.pipx:
|
||||
state: inject
|
||||
name: pylint
|
||||
|
@ -30,13 +30,13 @@
|
|||
install_apps: true
|
||||
register: inject_pkgs_apps_pylint
|
||||
|
||||
- name: cleanup pylint
|
||||
- name: Cleanup pylint
|
||||
community.general.pipx:
|
||||
state: absent
|
||||
name: pylint
|
||||
register: uninstall_pylint
|
||||
|
||||
- name: check assertions inject_packages
|
||||
- name: Check assertions inject_packages
|
||||
assert:
|
||||
that:
|
||||
- install_pylint is changed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue