diff --git a/tasks/mysql.yml b/tasks/mysql.yml index 2409ba49cfd8baf2ef0a613d5165458668ec3c76..4bcdd418131e7d1cf426e829f332c180412f5cc8 100644 --- a/tasks/mysql.yml +++ b/tasks/mysql.yml @@ -4,6 +4,8 @@ - set_fact: db='{{ drupal_domain.db }}' extra={{ drupal_domain.db.extra|default([]) }} + external={{ drupal_domain.db.external|default([]) }} + external_hosts={{ drupal_domain.db.external_hosts|default([]) }} tags: always - name: "Ensure Database" @@ -60,3 +62,20 @@ - ['localhost', '127.0.0.1', '::1'] when: item.0.username is defined and item.0.username != 'root' ignore_errors: true + +- name: "Create external MySQL Users" + mysql_user: + user='{{ item.0.username|default("root") }}' + password='{{ item.0.password|default(mysql_root_password|default("root")) }}' + host='{{ item.1 }}' + check_implicit_admin=yes + priv='{{ item.0.priv }}' + login_user='root' + login_password='{{ mysql_root_password|default("root") }}' + login_host='127.0.0.1' + login_port='{{ item.0.port|default('3306') }}' + with_nested: + - '{{ external }}' + - '{{ external_hosts }}' + when: item.0.username is defined and item.0.username != 'root' + ignore_errors: true