Confusion on deploy

I seem to be missing a step in the deploy process. I get as far as deploy : WordPress Installed? and it fails. I’ve seen conflicting information in the forum regarding the installation of WP on the staging server. I can see I have everything but the web directory in src/www/staging.example.com

I’ve googled and searched as far as I can go. Any insight/tips on what I’m missing greatly appreciated.

What’s the error message?

Trellis doesn’t install WordPress on remote servers. But the deploy shouldn’t fail because of that.

The full message

TASK [deploy : WordPress Installed?] *******************************************
fatal: [XXX.XXX.XX.XXX]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed"], "delta": "0:00:00.268589", "end": "2016-02-01 17:29:50.279160", "failed": true, "failed_when_result": true, "rc": 1, "start": "2016-02-01 17:29:50.010571", "stderr": "WordPress database error Table 'chapel_dev.wp_blogs' doesn't exist for query SELECT * FROM wp_blogs WHERE domain = 'chapel.thedevyard.com' AND path = '/' made by include('phar:///usr/bin/wp/php/boot-phar.php'), include('phar:///usr/bin/wp/php/wp-cli.php'), WP_CLI\\Runner->start, WP_CLI\\Runner->load_wordpress, require('phar:///usr/bin/wp/php/wp-settings-cli.php'), require('wp-includes/ms-settings.php'), get_site_by_path\nWordPress database error Table 'chapel_dev.wp_sitemeta' doesn't exist for query SELECT meta_value FROM wp_sitemeta WHERE meta_key = 'site_name' AND site_id = 1 made by include('phar:///usr/bin/wp/php/boot-phar.php'), include('phar:///usr/bin/wp/php/wp-cli.php'), WP_CLI\\Runner->start, WP_CLI\\Runner->load_wordpress, require('phar:///usr/bin/wp/php/wp-settings-cli.php'), require('wp-includes/ms-settings.php'), WP_Network->__construct, WP_Network->_set_site_name, get_network_option\nWordPress database error Table 'chapel_dev.wp_sitemeta' doesn't exist for query SELECT meta_value FROM wp_sitemeta WHERE meta_key = 'siteurl' AND site_id = 1 made by include('phar:///usr/bin/wp/php/boot-phar.php'), include('phar:///usr/bin/wp/php/wp-cli.php'), WP_CLI\\Runner->start, WP_CLI\\Runner->load_wordpress, require('phar:///usr/bin/wp/php/wp-settings-cli.php'), wp_cookie_constants, get_site_option, get_network_option", "stdout": "", "stdout_lines": [], "warnings": []}

Aside from that, I’m confused about the “doesn’t install WordPress on remote servers.” Does that mean I need to create web directory and install there?

I had seen in the forums a suggestion to use
- if ! wp core is-installed; then wp core install --url="{{ project.env.wp_home }}" --title="{{project.site_title }}" --admin_user="{{ project.admin_user }}" --admin_password="{{ project.admin_password }}" --admin_email="{{ project.admin_email }}"; fi

in role/deploy/defaults/main.yml file, but that doesn’t seem to do anything.

EDIT Looking closer, I don’t have either the trellis or site folder. Do I need to install all of that on the server somehow? Must admit, the documentation on this part seems sparse.

I think you’re confusing the terms deploying and installing. Deploying a project basically means getting the code onto the server. Installing WordPress means creating a database and running their installer.

The workflow for a brand new server is:

  1. Provision server with server.yml
  2. Deploy site with ./deploy.sh
  3. Install WordPress (however you want, just hit the URL to do it manually)
  4. Keep deploying as usual

Now all that being said, you’re just running into an error which has nothing to do with this. That “WordPress Installed?” shouldn’t fail like that. I’m guessing there’s some mis-configuration here. Is this a WP multisite or no?

And no, trellis or site should not appear on the server. If you have repo_subtree_path set correctly then it just takes that sub-folder: https://github.com/roots/trellis/blob/11516d12e42355d0304eb4fb8c15be7ca8fcf6d4/group_vars/production/wordpress_sites.yml#L9

I guess I am. When I think of “deploy” from a git repo, I’m assuming all of the code is copied to the server, which in this case, it’s not?

To the question of whether this is a multi-site, yes. Everything works locally, but I will check the wordpress_sites.yml files to compare.

I appreciate your help in walking me through this.

Database is not code

that’s helpful :hushed:

Looks like you may have run into a bug with multisite (won’t be the first or last :frowning:)

Here’s the failing task: https://github.com/roots/trellis/blob/11516d12e42355d0304eb4fb8c15be7ca8fcf6d4/roles/deploy/hooks/finalize-after.yml#L2-L8

