From 6f26ccefa724a6ed22624e52104d6f52adfa6526 2021-01-15 00:19:45 From: Branko Majic Date: 2021-01-15 00:19:45 Subject: [PATCH] MAR-151: Added support for Debian 10 Buster to php_website role: - Updated role reference documentaiton. - Updated role meta information. - Updated tests. - Refactor the code to take into account differences in PHP-related paths between Debian Stretch and Debian Buster. - Make the test for web application user less dependant on what the actual UID number is in case of default value. By default user should be created as system user, which means its UID number should be less than 1000. - Drop the installation of libmariadbclient-dev-compat library - the test is good enough without it, and the actual package is differently named under Debian Stretch and Debian Buster (which would complicate the test without any benefits). --- diff --git a/docs/rolereference.rst b/docs/rolereference.rst index bdd111f21236b9a8b99cbf0cd1b894f152beabbc..80da48de196e17dcd42661cdbc74a6f80cf84176 100644 --- a/docs/rolereference.rst +++ b/docs/rolereference.rst @@ -1668,6 +1668,7 @@ Distribution compatibility Role is compatible with the following distributions: - Debian 9 (Stretch) +- Debian 10 (Buster) Examples diff --git a/roles/php_website/defaults/main.yml b/roles/php_website/defaults/main.yml index c56f66bbd2a58b040e14b478218e854c0de4faa2..06cdc595f15e05d252c5ffa7ac857a14592ddce9 100644 --- a/roles/php_website/defaults/main.yml +++ b/roles/php_website/defaults/main.yml @@ -12,9 +12,21 @@ website_mail_recipients: "root" environment_indicator: null # Internal parameters. +php_fpm_service_name_per_release: + stretch: "php7.0-fpm" + buster: "php7.3-fpm" + +php_fpm_binary_per_release: + stretch: "php-fpm7.0" + buster: "php-fpm7.3" + +php_fpm_pool_directory_per_release: + stretch: "/etc/php/7.0/fpm/pool.d" + buster: "/etc/php/7.3/fpm/pool.d" + admin: "admin-{{ fqdn | replace('.', '_') }}" user: "web-{{ fqdn | replace('.', '_') }}" home: "/var/www/{{ fqdn }}" -php_fpm_pool_directory: "/etc/php/7.0/fpm/pool.d" -php_fpm_binary: "php-fpm7.0" -php_fpm_service_name: "php7.0-fpm" +php_fpm_pool_directory: "{{ php_fpm_pool_directory_per_release[ansible_distribution_release] }}" +php_fpm_binary: "{{ php_fpm_binary_per_release[ansible_distribution_release] }}" +php_fpm_service_name: "{{ php_fpm_service_name_per_release[ansible_distribution_release] }}" diff --git a/roles/php_website/meta/main.yml b/roles/php_website/meta/main.yml index 59e1ca18c3bbc4ec30f88c0424ddc85008a68dc9..b3a13833d411d69ba60397ef7e0bb2c631338256 100644 --- a/roles/php_website/meta/main.yml +++ b/roles/php_website/meta/main.yml @@ -14,5 +14,5 @@ galaxy_info: platforms: - name: Debian versions: - - 8 - 9 + - 10 diff --git a/roles/php_website/molecule/default/molecule.yml b/roles/php_website/molecule/default/molecule.yml index f76e5571d27dad30c0b9911059cb1f28ff50dc97..3701c7bde2216577d46daea60c846d481bb796db 100644 --- a/roles/php_website/molecule/default/molecule.yml +++ b/roles/php_website/molecule/default/molecule.yml @@ -23,6 +23,15 @@ platforms: memory: 512 cpus: 1 + - name: php-website-buster64 + groups: + - parameters-mandatory + - parameters-optional + - buster + box: debian/contrib-buster64 + memory: 512 + cpus: 1 + provisioner: name: ansible playbooks: diff --git a/roles/php_website/molecule/default/playbook.yml b/roles/php_website/molecule/default/playbook.yml index fbb5302a7fa143541c0ea597c8dadbf9802a6310..7d385bb9653a4c761bd565d107316ef2c2478b07 100644 --- a/roles/php_website/molecule/default/playbook.yml +++ b/roles/php_website/molecule/default/playbook.yml @@ -45,7 +45,6 @@ packages: - "php-ldap" - "php-json" - - "libmariadbclient-dev-compat" uid: 5001 website_mail_recipients: user diff --git a/roles/php_website/molecule/default/tests/test_parameters_mandatory.py b/roles/php_website/molecule/default/tests/test_parameters_mandatory.py index a3d656525217991308075a4c74167129b9d5a34d..3f091c8c6e560dd2a57b07288d8a8e667690a4e6 100644 --- a/roles/php_website/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/php_website/molecule/default/tests/test_parameters_mandatory.py @@ -71,7 +71,7 @@ def test_website_application_user(host): user = host.user('web-parameters-mandatory') assert user.exists - assert user.uid == 999 + assert user.uid < 1000 assert user.group == 'web-parameters-mandatory' assert user.groups == ['web-parameters-mandatory'] assert user.shell == '/bin/sh' @@ -137,7 +137,14 @@ def test_php_fpm_configuration_file(host): Tests if PHP FPM configuration file has been correctly deployed. """ - config_file_path = '/etc/php/7.0/fpm/pool.d/parameters-mandatory.conf' + distribution_release = host.ansible("setup")["ansible_facts"]["ansible_distribution_release"] + + if distribution_release == "stretch": + config_file_path = '/etc/php/7.0/fpm/pool.d/parameters-mandatory.conf' + elif distribution_release == "buster": + config_file_path = '/etc/php/7.3/fpm/pool.d/parameters-mandatory.conf' + else: + raise Exception("Tried running test on unsupported distribution: %s" % distribution_release) with host.sudo(): diff --git a/roles/php_website/molecule/default/tests/test_parameters_optional.py b/roles/php_website/molecule/default/tests/test_parameters_optional.py index 08a94564c657f0163dc1e22a4382994a55c57ae2..ed1e5840e5a7462e036d08140efca37de8bd7bbb 100644 --- a/roles/php_website/molecule/default/tests/test_parameters_optional.py +++ b/roles/php_website/molecule/default/tests/test_parameters_optional.py @@ -139,7 +139,6 @@ def test_installed_packages(host): assert host.package('php-ldap').is_installed assert host.package('php-json').is_installed - assert host.package('libmariadbclient-dev-compat').is_installed def test_certificate_validity_check_configuration(host):