Changeset - 9a06395ab828
[Not reviewed]
0 6 0
Branko Majic (branko) - 4 years ago 2020-05-06 01:20:53
branko@majic.rs
MAR-152: Drop support for Debian 8 Jessie from the common role.
6 files changed with 3 insertions and 80 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -427,32 +427,24 @@ Parameters
 
  needs to be updated from time to time as the new releases of
 
  ``pip-tools`` and related packages are coming out. For Python 3, see
 
  the dedicatd parameter ``pip_check_requirements_py3`` below.
 

	
 
**pip_check_requirements_py3** (list, optional, ``[click==7.0, pip-tools==3.9.0, pip==19.1.1, setuptools==41.2.0, six==1.12.0, wheel==0.33.6]``)
 
  List of Python package requirements to install in Python 3 virtual
 
  environment in order to be able to run the ``pip-tools``
 
  applications as part of pip requirements upgrade checks. This list
 
  needs to be updated from time to time as the new releases of
 
  ``pip-tools`` and related packages are coming out. For Python 2, see
 
  the dedicatd parameter ``pip_check_requirements`` above.
 

	
 
  Take note that on Debian Jessie and Stretch there will be
 
  differences in what the system uses because of differing Python 3
 
  versions and deprecation around Python 3 minor version releases. The
 
  listed defaults are conservative on the side of being usable on both
 
  Debian Jessie and Debian Stretch as of time of this writing. For
 
  Debian Stretch machines you will most likely end up updating the
 
  list almost immediatelly.
 

	
 
**pipreqcheck_uid** (integer, optional, ``whatever OS picks``)
 
  UID for user running the pip requirements upgrade checks. User is created with
 
  name ``pipreqcheck``.
 

	
 
**pipreqcheck_gid** (integer, optional, ``whatever OS picks``)
 
  GID for user running the pip requirements upgrade checks. Group is created
 
  with name ``pipreqcheck``.
 

	
 
**prompt_colour** (string, optional, ``none``)
 
  Colour for showing the Bash prompt. Supported values are:
 

	
 
  ``black``, ``red``, ``green``, ``brown``, ``blue``, ``purple``, ``cyan``,
 
@@ -465,25 +457,24 @@ Parameters
 
**prompt_id** (string, optional, ``NONE``)
 
  Optional identifier appended to regular Bash prompt, useful for visually
 
  identifying distinct environments. For example, if set to ``test``, resulting
 
  prompt will be similar to ``admin@web[test]:~$``. Setting affects Bash shells
 
  *only*.
 

	
 

	
 
Distribution compatibility
 
~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
Role is compatible with the following distributions:
 

	
 
- Debian 8 (Jessie)
 
- Debian 9 (Stretch)
 

	
 

	
 
Examples
 
~~~~~~~~
 

	
 
Here is an example configuration for setting-up some common users, groups, and
 
packages on all servers:
 

	
 
.. code-block:: yaml
 

	
 
  ---
roles/common/molecule/default/group_vars/parameters-optional.yml
Show inline comments
 
@@ -22,26 +22,25 @@ os_users:
 
      - "{{ lookup('file', 'tests/data/ssh/clientkey3.pub') }}"
 
    # Password is 'user3'.
 
    password: "$6$nmx.21uLqT$9LrUqNUgUwIM.l0KFKgr2.kDEwe2lo7IbBIhnG70AGW7GTFdWBUFnGAxH15YxikTXhDJD/uxd.NNgojEOjRvx1"
 
os_groups:
 
  - name: group1
 
  - name: group2
 
    gid: 3001
 
  - name: group3
 
    gid: 3002
 
common_packages:
 
  - units
 
  - gnutls-bin
 
  - "{{ 'libmariadb-client-lgpl-dev-compat' if ansible_distribution_release == 'jessie'
 
  else 'libmariadbclient-dev-compat' if ansible_distribution_release == 'stretch' }}"
 
  - libmariadbclient-dev-compat
 
  - emacs24-nox
 
ca_certificates:
 
  cacert1: "{{ lookup('file', 'tests/data/x509/ca1.cert.pem') }}"
 
  cacert2: "{{ lookup('file', 'tests/data/x509/ca2.cert.pem') }}"
 
extra_backup_patterns:
 
  - /home/user1
 
  - /home/user2
 
incoming_connection_limit: 5/second
 
incoming_connection_limit_burst: 5
 
pipreqcheck_uid: 2500
 
pipreqcheck_gid: 2500
 
prompt_colour: cyan
roles/common/molecule/default/molecule.yml
Show inline comments
 
@@ -5,57 +5,33 @@ dependency: {}
 
driver:
 
  name: vagrant
 
  provider:
 
    name: virtualbox
 

	
 
lint:
 
  name: yamllint
 
  options:
 
    config-file: ../../.yamllint.yml
 

	
 
platforms:
 
  - name: helper
 
    box: debian/contrib-jessie64
 
    box: debian/contrib-stretch64
 
    memory: 512
 
    cpus: 1
 
    interfaces:
 
      - auto_config: true
 
        ip: 10.31.127.2
 
        network_name: private_network
 
        type: static
 

	
 
  - name: parameters-mandatory-jessie64
 
    groups:
 
      - parameters-mandatory
 
    box: debian/contrib-jessie64
 
    memory: 256
 
    cpus: 1
 
    interfaces:
 
      - auto_config: true
 
        ip: 10.31.127.3
 
        network_name: private_network
 
        type: static
 

	
 
  - name: parameters-optional-jessie64
 
    groups:
 
      - parameters-optional
 
    box: debian/contrib-jessie64
 
    memory: 256
 
    cpus: 1
 
    interfaces:
 
      - auto_config: true
 
        ip: 10.31.127.4
 
        network_name: private_network
 
        type: static
 

	
 
  - name: parameters-mandatory-stretch64
 
    groups:
 
      - parameters-mandatory
 
    box: debian/contrib-stretch64
 
    memory: 256
 
    cpus: 1
 
    interfaces:
 
      - auto_config: true
 
        ip: 10.31.127.5
 
        network_name: private_network
 
        type: static
 

	
