From 3aca9dedd329b9e81f1bdd03af6b095f3eb620db Mon Sep 17 00:00:00 2001 From: L3D Date: Sun, 10 Jan 2021 00:00:19 +0100 Subject: [PATCH] Update mailserver mysql tasks as handlers --- .../mailserver_preperation/handlers/main.yml | 16 +++++++++++++ roles/mailserver_preperation/tasks/hosts.yml | 1 + .../mailserver_preperation/tasks/mariadb.yml | 24 ++++--------------- roles/mailserver_preperation/vars/main.yml | 2 +- 4 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 roles/mailserver_preperation/handlers/main.yml diff --git a/roles/mailserver_preperation/handlers/main.yml b/roles/mailserver_preperation/handlers/main.yml new file mode 100644 index 0000000..eace201 --- /dev/null +++ b/roles/mailserver_preperation/handlers/main.yml @@ -0,0 +1,16 @@ +--- +- name: import mail database config + become: true + community.mysql.mysql_db: + name: vmail + encoding: 'utf8' + state: import + target: '/root/.mariadb_schema/config.sql' + +- name: create database schema + become: true + community.mysql.mysql_db: + name: vmail + encoding: 'utf8' + state: import + target: '/root/.mariadb_schema/schema.sql' diff --git a/roles/mailserver_preperation/tasks/hosts.yml b/roles/mailserver_preperation/tasks/hosts.yml index 220beee..31ba00c 100644 --- a/roles/mailserver_preperation/tasks/hosts.yml +++ b/roles/mailserver_preperation/tasks/hosts.yml @@ -17,6 +17,7 @@ copy: dest: "/etc/mailname" content: "{{ mailserver_domain }}" + mode: '0644' - name: set own dns resolver become: true diff --git a/roles/mailserver_preperation/tasks/mariadb.yml b/roles/mailserver_preperation/tasks/mariadb.yml index a9dc323..965c5a0 100644 --- a/roles/mailserver_preperation/tasks/mariadb.yml +++ b/roles/mailserver_preperation/tasks/mariadb.yml @@ -13,29 +13,13 @@ copy: src: files/schema.sql dest: /root/.mariadb_schema/schema.sql - register: mysqlschema + mode: '0644' + notify: create database schema - name: Copy mail config become: true template: src: templates/mysqlconfig.sql.j2 dest: /root/.mariadb_schema/config.sql - register: mysqlconfig - -- name: create database schema - become: true - community.mysql.mysql_db: - name: vmail - encoding: 'utf8' - state: import - target: '/root/.mariadb_schema/schema.sql' - when: mysqlschema.changed - -- name: Import database schema - become: true - community.mysql.mysql_db: - name: vmail - encoding: 'utf8' - state: import - target: '/root/.mariadb_schema/config.sql' - when: mysqlconfig.changed + mode: '0644' + notify: import mail database config diff --git a/roles/mailserver_preperation/vars/main.yml b/roles/mailserver_preperation/vars/main.yml index aa39641..374e931 100644 --- a/roles/mailserver_preperation/vars/main.yml +++ b/roles/mailserver_preperation/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 33 # should be int +playbook_version_number: 34 # should be int playbook_version_path: 'role-mailserver_roles-ansile_github.com.version'