diff --git a/docs/releasenotes.rst b/docs/releasenotes.rst index cc0cc10f6ef9f1917d8b37ab3f6e0acfc4eeebc0..06534562b376b366fc256aae4c79bcc7351738ee 100644 --- a/docs/releasenotes.rst +++ b/docs/releasenotes.rst @@ -76,6 +76,11 @@ Breaking changes: deprecated and removed. Existing roles should be updated to utilise the ``wsgi_requirements`` parameter instead. + * Added parameter ``wsgi_requirements_in`` for listing top-level + packages for performing pip requirements upgrade checks for + Gunicorn requirements (listed via existing ``wsgi_requirements`` + parameter). + * ``xmpp_server`` role * Use 2048-bit Diffie-Hellman parameters for relevant TLS diff --git a/docs/rolereference.rst b/docs/rolereference.rst index d6533036d645a4279c6886532bc37b42dd91ea7e..0676d0f631faed9a5c2ffd98860e95dad643df81 100644 --- a/docs/rolereference.rst +++ b/docs/rolereference.rst @@ -1900,6 +1900,13 @@ Parameters `_ (the ``pip-compile`` utility) with ``gunicorn`` and ``futures`` in the ``.in.`` file. +**wsgi_requirements_in** (list, optional, ``[ futures, 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). + Distribution compatibility ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/roles/wsgi_website/defaults/main.yml b/roles/wsgi_website/defaults/main.yml index 55286751a2dbdc7344ddadd4387329affaaf92a4..de95ba0e22238da6ea187fb297611570a8ae1e7d 100644 --- a/roles/wsgi_website/defaults/main.yml +++ b/roles/wsgi_website/defaults/main.yml @@ -15,6 +15,9 @@ python_version: 2 wsgi_requirements: - futures==3.3.0 - gunicorn==19.10.0 +wsgi_requirements_in: + - futures + - gunicorn # Internal parameters. admin: "admin-{{ fqdn | replace('.', '_') }}" diff --git a/roles/wsgi_website/molecule/default/playbook.yml b/roles/wsgi_website/molecule/default/playbook.yml index 55238a7ac667c52396594f2dcf933d86221419c1..fcac8e8344822bc0ba653e96eda332e9f33bb424 100644 --- a/roles/wsgi_website/molecule/default/playbook.yml +++ b/roles/wsgi_website/molecule/default/playbook.yml @@ -63,6 +63,8 @@ wsgi_requirements: - futures==3.1.1 - gunicorn==20.0.4 + wsgi_requirements_in: + - gunicorn python_version: 3 - role: wsgi_website diff --git a/roles/wsgi_website/molecule/default/tests/test_default.py b/roles/wsgi_website/molecule/default/tests/test_default.py index 9b9a20f4b76ae6d90a61435b7ca85f5a84fde247..82f5db009b7bad3f4585bb3107a2ee51135b98c4 100644 --- a/roles/wsgi_website/molecule/default/tests/test_default.py +++ b/roles/wsgi_website/molecule/default/tests/test_default.py @@ -541,12 +541,12 @@ def test_python_version_in_virtualenv(host, python_path, expected_version): assert expected_version in python_version.stdout or expected_version in python_version.stderr -@pytest.mark.parametrize("fqdn, expected_packages", [ - ("parameters-mandatory", ["futures==3.3.0", "gunicorn==19.10.0"]), - ("parameters-optional.local", ["futures==3.1.1", "gunicorn==20.0.4"]), - ("parameters-paste-req", ["futures==3.1.1", "gunicorn==19.8.1"]), +@pytest.mark.parametrize("fqdn, expected_requirements_in, expected_requirements", [ + ("parameters-mandatory", ["futures", "gunicorn"], ["futures==3.3.0", "gunicorn==19.10.0"]), + ("parameters-optional.local", ["gunicorn"], ["futures==3.1.1", "gunicorn==20.0.4"]), + ("parameters-paste-req", ["futures", "gunicorn"], ["futures==3.1.1", "gunicorn==19.8.1"]), ]) -def test_wsgi_requirements(host, fqdn, expected_packages): +def test_wsgi_requirements(host, fqdn, expected_requirements_in, expected_requirements): """ Tests if Python requirements files are set-up correctly (for both installation and upgrade checks). @@ -564,7 +564,9 @@ def test_wsgi_requirements(host, fqdn, expected_packages): assert config.user == 'root' assert config.group == 'pipreqcheck' assert config.mode == 0o640 - assert config.content_string == "futures\ngunicorn\n" + + check_requirements_in = config.content_string.strip().split("\n") + assert check_requirements_in == expected_requirements_in config = host.file('/etc/pip_check_requirements_upgrades/%s/wsgi_requirements.txt' % fqdn) assert config.is_file @@ -572,8 +574,8 @@ def test_wsgi_requirements(host, fqdn, expected_packages): assert config.group == 'pipreqcheck' assert config.mode == 0o640 - check_packages = config.content_string.strip().split("\n") - assert check_packages == expected_packages + check_requirements = config.content_string.strip().split("\n") + assert check_requirements == expected_requirements requirements = host.file('/var/www/%s/.wsgi_requirements.txt' % fqdn) assert requirements.is_file @@ -581,5 +583,5 @@ def test_wsgi_requirements(host, fqdn, expected_packages): assert requirements.group == 'web-%s' % fqdn.replace(".", "_") assert requirements.mode == 0o640 - install_packages = requirements.content_string.strip().split("\n") - assert install_packages == expected_packages + install_requirements = requirements.content_string.strip().split("\n") + assert install_requirements == expected_requirements diff --git a/roles/wsgi_website/templates/wsgi_requirements.in.j2 b/roles/wsgi_website/templates/wsgi_requirements.in.j2 index a1aba3a63a9245813ca7791e0047a7f5f8818988..8c70825d2e4366381cf24f3f97ef1c6dbcc57d29 100644 --- a/roles/wsgi_website/templates/wsgi_requirements.in.j2 +++ b/roles/wsgi_website/templates/wsgi_requirements.in.j2 @@ -1,2 +1,3 @@ -futures -gunicorn +{% for requirement in wsgi_requirements_in %} +{{ requirement }} +{% endfor %}