Changeset - 7f4f7163ae31
[Not reviewed]
0 8 0
Branko Majic (branko) - 2 months ago 2024-02-11 12:30:34
branko@majic.rs
MAR-154: Drop suppor for Python 2.7 from the wsgi_website role:

- Mostly a matter of dropping the Python version parameter, and
updating some package versioning to account for Python 3 only.
8 files changed with 34 insertions and 28 deletions:
0 comments (0 inline, 0 general)
docs/releasenotes.rst
Show inline comments
 
@@ -27,6 +27,18 @@ Dropped support for Debian 10 (Buster).
 
    renamed to ``pip_check_requirements`` /
 
    ``pip_check_requirements_in``.
 

	
 
* ``wsgi_website`` role
 

	
 
  * Dropped support for Python 2.7. Only Python 3 is supported now.
 

	
 
    The ``python_version`` role parameter has been dropped. The
 
    ``python_interpreter`` parameter is still available, but it
 
    defaults to Python 3 binary.
 

	
 
    Python (input) requirements files are now placed under the
 
    ``/etc/pip_check_requirements_upgrades`` path, in accordance to
 
    changes made in this release to the ``common`` role.
 

	
 
**Bug fixes:**
 

	
 
* ``common`` role
docs/rolereference.rst
Show inline comments
 
@@ -1882,9 +1882,6 @@ Parameters
 
  forget to surround them by another set of quotes for YAML syntax, for example
 
  ``"\"\""`` or ``'""'``).
 

	
 
**python_version** (string, optional, ``2``)
 
  Python version to use when setting-up the Python virtual environment.
 

	
 
**rewrites** (list, optional, ``[]``)
 
  A list of rewrite rules that are applied to incoming requests. Each element of
 
  the list should be a string value compatible with the format of ``nginx``
roles/wsgi_website/defaults/main.yml
Show inline comments
 
@@ -10,17 +10,15 @@ environment_variables: {}
 
website_mail_recipients: "root"
 
environment_indicator: null
 
proxy_headers: {}
 
python_version: 2
 
wsgi_requirements:
 
  - futures==3.3.0
 
  - gunicorn==19.10.0
 
  - gunicorn==21.2.0
 
  - packaging==23.2
 
wsgi_requirements_in:
 
  - futures
 
  - gunicorn
 

	
 
# Internal parameters.
 
admin: "admin-{{ fqdn | replace('.', '_') }}"
 
user: "web-{{ fqdn | replace('.', '_') }}"
 
home: "/var/www/{{ fqdn }}"
 
python_interpreter: "/usr/bin/python{{ python_version }}"
 
pip_check_requirements_upgrades_directory: "/etc/pip_check_requirements_upgrades{% if python_version | int == 3 %}-py3{% endif %}"
 
python_interpreter: "/usr/bin/python3"
 
pip_check_requirements_upgrades_directory: "/etc/pip_check_requirements_upgrades"
roles/wsgi_website/molecule/default/playbook.yml
Show inline comments
 
@@ -60,11 +60,10 @@
 
      website_mail_recipients: user
 
      wsgi_application: testapp:application
 
      wsgi_requirements:
 
        - futures==3.1.1
 
        - gunicorn==20.0.4
 
        - gunicorn==21.1.0
 
        - packaging==23.2
 
      wsgi_requirements_in:
 
        - gunicorn
 
      python_version: 3
 

	
 
    - role: wsgi_website
 
      fqdn: parameters-paste-req
 
@@ -82,8 +81,8 @@
 
        - Werkzeug==0.12.2
 
      wsgi_application: config.ini
 
      wsgi_requirements:
 
        - futures==3.1.1
 
        - gunicorn==19.8.1
 
        - gunicorn==21.1.0
 
        - packaging==23.2
 
      https_tls_certificate: "{{ lookup('file', 'tests/data/x509/server/parameters-paste-req_https.cert.pem') }}"
 
      https_tls_key: "{{ lookup('file', 'tests/data/x509/server/parameters-paste-req_https.key.pem') }}"
 

	
roles/wsgi_website/molecule/default/tests/test_default.py
Show inline comments
 
