Changeset - ea2565a624f1
[Not reviewed]
0 7 0
Branko Majic (branko) - 3 months ago 2024-02-11 23:19:38
branko@majic.rs
MAR-154: Update documentation and test site for Python 2.7 support removal:

- Drop most of the references to Python 2.
- Switch anything that has been previously using Python 2.7 to Python
3.
7 files changed with 14 insertions and 28 deletions:
0 comments (0 inline, 0 general)
docs/development.rst
Show inline comments
 
@@ -196,15 +196,15 @@ should be resolvable towards the servers):
 

	
 
The web server is also set-up with one sample PHP application and two
 
WSGI applications deployed via roles:
 

	
 
- ``phpinfo``, used to serve information about the local PHP
 
  installation.
 
- ``wsgihello``, small hello world application using Python 2
 
- ``wsgihello2``, small hello world application using Python 3 and a
 
  couple of additional ``wsgi_website`` role parameters.
 
- ``wsgihello``, small hello world application.
 
- ``wsgihello2``, small hello world application using a couple of
 
  additional ``wsgi_website`` role parameters.
 

	
 
To make the web applications reachable, make sure the web server
 
(``web.example.com``) IP is also resolvable via names:
 

	
 
- ``phpinfo.example.com`` (``phpinfo`` application/role)
 
- ``wsgi.example.com`` (``wsgihello`` application/role)
docs/rolereference.rst
Show inline comments
 
@@ -1743,16 +1743,13 @@ The role implements the following:
 
* Creates a base directory where the website-specific code and data should be
 
  stored at.
 
* Adds nginx to website's group, so nginx could read the necessary files.
 
* Adds website administrator to website's group, so administrator could manage
 
  the code and data.
 
* Installs additional packages required for running the role (as configured).
 
* Sets-up a dedicated Python virtual environment for website. Python
 
  version can be specified (default is Python 2).
 
* Install ``futures`` package in Python virtual environment (required for
 
  Gunicorn in combination with Python 2.7).
 
* Sets-up a dedicated Python virtual environment for website.
 
* Install Gunicorn in Python virtual environment.
 
* Installs additional packages required for running the role in Python virtual
 
  environment (as configured).
 
* Configures systemd to run the website code (using Gunicorn)
 
* Deploys the HTTPS TLS private key and certificate (for website vhost).
 
* Configures nginx to serve the website (static files served directly, requests
 
@@ -1916,49 +1913,44 @@ Parameters
 
  conformant to what the ``gunicorn`` command-line tool accepts. If the
 
  ``use_paste`` option is enabled, the value should be equal to filename of the
 
  Python Paste ini file, located in the ``code`` sub-directory. It should be
 
  noted that in either case the value should be specsified relative to the
 
  ``code`` sub-directory. I.e. don't use full paths.
 

	
 
**wsgi_requirements** (list, optional, ``[ futures==3.3.0, gunicorn==19.10.0 ]``)
 
**wsgi_requirements** (list, optional, ``[ gunicorn==21.2.0, packaging==23.2 ]``)
 
  Complete list of pip requirements used for deploying Gunicorn. If
 
  specified, this list will be used to create requirements file and
 
  install Gunicorn and its dependencies from that one. This allows to
 
  have pinned packages for both Gunicorn, futures, and their
 
  dependencies. The ``futures`` package is required by Gunicorn when
 
  using Python 2.7.
 
  have pinned packages for both Gunicorn and its dependencies.
 

	
 
  It should be noted that this installation method is meant primarily in case of
 
  roles that want to take advantage of upgrade checks for pip requirements
 
  files, and that employ `pip-tools <https://github.com/jazzband/pip-tools>`_.
 

	
 
  In addition to change of installation method, when this parameter is
 
  specified the role will deploy necessary files for running the pip
 
  requirements upgrade check (see the ``common`` role for
 
  description). For this a directory is created under
 
  ``/etc/pip_check_requirements_upgrades/FQDN`` for Python 2 or
 
  ``/etc/pip_check_requirements_upgrades-py3/FQDN`` for Python 3. The same
 
  directory should be used by dependant roles to deploy their own
 
  ``.in`` and ``.txt`` files. Make sure the file ownership is set to
 
  ``/etc/pip_check_requirements_upgrades/FQDN``. The same directory
 
  should be used by dependant roles to deploy their own ``.in`` and
 
  ``.txt`` files. Make sure the file ownership is set to
 
  ``root:pipreqcheck``.
 

	
 
  Should you need to utilise the requirements file in some manner (other than
 
  checking for its upgrades), it will be also stored (and made accessible to
 
  application user/admin)) in application's home directory under the name
 
  ``.wsgi_requirements.txt``.
 

	
 
  To create complete requirements list, it is recommended to use `pip-tools
 
  <https://github.com/jazzband/pip-tools>`_ (the ``pip-compile`` utility) with
 
  ``gunicorn`` and ``futures`` in the ``.in.`` file.
 

	
 
