Roots Discourse

Using separate DB

Hey,

I’ve just started using Trellis and am trying to separate the application and database.

I’ve setup a Digital Ocean droplet and database cluster (running postgresql 11) on DO as well.

All I have changed really is the following:

In trellis/group_vars/all.yml:

wordpress_env_defaults:
  db_name: defaultdb
  db_host: staging-<redacted>.db.ondigitalocean.com
  db_user: <redacted>
  db_user_host: staging-<redacted>.db.ondigitalocean.com

db_create: false

Added the db_password in trellis/group_vars/vault.yml

Also updated the hosts/staging to:

[staging]
<ip>

[web]
<same-ip as above>

[db]
staging-<redacted>.db.ondigitalocean.com

I can successfully run ansible-playbook server.yml -e env=staging

However running ansible-playbook deploy.yml -e "site=staging.<redacted>.dev env=staging", I get the following error:

TASK [deploy : WordPress Installed?] *************************************************************************************
System info:
  Ansible 2.7.11; Darwin
  Trellis 1.0.3: April 30th, 2019
---------------------------------------------------
non-zero return code
Error: Error establishing a database connection. This either means that the
username and password information in your `wp-config.php` file is incorrect
or we can’t contact the database server at `localhost`. This could mean your
host’s database server is down.
fatal: [139.59.203.232]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed", "--skip-plugins", "--skip-themes", "--require=/srv/www/staging.<redacted>.dev/shared/tmp_multisite_constants.php"], "delta": "0:00:00.182033", "end": "2019-07-03 10:43:41.889800", "failed_when_result": true, "rc": 1, "start": "2019-07-03 10:43:41.707767", "stderr_lines": ["Error: Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is incorrect or we can’t contact the database server at `localhost`. This could mean your host’s database server is down."], "stdout": "", "stdout_lines": []}

I can successfully connect to the postgresql database using pgAdmin.

Any ideas what configuration I am missing? (maybe the db_port?)

Thanks!

Similar to Separating the database from the application

Unless I’ve missed something in your setup, you’ll need to use MySQL as opposed to PostgreSQL with WordPress.

This topic was automatically closed after 42 days. New replies are no longer allowed.