Browse Source

Make opendmarc database setup more robust

Instead of registering a handler to run when the database is created,
register a variable and check it immediately to run the schema import.
This avoids a problem where an error between database creation and
schema import 1) leaves the server in a broken state, and 2) rerunning
the playbook doesn't fix it.
Mike Ashley 8 years ago
parent
commit
06f6b62e58
2 changed files with 5 additions and 4 deletions
  1. 0
    3
      roles/mailserver/handlers/main.yml
  2. 5
    1
      roles/mailserver/tasks/opendmarc.yml

+ 0
- 3
roles/mailserver/handlers/main.yml View File

@@ -19,6 +19,3 @@
19 19
 
20 20
 - name: restart rspamd
21 21
   service: name=rspamd state=restarted
22
-
23
-- name: import opendmarc schema
24
-  mysql_db: name={{ mail_db_opendmarc_database }} state=import target=/usr/share/doc/opendmarc/schema.mysql

+ 5
- 1
roles/mailserver/tasks/opendmarc.yml View File

@@ -39,7 +39,11 @@
39 39
 
40 40
 - name: Create database for OpenDMARC reports
41 41
   mysql_db: name={{ mail_db_opendmarc_database }} state=present
42
-  notify: import opendmarc schema
42
+  register: db_created
43
+
44
+- name: Import opendmarc schema
45
+  mysql_db: name={{ mail_db_opendmarc_database }} state=import target=/usr/share/doc/opendmarc/schema.mysql
46
+  when: db_created.changed
43 47
 
44 48
 - name: Copy nightly OpenDMARC report generation script into place
45 49
   template: src=etc_opendmarc_report.sh.j2 dest=/etc/opendmarc/report.sh owner=root group=root mode="755"

Loading…
Cancel
Save