**wsgi_requirements_in** (list, optional, ``[ futures, gunicorn ]``)
 
**wsgi_requirements_in** (list, optional, ``[ gunicorn ]``)
 
  List of top level packages to use when performing the pip
 
  requirements upgrade checks for the Gunicorn requirements (listed
 
  via ``wsgi_requirements`` parameter). For Python 3-based websites,
 
  it should be sufficient to list only ``gunicorn`` (``futures`` is
 
  required for Python 2).
 
  via ``wsgi_requirements`` parameter).
 

	
 

	
 
Distribution compatibility
 
~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
Role is compatible with the following distributions:
docs/usage.rst
Show inline comments
 
@@ -1868,14 +1868,12 @@ on the safe side:
 
            - libjpeg62-turbo
 
            - libjpeg-dev
 
            - libpng16-16
 
            - libpng-dev
 
            - libmariadb-dev
 
            - libmariadb-dev-compat
 
          # Specify that Python 3 should be used for the application
 
          python_version: 3
 
          # Here we specify that anything accessing our website with "/static/"
 
          # URL should be treated as request to a static file, to be served
 
          # directly by Nginx instead of the WSGI server.
 
          static_locations:
 
            - /static/
 
          # Again, not mandatory, but it is good to have some sort of policy
roles/common/molecule/default/tests/test_default.py
Show inline comments
 
@@ -323,14 +323,13 @@ def test_pipreqcheck_virtualenv_packages(host):
 

	
 
    # Normalise package names and order.
 
    expected_packages = sorted([p.lower() for p in expected_packages])
 
    actual_packages = sorted(packages.stdout.lower().strip().split("\n"))
 

	
 
    # This is a dummy distro-provided package ignored by the
 
    # pip-tools. pkg-resources for Python 2.7, pkg_resources for
 
    # Python 3.
 
    # pip-tools. Two variants of this name have been previously known.
 
    if "pkg-resources==0.0.0" in actual_packages:
 
        actual_packages.remove("pkg-resources==0.0.0")
 
    if "pkg_resources==0.0.0" in actual_packages:
 
        actual_packages.remove("pkg_resources==0.0.0")
 

	
 
    assert actual_packages == expected_packages
roles/wsgi_website/molecule/default/tests/test_default.py
Show inline comments
 
@@ -509,15 +509,13 @@ def test_python_version_in_virtualenv(host, python_path, expected_version):
 
    with host.sudo():
 

	
 
        python_version = host.run(python_path + " --version")
 

	
 
        assert python_version.rc == 0
 

	
 
        # Python 2 outputs version to stderr, Python 3 outputs it to
 
        # stdout. Go figure.
 
        assert expected_version in python_version.stdout or expected_version in python_version.stderr
 
        assert expected_version in python_version.stdout
 

	
 

	
 
@pytest.mark.parametrize("fqdn, pip_check_requirements_upgrades_directory, expected_requirements_in, expected_requirements", [
 
    ("parameters-mandatory", "/etc/pip_check_requirements_upgrades",  ["gunicorn"], ["gunicorn==21.2.0", "packaging==23.2"]),
 
    ("parameters-optional.local", "/etc/pip_check_requirements_upgrades", ["gunicorn"], ["gunicorn==21.1.0", "packaging==23.2"]),
 
    ("parameters-paste-req", "/etc/pip_check_requirements_upgrades", ["gunicorn"], ["gunicorn==21.1.0", "packaging==23.2"]),
testsite/playbooks/roles/wsgihello2/meta/main.yml
Show inline comments
 
@@ -13,10 +13,9 @@ dependencies:
 
    environment_variables:
 
      WEBSITE_NAME: "Majic Ansible Roles Test Site"
 
    wsgi_requirements:
 
      - gunicorn==19.9.0
 
    wsgi_requirements_in:
 
      - gunicorn
 
    python_version: 3
 
  - role: database
 
    db_name: wsgi_{{ testsite_domain_underscores }}
 
    db_password: wsgi_{{ testsite_domain_underscores }}
testsite/playbooks/roles/wsgihello2/tasks/main.yml
Show inline comments
 
@@ -2,13 +2,13 @@
 

	
 
- name: Create directory for storing code
 
  file: dest="/var/www/wsgireq.{{ testsite_domain }}/code/" state=directory
 
        owner="admin-wsgireq_{{ testsite_domain_underscores }}" group="web-wsgireq_{{ testsite_domain_underscores }}" mode=2750
 

	
 
- name: Deploy requirements and its source for upgrade checks
 
  copy: src="{{ item }}" dest="/etc/pip_check_requirements_upgrades-py3/wsgireq.{{ testsite_domain }}/{{ item }}"
 
  copy: src="{{ item }}" dest="/etc/pip_check_requirements_upgrades/wsgireq.{{ testsite_domain }}/{{ item }}"
 
        owner="root" group="pipreqcheck" mode=640
 
  with_items:
 
    - requirements.in
 
    - requirements.txt
 

	
 
- name: Deploy requirements
0 comments (0 inline, 0 general)