Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ env:
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
additional_vars: "centos-7-vars.yml"
- distribution: ubuntu
version: 14.04
init: /sbin/init
run_opts: "--privileged"
additional_vars: ubuntu-14-postgresql.yml

services:
- docker
Expand Down Expand Up @@ -109,5 +114,8 @@ script:
&& (echo 'Drush install pass' && exit 0)
|| (echo 'Drush install fail' && exit 1)

# Debug
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm drush @${MACHINE_NAME}.${HOSTNAME} status'

# Clean up
- 'sudo docker stop "$(cat ${container_id})"'
28 changes: 0 additions & 28 deletions docs/extras/mariadb.md

This file was deleted.

97 changes: 97 additions & 0 deletions docs/other/database-engines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
By default Drupal VM uses the package managers version of MySQL. If you're using RedHat 7 or CentOS 7 there is no MySQL package available and you need to use MariaDB instead.

## Using MySQL

This is the default setup for Drupal VM but for reference you need the following configuration in your `config.yml`

```yaml
# The database engine to use. Can be either 'mysql' or 'pgsql'.
drupal_database_engine: mysql

# MySQL Databases and users. If build_makefile: is true, first database will
# be used for the makefile-built site.
mysql_databases:
- name: "{{ drupal_database_name }}"
encoding: utf8
collation: utf8_general_ci

mysql_users:
- name: "{{ drupal_database_user }}"
host: "%"
password: "{{ drupal_database_password }}"
priv: "{{ drupal_database_name }}.*:ALL"

installed_extras:
- ...
- mysql
```

## Using MariaDB

Since Drupal VM is built in a modular fashion, and the upstream Ansible Role that installs and configures MySQL is built in a way that works with any MySQL-compatible replacement, you can easily swap out MySQL for MariaDB.

The simplest way is to add the following lines after the `# MySQL Configuration.` line in `config.yml`:

```yaml
mysql_packages:
- mariadb-client
- mariadb-server
- python-mysqldb
```

This set of packages works out of the box with the default Ubuntu 14.04 installation that comes with Drupal VM.

Alternatively, if you want to use RedHat 7 or CentOS 7 instead of Ubuntu, you can set the following variables to install and configure MariaDB instead of MySQL:

```yaml
mysql_packages:
- mariadb
- mariadb-server
- mariadb-libs
- MySQL-python
- perl-DBD-MySQL
mysql_daemon: mariadb
mysql_socket: /var/lib/mysql/mysql.sock
mysql_log_error: /var/log/mariadb/mariadb.log
mysql_syslog_tag: mariadb
mysql_pid_file: /var/run/mariadb/mariadb.pid
```

