Changeset - 38c3569bdc6a
[Not reviewed]
0 10 0
Branko Majic (branko) - 3 years ago 2021-01-15 01:03:49
branko@majic.rs
MAR-151: Added support for Debian 10 Buster to wsgi_website role:

- Updated role reference documentaiton.
- Updated role meta information.
- Updated tests.
- Replace the installation of libmariadbclient-dev-compat library with
atftp - the actual package is differently named under Debian Stretch
and Debian Buster (which would complicate the test without any
benefits).
- Drop the fix for root mail alias in Vagrant image - seems it's no
longer a problem.
- Split-up the test for web application user since it's not possible
to keep it all under one parametrised test due to differences in
assigned system UID numbers for 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.
10 files changed with 87 insertions and 43 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -1965,6 +1965,7 @@ Distribution compatibility
 
Role is compatible with the following distributions:
 

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

	
 

	
 
Examples
roles/wsgi_website/meta/main.yml
Show inline comments
 
@@ -14,5 +14,5 @@ galaxy_info:
 
  platforms:
 
    - name: Debian
 
      versions:
 
        - 8
 
        - 9
 
        - 10
roles/wsgi_website/molecule/default/molecule.yml
Show inline comments
 
@@ -24,6 +24,16 @@ platforms:
 
    memory: 512
 
    cpus: 1
 

	
 
  - name: wsgi-website-buster64
 
    groups:
 
      - wsgi-website
 
      - parameters-mandatory
 
      - parameters-optional
 
      - buster
 
    box: debian/contrib-buster64
 
    memory: 512
 
    cpus: 1
 

	
 
provisioner:
 
  name: ansible
 
  playbooks:
roles/wsgi_website/molecule/default/playbook.yml
Show inline comments
 
@@ -33,7 +33,7 @@
 
      environment_variables:
 
        MY_ENV_VAR: "My environment variable"
 
      packages:
 
        - "libmariadbclient-dev-compat"
 
        - atftp
 
        - global
 
      proxy_headers:
 
        Accept-Encoding: '""'
roles/wsgi_website/molecule/default/prepare.yml
Show inline comments
 
@@ -98,15 +98,6 @@
 
      notify:
 
        - Restart Postfix
 

	
 
    - name: Direct all mails from the root account to vagrant (Stretch image does not do that by default)
 
      lineinfile:
 
        path: /etc/aliases
 
        regexp: "^root"
 
        line: "root: vagrant"
 
        state: present
 
      notify:
 
        - Generate aliases database
 

	
 
    - name: Set-up group for an additional user
 
      group:
 
        name: user
roles/wsgi_website/molecule/default/tests/test_default.py
Show inline comments
 
@@ -137,30 +137,6 @@ def test_profile_configuration(host, admin_user, expected_virtualenv_path):
 
    assert env.stdout == expected_virtualenv_path
 

	
 

	
 
@pytest.mark.parametrize("app_user, expected_uid, expected_group, expected_home", [
 
    ('web-parameters-mandatory', 999, 'web-parameters-mandatory', '/var/www/parameters-mandatory'),
 
    ('web-parameters-optional_local', 5001, 'web-parameters-optional_local', '/var/www/parameters-optional.local'),
 
    ('web-parameters-paste-req', 998, 'web-parameters-paste-req', '/var/www/parameters-paste-req'),
 
])
 
def test_website_application_user(host, app_user, expected_uid, expected_group, expected_home):
 
    """
 
    Tests if website application user has been created correctly.
 
    """
 

	
 
    user = host.user(app_user)
 

	
 
    assert user.exists
 
    assert user.uid == expected_uid
 
    assert user.group == expected_group
 
    assert user.groups == [expected_group]
 
    assert user.shell == '/bin/sh'
 
    assert user.home == expected_home
 

	
 
    with host.sudo():
 
        umask = host.run("su -l " + app_user + " -c 'bash -c umask'")
 
        assert umask.stdout == '0007\n'
 

	
 

	
 