Looks like multisite requires a --network option from WP-CLI. (See http://wp-cli.org/commands/core/is-installed/)

You can try manually adding it for now to see if it fixes the problem.

OK, I changed it to command: wp core is-installed --network in finalize-after.yml

Error:

fatal: [162.243.70.107]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed", "--network"], "delta": "0:00:00.242924", "end": "2016-02-01 19:22:40.956159", "failed": true, "failed_when_result": true, "rc": 1, "start": "2016-02-01 19:22:40.713235", "stderr": "Error: Can’t select database", "stdout": "", "stdout_lines": [], "warnings": []}

I think you also need the --url option for multisite:

–url= Pretend request came from given URL. In multisite, this argument is how the target site is specified.

So you can just try the first/main site URL.

So at this point, I’ve gotten past the previous issues, but now am hanging up with the domain_current_site: getting “site not found”.

I am using the example project as a template, using a subdomain, and have tried every variation of my staging.roots-example-project.com in the domain_current_site:. i.e., http://staging.roots-example-project.com, staging.roots-example-project.com, roots-example-project.com

Is this an issue with trying to do a multisite on a subdomain?

EDIT: full error message

TASK [deploy : Update WP theme paths] ******************************************
fatal: [XXX.XXX.XX.XXX]: FAILED! => {"changed": true, "cmd": ["wp", "eval", "wp_clean_themes_cache(); switch_theme(get_stylesheet());"], "delta": "0:00:00.097746", "end": "2016-02-01 21:16:01.744476", "failed": true, "rc": 1, "start": "2016-02-01 21:16:01.646730", "stderr": "Error: Site example.com/ not found.", "stdout": "", "stdout_lines": [], "warnings": []}

Just a follow up, in case some one has any insight.

I commented out that particular part of roles/deploy/hooks/finalize-after.yml but got the same error when trying trying to update the db in a multisite instance.

I ultimately went about testing if I could deploy a non-multisite instance without using a subdomain and was successful.

So somewhere along the line, I’m getting that Error: Site example.com/ not found when trying to update the database in multisite. I did see a suggestion to add the url to the wp-cli.yml file but not sure how that would affect local dev, or if it would do anything. I did try adding --url=example.com to wp core update-db --network to no avail.

Pretty stumped, but appreciate the responses thus far.

I run into the same bug on the production server with multisite/subdomain setting. Ansible fails at the task Wordpress installed?. This is strange, because the task works without any problems on the development virtual machine. So as already mentioned by @miklb it doesn’t fail because of a missing argument, like --network or --url.

I tried to run the command manually on the server with the --debug flag, but it failed:

root@example:/srv/www/example.com/current# wp core --debug is-installed --allow-root
Debug: No readable global config found (0.008s)
Debug: Using project config: /srv/www/example.com/releases/20160205091556/wp-cli.yml (0.008s)
Debug: ABSPATH defined: /srv/www/example.com/releases/20160205091556/web/wp/ (0.025s)
Debug: Begin WordPress load (0.026s)
Debug: wp-config.php path: /srv/www/example.com/releases/20160205091556/web/wp-config.php (0.026s)
Debug: Set URL: example.com/ (0.028s)
WordPress database error Table 'div_prod.wp_blogs' doesn't exist for query SELECT * FROM wp_blogs WHERE domain = 'example.de' AND path = '/' made by include('phar:///usr/bin/wp/php/boot-phar.php'), include('phar:///usr/bin/wp/php/wp-cli.php'), WP_CLI\Runner->start, WP_CLI\Runner->load_wordpress, require('phar:///usr/bin/wp/php/wp-settings-cli.php'), require('wp-includes/ms-settings.php'), get_site_by_path
PHP Notice:  Undefined property: stdClass::$public in /srv/www/example.com/releases/20160205091556/web/wp/wp-includes/ms-settings.php on line 199
Notice: Undefined property: stdClass::$public in /srv/www/example.com/releases/20160205091556/web/wp/wp-includes/ms-settings.php on line 199
WordPress database error Table 'div_prod.wp_sitemeta' doesn't exist for query SELECT meta_value FROM wp_sitemeta WHERE meta_key = 'site_name' AND site_id = 1 made by include('phar:///usr/bin/wp/php/boot-phar.php'), include('phar:///usr/bin/wp/php/wp-cli.php'), WP_CLI\Runner->start, WP_CLI\Runner->load_wordpress, require('phar:///usr/bin/wp/php/wp-settings-cli.php'), require('wp-includes/ms-settings.php'), WP_Network->__construct, WP_Network->_set_site_name, get_network_option
WordPress database error Table 'div_prod.wp_sitemeta' doesn't exist for query SELECT meta_value FROM wp_sitemeta WHERE meta_key = 'siteurl' AND site_id = 1 made by include('phar:///usr/bin/wp/php/boot-phar.php'), include('phar:///usr/bin/wp/php/wp-cli.php'), WP_CLI\Runner->start, WP_CLI\Runner->load_wordpress, require('phar:///usr/bin/wp/php/wp-settings-cli.php'), wp_cookie_constants, get_site_option, get_network_option
Debug: Loaded WordPress (0.218s)
Debug: Running command: core is-installed (0.219s)

I checked for any known bugs on wp-cli, but haven’t found any reports. I also updated wp-cli to the latest version without any luck. @swalkinshaw do you have any suggestions where to start debugging?

Edit:
I added a bug report with a temporary workaround https://github.com/roots/trellis/issues/482.

For more context from my end, the exact same local installation deploys just fine if I do not enable multisite.

I was able to resolve this by looking for instances of my old url in the database sql dump and changing it with my new desired production url.