The configurations are the same as for MySQL and you can find out more options in the [`geerlingguy.mysql` Ansible role's README](https://github.com/geerlingguy/ansible-role-mysql#readme).

## Using PostgreSQL

If you prefer to use PostgreSQL instead of MySQL/MariaDB you can install it by changing the `drupal_database_engine` variable to `pgsql`:

```yaml
drupal_database_engine: pgsql
```

And adding `pgsql` to `installed_extras` list:

```yaml
installed_extras:
- ...
- pgsql
```

To create the drupal database and the database user also add this to your `config.yml`:

```yaml
# PostgreSQL
postgresql_databases:
- name: "{{ drupal_database_name }}"
owner: "{{ drupal_database_user }}"

postgresql_users:
- name: "{{ drupal_database_user }}"
pass: "{{ drupal_database_password }}"
encrypted: no

postgresql_user_privileges:
- name: "{{ drupal_database_user }}"
db: "{{ drupal_database_user }}"
priv: "ALL"
```

For more configuration options see the [`ANXS.postgresql` Ansible role's README](https://github.com/ANXS/postgresql#readme).
17 changes: 10 additions & 7 deletions example.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ drupal_install_profile: standard
drupal_enable_modules: [ 'devel' ]
drupal_account_name: admin
drupal_account_pass: admin
drupal_mysql_user: drupal
drupal_mysql_password: drupal
drupal_mysql_database: drupal
drupal_database_user: drupal
drupal_database_password: drupal
drupal_database_name: drupal
drupal_database_engine: mysql

# Additional arguments or options to pass to `drush site-install`.
drupal_site_install_extra_args: []
Expand Down Expand Up @@ -137,15 +138,15 @@ nginx_remove_default_vhost: true
# MySQL Databases and users. If build_makefile: is true, first database will
# be used for the makefile-built site.
mysql_databases:
- name: "{{ drupal_mysql_database }}"
- name: "{{ drupal_database_name }}"
encoding: utf8
collation: utf8_general_ci

mysql_users:
- name: "{{ drupal_mysql_user }}"
- name: "{{ drupal_database_user }}"
host: "%"
password: "{{ drupal_mysql_password }}"
priv: "{{ drupal_mysql_database }}.*:ALL"
password: "{{ drupal_database_password }}"
priv: "{{ drupal_database_name }}.*:ALL"

# Comment out any extra utilities you don't want to install. If you don't want
# to install *any* extras, make set this value to an empty set, e.g. `[]`.
Expand All @@ -154,7 +155,9 @@ installed_extras:
- drupalconsole
- mailhog
- memcached
- mysql
# - nodejs
# - pgsql
- pimpmylog
# - redis
# - ruby
Expand Down
2 changes: 1 addition & 1 deletion examples/prod/prod.overrides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apache_vhosts:
# Since this will be a publicly-accessible instance of Drupal VM, make sure you
# configure secure passwords, especially for Drupal and MySQL!
drupal_account_pass: admin
drupal_mysql_password: drupal
drupal_database_password: drupal
mysql_root_password: root

# Only install extras that you will need/use on your site, and don't install
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pages:
- 'Use Drush with Drupal VM': 'extras/drush.md'
- 'Use Drupal Console with Drupal VM': 'extras/drupal-console.md'
- 'Use Varnish with Drupal VM': 'extras/varnish.md'
- 'Use MariaDB instead of MySQL': 'extras/mariadb.md'
- 'Use Node.js and NPM': 'extras/nodejs.md'
- 'Use SSL vhosts with Apache': 'extras/ssl.md'
- 'View Logs with Pimp my Log': 'extras/pimpmylog.md'
Expand All @@ -33,6 +32,7 @@ pages:
- Other Information:
- 'Using Different Base OSes': 'other/base-os.md'
- 'Using Different Webservers': 'other/webservers.md'
- 'Using Different Database Engines': 'other/database-engines.md'
- 'Using a local Vagrantfile': 'other/local-vagrantfile.md'
- 'PHP 7 on Drupal VM': 'other/php-7.md'
- 'Drupal VM Management Tools': 'other/management-tools.md'
Expand Down
5 changes: 3 additions & 2 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
- { role: geerlingguy.apache, when: drupalvm_webserver == 'apache' }
- { role: geerlingguy.apache-php-fpm, when: drupalvm_webserver == 'apache' }
- { role: geerlingguy.nginx, when: drupalvm_webserver == 'nginx' }
- geerlingguy.mysql
- geerlingguy.php
- geerlingguy.php-pecl
- geerlingguy.php-mysql
- { role: geerlingguy.mysql, when: '"mysql" in installed_extras or drupal_database_engine == "mysql"' }
- { role: geerlingguy.php-mysql, when: '"mysql" in installed_extras or drupal_database_engine == "mysql"' }
- { role: ANXS.postgresql, when: '"pgsql" in installed_extras or drupal_database_engine == "pgsql"' }
- geerlingguy.composer
- geerlingguy.drush

Expand Down
1 change: 1 addition & 0 deletions provisioning/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- src: ANXS.postgresql
- src: arknoll.selenium
- src: geerlingguy.adminer
- src: geerlingguy.apache
Expand Down
2 changes: 1 addition & 1 deletion provisioning/tasks/apparmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
src: /etc/apparmor.d/usr.sbin.mysqld
state: link
register: mysql_apparmor
when: mysql_slow_query_log_enabled and apparmor_installed.stat.exists
when: mysql_slow_query_log_enabled and apparmor_installed.stat.exists and "mysql" in installed_extras

- name: Restart the AppArmor if necessary.
service: name=apparmor state=restarted
Expand Down
4 changes: 4 additions & 0 deletions provisioning/tasks/init-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@
set_fact:
php_xhprof_html_dir: "/usr/share/php/xhprof_html"
when: php_xhprof_html_dir is not defined

- name: Install PHP PostgreSQL dependencies.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'd like to follow the pattern of setting this up in a separate role. Will try to get to that soon.

apt: name=php5-pgsql state=installed
when: "'pgsql' in installed_extras or drupal_database_engine == 'pgsql'"
4 changes: 4 additions & 0 deletions provisioning/tasks/init-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@
set_fact:
php_xhprof_html_dir: "/usr/share/pear/xhprof_html"
when: php_xhprof_html_dir is not defined

- name: Install PHP PostgreSQL dependencies.
yum: name=php-pgsql state=installed
when: "'pgsql' in installed_extras or drupal_database_engine == 'pgsql'"
2 changes: 1 addition & 1 deletion provisioning/tasks/install-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
--site-name="{{ drupal_site_name }}"
--account-name={{ drupal_account_name }}
--account-pass={{ drupal_account_pass }}
--db-url=mysql://{{ drupal_mysql_user }}:{{ drupal_mysql_password }}@localhost/{{ mysql_databases[0].name }}
--db-url={{ drupal_database_engine }}://{{ drupal_database_user }}:{{ drupal_database_password }}@localhost/{{ drupal_database_name }}
{{ drupal_site_install_extra_args | default([]) | join(" ") }}
chdir={{ drupal_core_path }}
notify: restart webserver
Expand Down
Loading