Initial commit of MariaDB role

Change-Id: I8d35374da716712ecf0ab1f748c952cbc2635969
diff --git a/tasks/Debian.yml b/tasks/Debian.yml
new file mode 100644
index 0000000..935bdb6
--- /dev/null
+++ b/tasks/Debian.yml
@@ -0,0 +1,28 @@
+---
+# mariadb tasks/Debian.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+
+- name: Add MariaDB apt repo GPG key
+  apt_key:
+    data: "{{ lookup('file','mariadb.gpg') }}"
+    state: "present"
+
+- name: Add MariaDB apt repo
+  apt_repository:
+    repo: >-
+      deb [arch=amd64,arm64,ppc64el]
+      {{ mariadb_apt_mirror }}/repo/{{ mariadb_version }}/{{ ansible_lsb['id'] | lower }}
+      {{ ansible_lsb['codename'] }} main
+    update_cache: true
+
+- name: Install MariaDB packages
+  apt:
+    name: "{{ mariadb_packages }}"
+    state: "present"
+    update_cache: true
+    cache_valid_time: 3600
+  notify:
+    - start-mariadb
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..db69d80
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,67 @@
+---
+# mariadb tasks/main.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: include OS-specific vars
+  include_vars: "{{ ansible_os_family }}.yml"
+
+- name: include OS-specific tasks
+  include_tasks: "{{ ansible_os_family }}.yml"
+
+- name: Enable MariaDB Service
+  service:
+    name: "{{ mariadb_service }}"
+    enabled: true
+  notify:
+    - start-mariadb
+
+- name: Flush handlers to start MariaDB
+  meta: flush_handlers
+
+# Secure the installation
+
+- name: Set root user password
+  mysql_user:
+    name: root
+    password: "{{ mariadb_root_password }}"
+    host_all: true
+    login_unix_socket: /var/run/mysqld/mysqld.sock
+  no_log: true
+
+- name: Create root ~/.my.cnf file to specify new password
+  template:
+    src: user.my.cnf.j2
+    dest: "{{ ansible_env.HOME }}/.my.cnf"
+    owner: root
+    group: root
+    mode: 0600
+
+- name: Remove all anonymous users
+  mysql_user:
+    name: ''
+    host_all: true
+    state: absent
+  no_log: true
+
+- name: Remove default test database
+  mysql_db:
+    name: test
+    state: absent
+
+# Create databases
+- name: Create databases
+  mysql_db:
+    name: "{{ item.name }}"
+  with_items: "{{ mariadb_databases }}"
+
+# Create users
+- name: Create users
+  mysql_user:
+    name: "{{ item.name }}"
+    password: "{{ item.password }}"
+    host: localhost
+    priv: "{{ item.priv }}"
+  no_log: true
+  with_items: "{{ mariadb_users }}"