Repository: geerlingguy/ansible-role-pip Branch: master Commit: efe631ae41bb Files: 14 Total size: 10.5 KB Directory structure: gitextract_eca78du3/ ├── .ansible-lint ├── .github/ │ ├── FUNDING.yml │ └── workflows/ │ ├── ci.yml │ ├── release.yml │ └── stale.yml ├── .gitignore ├── .yamllint ├── LICENSE ├── README.md ├── defaults/ │ └── main.yml ├── meta/ │ └── main.yml ├── molecule/ │ └── default/ │ ├── converge.yml │ └── molecule.yml └── tasks/ └── main.yml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .ansible-lint ================================================ skip_list: - 'yaml' - 'role-name' ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms --- github: geerlingguy patreon: geerlingguy ================================================ FILE: .github/workflows/ci.yml ================================================ --- name: CI 'on': pull_request: push: branches: - master schedule: - cron: "0 4 * * 5" defaults: run: working-directory: 'geerlingguy.pip' jobs: lint: name: Lint runs-on: ubuntu-latest steps: - name: Check out the codebase. uses: actions/checkout@v3 with: path: 'geerlingguy.pip' - name: Set up Python 3. uses: actions/setup-python@v4 with: python-version: '3.13' # Can't go to 3.14+ until Ansible 13.x - name: Install test dependencies. run: pip3 install yamllint - name: Lint code. run: | yamllint . molecule: name: Molecule runs-on: ubuntu-latest strategy: matrix: distro: - rockylinux10 - fedora42 - ubuntu2404 - debian13 - debian12 steps: - name: Check out the codebase. uses: actions/checkout@v3 with: path: 'geerlingguy.pip' - name: Set up Python 3. uses: actions/setup-python@v4 with: python-version: '3.13' # Can't go to 3.14+ until Ansible 13.x - name: Install test dependencies. run: pip3 install ansible molecule molecule-plugins[docker] docker - name: Run Molecule tests. run: molecule test env: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' MOLECULE_DISTRO: ${{ matrix.distro }} ================================================ FILE: .github/workflows/release.yml ================================================ --- # This workflow requires a GALAXY_API_KEY secret present in the GitHub # repository or organization. # # See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy # See: https://github.com/ansible/galaxy/issues/46 name: Release 'on': push: tags: - '*' defaults: run: working-directory: 'geerlingguy.pip' jobs: release: name: Release runs-on: ubuntu-latest steps: - name: Check out the codebase. uses: actions/checkout@v4 with: path: 'geerlingguy.pip' - name: Set up Python 3. uses: actions/setup-python@v5 with: python-version: '3.13' # Can't go to 3.14+ until Ansible 13.x - name: Install Ansible. run: pip3 install ansible-core - name: Trigger a new import on Galaxy. run: >- ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) ================================================ FILE: .github/workflows/stale.yml ================================================ --- name: Close inactive issues 'on': schedule: - cron: "55 21 * * 5" # semi-random time jobs: close-issues: runs-on: ubuntu-latest permissions: issues: write pull-requests: write steps: - uses: actions/stale@v8 with: days-before-stale: 120 days-before-close: 60 exempt-issue-labels: bug,pinned,security,planned exempt-pr-labels: bug,pinned,security,planned stale-issue-label: "stale" stale-pr-label: "stale" stale-issue-message: | This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. close-issue-message: | This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. stale-pr-message: | This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. close-pr-message: | This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. repo-token: ${{ secrets.GITHUB_TOKEN }} ================================================ FILE: .gitignore ================================================ *.retry */__pycache__ *.pyc .cache ================================================ FILE: .yamllint ================================================ --- extends: default rules: line-length: max: 120 level: warning ignore: | .github/workflows/stale.yml ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2017 Jeff Geerling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Ansible Role: Pip (for Python) [![CI](https://github.com/geerlingguy/ansible-role-pip/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/ansible-role-pip/actions/workflows/ci.yml) An Ansible Role that installs [Pip](https://pip.pypa.io) on Linux. ## Requirements On RedHat/CentOS, you may need to have EPEL installed before running this role. You can use the `geerlingguy.repo-epel` role if you need a simple way to ensure it's installed. ## Role Variables Available variables are listed below, along with default values (see `defaults/main.yml`): pip_package: python3-pip The name of the package to install to get `pip` on the system. For older systems that don't have Python 3 available, you can set this to `python-pip`. pip_executable: pip3 The role will try to autodetect the pip executable based on the `pip_package` (e.g. `pip` for Python 2 and `pip3` for Python 3). You can also override this explicitly, e.g. `pip_executable: pip3.6`. pip_install_packages: [] A list of packages to install with pip. Examples below: pip_install_packages: # Specify names and versions. - name: docker version: "1.2.3" - name: awscli version: "1.11.91" # Or specify bare packages to get the latest release. - docker - awscli # Or uninstall a package. - name: docker state: absent # Or update a package to the latest version. - name: docker state: latest # Or force a reinstall. - name: docker state: forcereinstall # Or install a package in a particular virtualenv. - name: docker virtualenv: /my_app/venv # Or pass through any extra arguments. - name: my_special_package_from_my_special_repo extra_args: --extra-index-url https://my-domain/pypi/pypi-master/simple ## Dependencies None. ## Example Playbook - hosts: all vars: pip_install_packages: - name: docker - name: awscli roles: - geerlingguy.pip ## License MIT / BSD ## Author Information This role was created in 2017 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). ================================================ FILE: defaults/main.yml ================================================ --- # For Python 3, use python3-pip. pip_package: python3-pip pip_executable: "{{ 'pip3' if pip_package.startswith('python3') else 'pip' }}" pip_install_packages: [] ================================================ FILE: meta/main.yml ================================================ --- dependencies: [] galaxy_info: role_name: pip author: geerlingguy description: Pip (Python package manager) for Linux. issue_tracker_url: https://github.com/geerlingguy/ansible-role-pip/issues company: "Midwestern Mac, LLC" license: "MIT" min_ansible_version: 2.10 platforms: - name: Fedora versions: - all - name: Debian versions: - all - name: Ubuntu versions: - all galaxy_tags: - system - server - packaging - python - pip - tools ================================================ FILE: molecule/default/converge.yml ================================================ --- - name: Converge hosts: all #become: true vars: pip_install_packages: # Test installing a specific version of a package. - name: ipaddress version: "1.0.18" # Test installing a package by name. - colorama pre_tasks: - name: Update apt cache. ansible.builtin.apt: update_cache: true cache_valid_time: 600 when: ansible_facts.os_family == 'Debian' - name: Set package name for older OSes. ansible.builtin.set_fact: pip_package: python-pip when: > (ansible_facts.os_family == 'RedHat') and (ansible_facts.distribution_major_version | int < 8) or (ansible_facts.distribution == 'Debian') and (ansible_facts.distribution_major_version | int < 10) or (ansible_facts.distribution == 'Ubuntu') and (ansible_facts.distribution_major_version | int < 18) roles: - role: geerlingguy.pip ================================================ FILE: molecule/default/molecule.yml ================================================ --- role_name_check: 1 dependency: name: galaxy options: ignore-errors: true driver: name: docker platforms: - name: instance image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-ansible:latest" command: ${MOLECULE_DOCKER_COMMAND:-""} volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw cgroupns_mode: host privileged: true pre_build_image: true provisioner: name: ansible playbooks: converge: ${MOLECULE_PLAYBOOK:-converge.yml} ================================================ FILE: tasks/main.yml ================================================ --- - name: Ensure Pip is installed. ansible.builtin.package: name: "{{ pip_package }}" state: present - name: Remove EXTERNALLY-MANAGED ansible.builtin.file: path: "/usr/lib/python3.{{ ansible_facts['python']['version']['minor'] }}/EXTERNALLY-MANAGED" state: absent - name: Ensure pip_install_packages are installed. ansible.builtin.pip: name: "{{ item.name | default(item) }}" version: "{{ item.version | default(omit) }}" virtualenv: "{{ item.virtualenv | default(omit) }}" state: "{{ item.state | default(omit) }}" extra_args: "{{ item.extra_args | default(omit) }}" executable: "{{ item.virtualenv | default(false) | ternary(omit, pip_executable) }}" loop: "{{ pip_install_packages }}"