Changeset - 27483663f5f0
[Not reviewed]
0 4 3
Branko Majic (branko) - 3 years ago 2020-12-23 21:09:49
branko@majic.rs
MAR-168: Introduce additional machine in database_server tests for testing deprecated features:

- Updated Molecule configuration, defining an additional machine.
- Set-up the new machine with pre-installed MariaDB server instance,
root login with password, and separate Debian system maintenance
user.
- Set-up configuration files for root and Debian system maintenance
user login.
- Run the default set of tests on the deprecated machine group.
7 files changed with 85 insertions and 1 deletions:
0 comments (0 inline, 0 general)
roles/database_server/molecule/default/files/deprecated-debian.cnf
Show inline comments
 
new file 100644
 
# Automatically generated for Debian scripts. DO NOT TOUCH!
 
[client]
 
host     = localhost
 
user     = debian-sys-maint
 
password = debian-sys-maint-password
 
socket   = /var/run/mysqld/mysqld.sock
 
[mysql_upgrade]
 
host     = localhost
 
user     = debian-sys-maint
 
password = debian-sys-maint-password
 
socket   = /var/run/mysqld/mysqld.sock
 
basedir  = /usr
roles/database_server/molecule/default/files/deprecated-root-my.cnf
Show inline comments
 
new file 100644
 
[client]
 
user=root
 
password=root_password
roles/database_server/molecule/default/group_vars/deprecated.yml
Show inline comments
 
new file 100644
 
---
 

	
 
db_root_password: "root_password"
roles/database_server/molecule/default/molecule.yml
Show inline comments
 
@@ -21,6 +21,13 @@ platforms:
 
    memory: 512
 
    cpus: 1
 

	
 
  - name: deprecated-stretch64
 
    groups:
 
      - deprecated
 
    box: debian/contrib-stretch64
 
    memory: 512
 
    cpus: 1
 

	
 
provisioner:
 
  name: ansible
 
  config_options:
roles/database_server/molecule/default/playbook.yml
Show inline comments
 
---
 

	
 
- hosts: parameters-mandatory
 
- hosts: parameters-mandatory,deprecated
 
  become: true
 
  roles:
 
    - database_server
roles/database_server/molecule/default/prepare.yml
Show inline comments
 
@@ -17,3 +17,57 @@
 
      apt:
 
        update_cache: true
 
      changed_when: false
 

	
 
- hosts: deprecated
 
  become: true
 
  tasks:
 

	
 
  - name: Install MariaDB
 
    apt:
 
      name:
 
        - mariadb-client
 
        - mariadb-server
 
        - python3-mysqldb
 
      state: present
 

	
 
  - name: Enable and start MariaDB
 
    service:
 
      name: mysql
 
      state: started
 
      enabled: true
 

	
 
  - name: Set password for the root database user (creating separate entry for different hosts)
 
    mysql_user:
 
      check_implicit_admin: true
 
      name: root
 
      host: "{{ item }}"
 
      password: "root_password"
 
    with_items:
 
      - "localhost"
 
      - "127.0.0.1"
 
      - "::1"
 
      - "{{ ansible_hostname }}"
 

	
 
  - name: Deploy username and password for the root database user
 
    copy:
 
      src: "deprecated-root-my.cnf"
 
      dest: "/root/.my.cnf"
 
      owner: root
 
      group: root
 
      mode: 0400
 

	
 
  - name: Disable use of unix socket login
 
    command: "mysql -B -e \"update mysql.user set plugin='' where user='root' and plugin='unix_socket'; flush privileges;\""
 

	
 
  - name: Create Debian system maintenance user
 
    mysql_user:
 
      name: debian-sys-maint
 
      password: debian-sys-maint-password
 

	
 
  - name: Deploy Debian system maintenance user login configuration
 
    copy:
 
      src: "deprecated-debian.cnf"
 
      dest: "/etc/mysql/debian.cnf"
 
      owner: root
 
      group: root
 
      mode: 0600
roles/database_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -6,6 +6,11 @@ import testinfra.utils.ansible_runner
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-mandatory')
 

	
 
testinfra_hosts += testinfra.utils.ansible_runner.AnsibleRunner(
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('deprecated')
 

	
 
testinfra_hosts = sorted(set(testinfra_hosts))
 

	
 

	
 
def test_installed_packages(host):
 
    """
0 comments (0 inline, 0 general)