@@ -273,16 +273,16 @@ def test_python_virtualenv_wrapper_script(host, wrapper_script, expected_owner,
 

	
 
@pytest.mark.parametrize("admin_user, pip_path, expected_packages",  [
 
    ('admin-parameters-mandatory', '/var/www/parameters-mandatory/virtualenv/bin/pip', [
 
        "futures==3.3.0",
 
        "gunicorn==19.10.0",
 
        "gunicorn==21.2.0",
 
        "packaging==23.2",
 
    ]),
 
    ('admin-parameters-optional_local', '/var/www/parameters-optional.local/virtualenv/bin/pip', [
 
        "Pygments==2.2.0",
 
        "dnspython==1.15.0",
 
        "docopt==0.6.2",
 
        "futures==3.1.1",
 
        "gunicorn==20.0.4",
 
        "gunicorn==21.1.0",
 
        "jedi==0.13.1",
 
        "packaging==23.2",
 
        "parso==0.3.1",
 
        "prompt-toolkit==1.0.15",
 
        "ptpython==0.41",
 
@@ -298,9 +298,9 @@ def test_python_virtualenv_wrapper_script(host, wrapper_script, expected_owner,
 
        "PasteScript==2.0.2",
 
        "Werkzeug==0.12.2",
 
        "click==6.7",
 
        "futures==3.1.1",
 
        "gunicorn==19.8.1",
 
        "gunicorn==21.1.0",
 
        "itsdangerous==0.24",
 
        "packaging==23.2",
 
        "six==1.10.0",
 
    ]),
 
])
 
@@ -496,9 +496,9 @@ def test_website_enabled(host, config_file, expected_content):
 

	
 

	
 
@pytest.mark.parametrize("python_path, expected_version", [
 
    ("/var/www/parameters-mandatory/virtualenv/bin/python", "Python 2"),
 
    ("/var/www/parameters-mandatory/virtualenv/bin/python", "Python 3"),
 
    ("/var/www/parameters-optional.local/virtualenv/bin/python", "Python 3"),
 
    ("/var/www/parameters-paste-req/virtualenv/bin/python", "Python 2"),
 
    ("/var/www/parameters-paste-req/virtualenv/bin/python", "Python 3"),
 
])
 
def test_python_version_in_virtualenv(host, python_path, expected_version):
 
    """
 
@@ -518,9 +518,9 @@ def test_python_version_in_virtualenv(host, python_path, expected_version):
 

	
 

	
 
@pytest.mark.parametrize("fqdn, pip_check_requirements_upgrades_directory, expected_requirements_in, expected_requirements", [
 
    ("parameters-mandatory", "/etc/pip_check_requirements_upgrades",  ["futures", "gunicorn"], ["futures==3.3.0", "gunicorn==19.10.0"]),
 
    ("parameters-optional.local", "/etc/pip_check_requirements_upgrades-py3", ["gunicorn"], ["futures==3.1.1", "gunicorn==20.0.4"]),
 
    ("parameters-paste-req", "/etc/pip_check_requirements_upgrades", ["futures", "gunicorn"], ["futures==3.1.1", "gunicorn==19.8.1"]),
 
    ("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"]),
 
])
 
def test_wsgi_requirements(host, fqdn, pip_check_requirements_upgrades_directory, expected_requirements_in, expected_requirements):
 
    """
roles/wsgi_website/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -23,7 +23,7 @@ def test_index_page(host):
 
    assert "Requested URL was: https://parameters-mandatory/" in page.stdout
 
    assert "MY_ENV_VAR: None" in page.stdout
 
    assert "Accept-Encoding: plain" in page.stdout
 
    assert "Python version: 2." in page.stdout
 
    assert "Python version: 3." in page.stdout
 

	
 

	
 
def test_static_file_serving(host):
roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py
Show inline comments
 
@@ -23,7 +23,7 @@ def test_index_page(host):
 
    assert "Requested URL was: https://parameters-paste-req/" in page.stdout
 
    assert "MY_ENV_VAR: None" in page.stdout
 
    assert "Accept-Encoding: plain" in page.stdout
 
    assert "Python version: 2." in page.stdout
 
    assert "Python version: 3." in page.stdout
 

	
 

	
 
def test_static_file_serving(host):
roles/wsgi_website/tasks/main.yml
Show inline comments
 
@@ -94,7 +94,7 @@
 
  file:
 
    path: "{{ home }}/virtualenv"
 
    state: absent
 
  when: "current_python_version.rc == 0 and not current_python_version.stdout.startswith(python_version | string)"
 
  when: "current_python_version.rc == 0 and not current_python_version.stdout.startswith('3')"
 
  notify:
 
    - Restart WSGI services
 

	
0 comments (0 inline, 0 general)