roles/common/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -41,36 +41,24 @@ def test_ssh_login_mechanisms(host):
 
    sock = socket.socket()
 
    sock.connect((remote_ip, 22))
 

	
 
    transport = paramiko.transport.Transport(sock)
 
    transport.connect()
 

	
 
    try:
 
        transport.auth_none('')
 
    except paramiko.transport.BadAuthenticationType, err:
 
        assert err.allowed_types == ['publickey']
 

	
 

	
 
def test_mariadb_mysql_config_symlink(host):
 
    """
 
    Tests if symbolic link has been set-up for mariadb_config binary to be
 
    accessible as mysql_config as well. (should not be present with just
 
    mandatory options set).
 
    """
 

	
 
    mysql_config = host.file('/usr/bin/mysql_config')
 

	
 
    assert not mysql_config.exists
 

	
 

	
 
def test_emacs_electric_indent_mode(host):
 
    """
 
    Tests if Emacs electric indent mode has been disabled via custom
 
    configuration file. With just mandatory options set, the file should not be
 
    present.
 
    """
 

	
 
    emacs_config = host.file('/etc/emacs/site-start.d/01disable-electric-indent-mode')
 

	
 
    assert not emacs_config.exists
 

	
 

	
roles/common/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -32,73 +32,49 @@ def test_bash_prompt_content(host):
 

	
 
    config = host.file('/etc/profile.d/bash_prompt.sh')
 

	
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[0;36m\\]\\u@\\h[test]:\\w\\$ \\[\\033[0m\\]'" in config.content
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\u@\\h[test]:\\w\\$ '" in config.content
 

	
 

	
 
def test_common_installed_packages_common(host):
 
    """
 
    Tests that user-provided common packages have been installed.
 
    """
 

	
 
    debian_release = host.ansible("setup")["ansible_facts"]["ansible_distribution_release"]
 

	
 
    assert host.package('units').is_installed
 
    assert host.package('gnutls-bin').is_installed
 

	
 
    # Different name of package in different Debian releases.
 
    if debian_release == 'jessie':
 
        assert host.package('libmariadb-client-lgpl-dev-compat').is_installed
 
    elif debian_release == 'stretch':
 
        assert host.package('libmariadbclient-dev-compat').is_installed
 
    else:
 
        raise Exception("Cannot run this test on debian release: %s" % debian_release)
 
    assert host.package('libmariadbclient-dev-compat').is_installed
 

	
 

	
 
def test_ssh_login_mechanisms(host):
 
    """
 
    Tests available SSH login mechanisms (should be just public key).
 
    """
 

	
 
    # Extract first non-IPv6 IP. Crude test, but it should work.
 
    remote_ip = next(a for a in host.interface("eth1").addresses if ":" not in a)
 

	
 
    sock = socket.socket()
 
    sock.connect((remote_ip, 22))
 

	
 
    transport = paramiko.transport.Transport(sock)
 
    transport.connect()
 

	
 
    try:
 
        transport.auth_none('')
 
    except paramiko.transport.BadAuthenticationType, err:
 
        assert err.allowed_types == ['publickey']
 

	
 

	
 
def test_mariadb_mysql_config_symlink(host):
 
    """
 
    Tests if symbolic link has been set-up for mariadb_config binary to be
 
    accessible as mysql_config as well.
 

	
 
    Only applicable to Debian Jessie.
 
    """
 

	
 
    if host.ansible("setup")["ansible_facts"]["ansible_distribution_release"] == 'jessie':
 
        mysql_config = host.file('/usr/bin/mysql_config')
 

	
 
        assert mysql_config.is_symlink
 
        assert mysql_config.linked_to == '/usr/bin/mariadb_config'
 

	
 

	
 
def test_emacs_electric_indent_mode(host):
 
    """
 
    Tests if Emacs electric indent mode has been disabled via custom
 
    configuration file.
 
    """
 

	
 
    emacs_config = host.file('/etc/emacs/site-start.d/01disable-electric-indent-mode.el')
 

	
 
    assert emacs_config.is_file
 
    assert emacs_config.user == 'root'
 
    assert emacs_config.group == 'root'
 
    assert emacs_config.mode == 0o644
roles/common/tasks/main.yml
Show inline comments
 
@@ -93,31 +93,24 @@
 
    state: present
 

	
 
- name: Install rcconf (workaround for systemctl broken handling of SysV)
 
  apt:
 
    name: rcconf
 
    state: present
 

	
 
- name: Install common packages
 
  apt:
 
    name: "{{ common_packages }}"
 
    state: "present"
 

	
 
- 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 common_packages and ansible_distribution_release == 'jessie'"
 

	
 
- name: Disable electric-indent-mode for Emacs by default for all users
 
  copy:
 
    src: "01disable-electric-indent-mode.el"
 
    dest: "/etc/emacs/site-start.d/01disable-electric-indent-mode.el"
 
    owner: root
 
    group: root
 
    mode: 0644
 
  when: "'emacs24' in common_packages or 'emacs24-nox' in common_packages"
 

	
 
- name: Set-up operating system groups
 
  group:
 
    name: "{{ item.name }}"
0 comments (0 inline, 0 general)