Skip to content
Snippets Groups Projects
Commit 4dcb696e authored by jurgenhaas's avatar jurgenhaas
Browse files

#3 Use explicit credentials to create dbs and users

parent e9a0262e
No related branches found
No related tags found
No related merge requests found
......@@ -172,24 +172,5 @@
- crontabs
tags: 'cron'
- name: "Ensure Database"
mysql_db:
name='{{ item.db.name }}'
state='present'
with_items: '{{ drupal.domains }}'
- name: "Create MySQL User"
mysql_user:
user='{{ item.0.db.username }}'
password='{{ item.0.db.password|default(mysql_root_password|default("root")) }}'
host='{{ item.1 }}'
check_implicit_admin=yes
priv='{{ item.0.db.name }}.*:ALL'
with_nested:
- '{{ drupal.domains }}'
- ['localhost', '127.0.0.1', '::1', '{{ inventory_hostname }}']
when: item.0.db.username is defined and item.0.db.username != 'root'
notify: "MySQL | Restart MySQL"
- name: "Set Extended Permissions"
command: setfacl -dRm u:{{ apacheUser }}:rwX,g:{{ apacheUser }}:rwX,o::rX {{ webRoot }}/files
......@@ -19,7 +19,15 @@
when: '"letsencrypt" not in excluded_roles'
- name: "Install Drupal"
include: install.yml
with_items: '{{ drupal_settings }}'
- block:
- name: "Install Drupal"
include: install.yml
with_items: '{{ drupal_settings }}'
- name: "Install Drupal Databases and Users"
include: mysql.yml
with_subelements:
- '{{ drupal_settings }}'
- domains
when: '"drupal" not in excluded_roles and drupal_install_drupal'
---
# file: roles/drupal/tasks/mysql.yml
- block:
- set_fact: domain='{{ item.1 }}'
- set_fact: port='3306'
- set_fact: port='{{ hostvars[item.db.host|default(inventory_hostname)]["ssh_tunnel_ports"][0]["local"] }}'
when: hostvars[domain.db.host|default(inventory_hostname)]["ssh_tunnel_ports"] is defined
tags: always
- name: "Ensure Database"
mysql_db:
name='{{ domain.db.name }}'
login_user='root'
login_password='{{ mysql_root_password|default("root") }}'
login_host='127.0.0.1'
login_port='{{ port }}'
state='present'
- name: "Create MySQL User"
mysql_user:
user='{{ domain.db.username }}'
password='{{ domain.db.password|default(mysql_root_password|default("root")) }}'
host='{{ item }}'
check_implicit_admin=yes
priv='{{ domain.db.name }}.*:ALL'
login_user='root'
login_password='{{ mysql_root_password|default("root") }}'
login_host='127.0.0.1'
login_port='{{ port }}'
with_items:
- 'localhost'
- '127.0.0.1'
- '::1'
- '{{ inventory_hostname }}'
when: domain.db.username is defined and domain.db.username != 'root'
notify: "MySQL | Restart MySQL"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment