Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit b4baa60

Browse files
committed
Merge branch '146-postgres'
2 parents c40e805 + 68316e0 commit b4baa60

39 files changed

+748
-18
lines changed

.travis.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,28 @@ env:
1111
IP: 192.168.88.88
1212
DRUPALVM_DIR: /var/www/drupalvm
1313
matrix:
14-
- distro: ubuntu1604
14+
# Defaults - Ubuntu 16.04.
15+
- type: defaults
16+
distro: ubuntu1604
1517
init: /sbin/init
1618
run_opts: "--privileged"
17-
- distro: ubuntu1604
19+
# Nginx and Drush make file test - Ubuntu 16.04.
20+
- type: nginx-drush-make
21+
distro: ubuntu1604
1822
init: /sbin/init
1923
run_opts: "--privileged"
2024
local_config: tests/ubuntu-16-nginx.config.yml
2125
config_dir: /var/www/drupalvm/config
22-
- distro: centos7
26+
# PostgreSQL - Ubuntu 16.04.
27+
- type: postgresql
28+
distro: ubuntu1604
29+
init: /sbin/init
30+
run_opts: "--privileged"
31+
local_config: tests/ubuntu-16-postgresql.config.yml
32+
config_dir: /var/www/drupalvm/config
33+
# Defaults - CentOS 7.
34+
- type: centos
35+
distro: centos7
2336
init: /usr/lib/systemd/systemd
2437
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
2538

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It will install the following on an Ubuntu 16.04 (by default) linux VM:
1010

1111
- Apache 2.4.x (or Nginx 1.x)
1212
- PHP 7.0.x (configurable)
13-
- MySQL 5.7.x
13+
- MySQL 5.7.x (or PostgreSQL 9.x)
1414
- Drush (configurable)
1515
- Drupal 7.x, or 8.x.x (configurable)
1616
- Optional:

default.config.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ force_ansible_local: false
4242
# The web server software to use. Can be either 'apache' or 'nginx'.
4343
drupalvm_webserver: apache
4444

45+
# The database system to use. Can be either 'mysql' or 'pgsql'.
46+
drupalvm_database: mysql
47+
4548
# Set this to 'false' if you are using a different site deployment strategy and
4649
# would like to configure 'vagrant_synced_folders' and 'apache_vhosts' manually.
4750
build_makefile: false
@@ -68,9 +71,9 @@ install_site: true
6871

6972
# Required Drupal settings.
7073
drupal_core_path: "{{ drupal_composer_install_dir }}/web"
71-
drupal_mysql_user: drupal
72-
drupal_mysql_password: drupal
73-
drupal_mysql_database: drupal
74+
drupal_db_user: drupal
75+
drupal_db_password: drupal
76+
drupal_db_name: drupal
7477

7578
# Settings for installing a Drupal site if 'install_site:' is 'true'.
7679
drupal_major_version: 8
@@ -161,18 +164,27 @@ nginx_hosts:
161164
nginx_remove_default_vhost: true
162165
nginx_ppa_use: true
163166

164-
# MySQL Databases and users. If 'install_site' is 'true', first database will
165-
# be used for the site.
167+
# MySQL databases and users.
166168
mysql_databases:
167-
- name: "{{ drupal_mysql_database }}"
169+
- name: "{{ drupal_db_name }}"
168170
encoding: utf8mb4
169171
collation: utf8mb4_general_ci
170172

171173
mysql_users:
172-
- name: "{{ drupal_mysql_user }}"
174+
- name: "{{ drupal_db_user }}"
173175
host: "%"
174-
password: "{{ drupal_mysql_password }}"
175-
priv: "{{ drupal_mysql_database }}.*:ALL"
176+
password: "{{ drupal_db_password }}"
177+
priv: "{{ drupal_db_name }}.*:ALL"
178+
179+
# PostgreSQL databases and users.
180+
postgresql_databases:
181+
- name: "{{ drupal_db_name }}"
182+
183+
postgresql_users:
184+
- name: "{{ drupal_db_user }}"
185+
password: "{{ drupal_db_password }}"
186+
db: "{{ drupal_db_name }}"
187+
priv: "ALL"
176188

177189
# Comment out any extra utilities you don't want to install. If you don't want
178190
# to install *any* extras, set this value to an empty set, e.g. `[]`.

