From ea4c2097d466d95a528a714f2ede5924e26fdb09 Mon Sep 17 00:00:00 2001 From: nd Date: Thu, 20 Sep 2018 13:19:38 +0200 Subject: [PATCH] Initial commit --- defaults/main.yml | 11 +++++++++++ handlers/main.yml | 3 +++ tasks/main.yml | 22 ++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 tasks/main.yml diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..58f569d --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,11 @@ +mariadb: + users: {} +# mysql: +# host: localhost +# password: foobar +# priv: *.*:USAGE + dbs: {} +# database: +# collation: utf8_general_ci +# encoding: utf8 + diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..6f737d9 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart mariadb + service: name=mariadb state=restarted diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..7e0d4c7 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: install mariadb + apt: + pkg: "{{ item }}" + with_items: + - mariadb-server + - python-mysqldb + +- name: create mariadb dbs + mysql_db: + name: "{{ item.key }}" + collation: "{{ item.value.collation | default('utf8_general_ci') }}" + encoding: "{{ item.value.encoding | default('utf8') }}" + with_dict: "{{ mariadb.dbs }}" + +- name: create mariadb users + mysql_user: + name: "{{ item.key }}" + host: "{{ item.value.host | default('localhost') }}" + password: "{{ item.value.password }}" + priv: "{{ item.value.priv | default('*.*:USAGE') }}" + with_dict: "{{ mariadb.users }}"