Skip to content

Ansible role for installing a specific base python version and environment

License

Notifications You must be signed in to change notification settings

marvel-nccr/ansible-role-python

Repository files navigation

CI Ansible Role Release

Ansible Role: marvel-nccr.python

An Ansible role that installs a specific base python+pip version (major.minor only).

The executables will be available at /usr/bin/python3.7 and /usr/local/bin/pip3.7, for the python_base_version specified.

The role is tested against: Ubuntu 16.04/18.04/20.04, Fedora 31 and CentOS 8 for python versions 3.6, 3.7 and 3.8.

You can also specify a path in which to create a virtualenv which uses this python version, with python_venv_path. By default python_venv_packages is set to install the latest pip, setuptools and wheel versions.

Installation

ansible-galaxy install marvel-nccr.python

Role Variables

See defaults/main.yml

Example Playbook

- hosts: servers
  roles:
  - role: marvel-nccr.python
    vars:
      python_base_version: "3.7"
      python_install_dev: true
      python_venv_path: "/tmp/my_venv"
      python_venv_packages:
        - pip
        - setuptools
        - wheel
      python_venv_state: latest

Known Issues

  • Python 3.7 is not available on CentOS 8
  • python_install_dev and python_install_tk will not work for Fedora 31 if no Python 3.7 (python3-devel and python3-tkinter will be installed, which only work for the default python 3.7 version)

Development and testing

This role uses Molecule and Docker for tests.

After installing Docker:

Clone the repository into a package named marvel-nccr.python (the folder must be named the same as the Ansible Galaxy name)

git clone https://github.com/marvel-nccr/ansible-role-python marvel-nccr.python
cd marvel-nccr.python

Then run:

pip install -r requirements.txt  # Installs molecule
molecule test  # runs tests

or use tox (see tox.ini):

pip install tox
tox

For testing specific distributions and python versions, .e.g.:

MOLECULE_DISTRO=centos8 MOLECULE_PYTHON_VERSION=3.8 tox

To manually inspect a container, you can run the converge and destroy steps individually:

tox converge
tox destroy

Code style

Code style is formatted and linted with pre-commit.

pip install pre-commit
pre-commit run -all

Deployment

Deployment to Ansible Galaxy is automated via GitHub Actions. Simply tag a release vX.Y.Z to initiate the CI and release workflow. Note, the release will only complete if the CI tests pass.

License

MIT

Contact

Please direct inquiries regarding Quantum Mobile and associated ansible roles to the AiiDA mailinglist.

About

Ansible role for installing a specific base python version and environment

Resources

License

Stars

Watchers

Forks

Packages

No packages published