docs/extras/postgresql.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Since Drupal VM is built in a modular fashion, you can swap out the database engine and use [PostgreSQL](https://www.postgresql.org/) instead of MySQL (as long as the version of Drupal you're using supports it!).
2+
3+
To switch from MySQL to PostgreSQL, switch the `drupalvm_database` setting in your local `config.yml` to `pgsql`:
4+
5+
```yaml
6+
drupalvm_database: mysql
7+
```
8+
9+
For more PostgreSQL configuration options, see the README included with the [`geerlingguy.postgresql](https://galaxy.ansible.com/geerlingguy/postgresql/) Ansible role.

examples/prod/prod.config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ apache_vhosts:
1313
# Since this will be a publicly-accessible instance of Drupal VM, make sure you
1414
# configure secure passwords, especially for Drupal and MySQL!
1515
drupal_account_pass: admin
16-
drupal_mysql_password: drupal
16+
drupal_db_password: drupal
1717
mysql_root_password: root
1818

1919
# Only install extras that you will need/use on your site, and don't install

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pages:
2323
- 'Use Drupal Console with Drupal VM': 'extras/drupal-console.md'
2424
- 'Use Varnish with Drupal VM': 'extras/varnish.md'
2525
- 'Use MariaDB instead of MySQL': 'extras/mariadb.md'
26+
- 'Use PostgreSQL instead of MySQL': 'extras/postgresql.md'
2627
- 'Use Node.js and NPM': 'extras/nodejs.md'
2728
- 'Use SSL vhosts with Apache': 'extras/ssl.md'
2829
- 'View Logs with Pimp my Log': 'extras/pimpmylog.md'

provisioning/playbook.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@
5151
- { role: geerlingguy.apache, when: drupalvm_webserver == 'apache' }
5252
- { role: geerlingguy.apache-php-fpm, when: drupalvm_webserver == 'apache' }
5353
- { role: geerlingguy.nginx, when: drupalvm_webserver == 'nginx' }
54-
- geerlingguy.mysql
5554
- geerlingguy.php
5655
- geerlingguy.php-pecl
57-
- geerlingguy.php-mysql
5856
- geerlingguy.composer
5957
- geerlingguy.drush
58+
- { role: geerlingguy.mysql, when: drupalvm_database == 'mysql' }
59+
- { role: geerlingguy.php-mysql, when: drupalvm_database == 'mysql' }
60+
- { role: geerlingguy.postgresql, when: drupalvm_database == 'pgsql' }
61+
- { role: geerlingguy.php-pgsql, when: drupalvm_database == 'pgsql' }
6062

6163
# Conditionally-installed roles.
6264
- { role: geerlingguy.drupal-console, when: 'drupal_major_version > 7 and "drupalconsole" in installed_extras' }
@@ -97,7 +99,7 @@
9799
- include: tasks/extras.yml
98100
- include: tasks/www.yml
99101
- include: tasks/apparmor.yml
100-
when: ansible_os_family == 'Debian'
102+
when: ansible_os_family == 'Debian' and drupalvm_database == 'mysql'
101103

102104
# Build makefile if configured.
103105
- include: tasks/build-makefile.yml

provisioning/requirements.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
version: 2.0.1
4646
- src: geerlingguy.php-pecl
4747
version: 1.2.1
48+
- src: geerlingguy.php-pgsql
49+
version: 1.0.0
4850
- src: geerlingguy.php-redis
4951
version: 3.0.0
5052
- src: geerlingguy.php-xdebug
@@ -55,6 +57,8 @@
5557
version: 1.0.2
5658
- src: geerlingguy.postfix
5759
version: 1.1.0
60+
- src: geerlingguy.postgresql
61+
version: 1.0.1
5862
- src: geerlingguy.redis
5963
version: 1.2.0
6064
- src: geerlingguy.repo-remi
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
services: docker
3+
4+
env:
5+
- distro: centos7
6+
init: /usr/lib/systemd/systemd
7+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
8+
- distro: ubuntu1604
9+
init: /lib/systemd/systemd
10+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
11+
12+
before_install:
13+
# Pull container.
14+
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
15+
16+
script:
17+
- container_id=$(mktemp)
18+
# Run container in detached state.
19+
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
20+
21+
# Install dependencies.
22+
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
23+
24+
# Ansible syntax check.
25+
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
26+
27+
# Test role.
28+
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
29+
30+
# Test role idempotence.
31+
- idempotence=$(mktemp)
32+
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
33+
- >
34+
tail ${idempotence}
35+
| grep -q 'changed=0.*failed=0'
36+
&& (echo 'Idempotence test: pass' && exit 0)
37+
|| (echo 'Idempotence test: fail' && exit 1)
38+
39+
# Ensure PHP PostgreSQL support is enabled.
40+
- docker exec --tty "$(cat ${container_id})" env TERM=xterm php -i | grep 'PostgreSQL Support => enabled'
41+
42+
after_failure:
43+
- docker exec --tty "$(cat ${container_id})" env TERM=xterm php -i
44+
45+
notifications:
46+
webhooks: https://galaxy.ansible.com/api/v1/notifications/
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Ansible Role: PHP-PostgreSQL
2+
3+
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-php-pgsql.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-php-pgsql)
4+
5+
Installs PHP [PostgreSQL](https://www.postgresql.org/) support on Linux.
6+
7+
## Requirements
8+
9+
None.
10+
11+
## Role Variables
12+
13+
Available variables are listed below, along with default values (see `defaults/main.yml`):
14+
15+
php_enablerepo: ""
16+
17+
(RedHat/CentOS only) If you have enabled any additional repositories (might I suggest geerlingguy.repo-epel or geerlingguy.repo-remi), those repositories can be listed under this variable (e.g. `remi,epel`). This can allow you to install later versions of PHP packages.
18+
19+
php_pgsql_package: php-pgsql # RedHat
20+
php_pgsql_package: php7.0-pgsql # Debian
21+
22+
The PHP PostgreSQL package to install via apt/yum. This should only be overridden if you need to install a unique/special package for PostgreSQL support, as in the case of using software collections on Enterprise Linux.
23+
24+
## Dependencies
25+
26+
- geerlingguy.php
27+
28+
## Example Playbook
29+
30+
- hosts: webservers
31+
roles:
32+
- geerlingguy.postgresql
33+
- geerlingguy.php
34+
- geerlingguy.php-pgsql
35+
36+
## License
37+
38+
MIT / BSD
39+
40+
## Author Information
41+
42+
This role was created in 2016 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).

0 commit comments

Comments
 (0)