Changeset - 6f26ccefa724
[Not reviewed]
0 7 0
Branko Majic (branko) - 3 years ago 2021-01-15 00:19:45
branko@majic.rs
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).
7 files changed with 35 insertions and 8 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -1668,6 +1668,7 @@ Distribution compatibility
 
Role is compatible with the following distributions:
 

	
 
- Debian 9 (Stretch)
 
- Debian 10 (Buster)
 

	
 

	
 
Examples
roles/php_website/defaults/main.yml
Show inline comments
 
@@ -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] }}"
roles/php_website/meta/main.yml
Show inline comments
 
@@ -14,5 +14,5 @@ galaxy_info:
 
  platforms:
 
    - name: Debian
 
      versions:
 
        - 8
 
        - 9
 
        - 10
roles/php_website/molecule/default/molecule.yml
Show inline comments
 
@@ -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:
roles/php_website/molecule/default/playbook.yml
Show inline comments
 
@@ -45,7 +45,6 @@
 
      packages:
 
        - "php-ldap"
 
        - "php-json"
 
        - "libmariadbclient-dev-compat"
 
      uid: 5001
 
      website_mail_recipients: user
 

	
roles/php_website/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -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():
 

	
roles/php_website/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -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):
0 comments (0 inline, 0 general)