@pytest.mark.parametrize("expected_group", [
 
    'web-parameters-mandatory',
 
    'web-parameters-optional_local',
roles/wsgi_website/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -40,3 +40,27 @@ def test_static_file_serving(host):
 
    assert page.rc == 0
 
    assert "This is the WSGI application at parameters-mandatory." in page.stdout
 
    assert "Requested URL was: https://parameters-mandatory/media/media_file.txt" in page.stdout
 

	
 

	
 
def test_website_application_user(host):
 
    """
 
    Tests if website application user has been created correctly.
 
    """
 

	
 
    app_user = "web-parameters-mandatory"
 

	
 
    expected_group = "web-parameters-mandatory"
 
    expected_home = "/var/www/parameters-mandatory"
 

	
 
    user = host.user(app_user)
 

	
 
    assert user.exists
 
    assert user.uid < 1000
 
    assert user.group == expected_group
 
    assert user.groups == [expected_group]
 
    assert user.shell == '/bin/sh'
 
    assert user.home == expected_home
 

	
 
    with host.sudo():
 
        umask = host.run("su -l " + app_user + " -c 'bash -c umask'")
 
        assert umask.stdout == '0007\n'
roles/wsgi_website/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -12,7 +12,7 @@ def test_installed_packages(host):
 
    Tests if additional packages are installed.
 
    """
 

	
 
    assert host.package('libmariadbclient-dev-compat').is_installed
 
    assert host.package('atftp').is_installed
 
    assert host.package('global').is_installed
 

	
 

	
 
@@ -83,3 +83,28 @@ def test_nginx_rewrite_config(host):
 
    page = host.run('curl https://parameters-optional.local/rewrite2/some/other/path')
 
    assert page.rc == 0
 
    assert "Requested URL was: https://parameters-optional.local/rewritten2/some/other/path" in page.stdout
 

	
 

	
 
def test_website_application_user(host):
 
    """
 
    Tests if website application user has been created correctly.
 
    """
 

	
 
    app_user = "web-parameters-optional_local"
 

	
 
    expected_group = "web-parameters-optional_local"
 
    expected_home = "/var/www/parameters-optional.local"
 
    expected_uid = 5001
 

	
 
    user = host.user(app_user)
 

	
 
    assert user.exists
 
    assert user.uid == expected_uid
 
    assert user.group == expected_group
 
    assert user.groups == [expected_group]
 
    assert user.shell == '/bin/sh'
 
    assert user.home == expected_home
 

	
 
    with host.sudo():
 
        umask = host.run("su -l " + app_user + " -c 'bash -c umask'")
 
        assert umask.stdout == '0007\n'
roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py
Show inline comments
 
@@ -40,3 +40,27 @@ def test_static_file_serving(host):
 
    assert page.rc == 0
 
    assert "This is the WSGI application at parameters-paste-req." in page.stdout
 
    assert "Requested URL was: https://parameters-paste-req/media/media_file.txt" in page.stdout
 

	
 

	
 
def test_website_application_user(host):
 
    """
 
    Tests if website application user has been created correctly.
 
    """
 

	
 
    app_user = "web-parameters-paste-req"
 

	
 
    expected_group = "web-parameters-paste-req"
 
    expected_home = "/var/www/parameters-paste-req"
 

	
 
    user = host.user(app_user)
 

	
 
    assert user.exists
 
    assert user.uid < 1000
 
    assert user.group == expected_group
 
    assert user.groups == [expected_group]
 
    assert user.shell == '/bin/sh'
 
    assert user.home == expected_home
 

	
 
    with host.sudo():
 
        umask = host.run("su -l " + app_user + " -c 'bash -c umask'")
 
        assert umask.stdout == '0007\n'
roles/wsgi_website/tasks/main.yml
Show inline comments
 
@@ -81,13 +81,6 @@
 
  notify:
 
    - Restart WSGI services
 

	
 
- name: Set-up MariaDB mysql_config symbolic link for compatibility (workaround for Debian bug 766996)
 
  file:
 
    src: "/usr/bin/mariadb_config"
 
    dest: "/usr/bin/mysql_config"
 
    state: link
 
  when: "'libmariadb-client-lgpl-dev-compat' in packages"
 

	
 
# Ignore failures - the virtual environment might not have been
 
# created yet. Don't use --version because Python 2 outputs to stderr,
 
# and Python 3 outputs to stdout.
0 comments (0 inline, 0 general)