"Can't select database" Error when trying to run 2 sites with bedrock-ansible

I just tried setting up my development sites with the latest version of bedrock-ansible (ansible deploys) and am running into the following problem:

 _________________________________________
< TASK: wordpress-install | WP installed? >
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||


failed: [default] => (item={'key': 'ou-history.dev', 'value': {'site_install': True, 'admin_user': 'admin', 'local_path': '../ou-history.dev', 'system_cron': True, 'repo': 'git@g$
tlab.dev:aldenlibrary/ou-history.git', 'ssl': {'enabled': False}, 'multisite': {'enabled': False, 'subdomains': False}, 'site_title': 'OU History (Dev)', 'admin_password': 'admin$
, 'env': {'db_name': 'ouhistory', 'wp_env': 'development', 'db_user': 'devel_user', 'db_password': 'devel_pass', 'wp_home': 'http://ou-history.dev', 'wp_siteurl': 'http://ou-hist$
ry.dev/wp'}, 'site_hosts': ['ou-history.dev'], 'admin_email': 'ciarlill@ohio.edu'}}) => {"changed": true, "cmd": ["wp", "core", "is-installed", "--allow-root"], "delta": "0:00:00$
361342", "end": "2015-04-27 17:15:43.255098", "item": {"key": "ou-history.dev", "value": {"admin_email": "ciarlill@ohio.edu", "admin_password": "admin", "admin_user": "admin", "e$
v": {"db_name": "ouhistory", "db_password": "devel_pass", "db_user": "devel_user", "wp_env": "development", "wp_home": "http://ou-history.dev", "wp_siteurl": "http://ou-history.d$
v/wp"}, "local_path": "../ou-history.dev", "multisite": {"enabled": false, "subdomains": false}, "repo": "git@gitlab.dev:aldenlibrary/ou-history.git", "site_hosts": ["ou-history.$
ev"], "site_install": true, "site_title": "OU History (Dev)", "ssl": {"enabled": false}, "system_cron": true}}, "rc": 1, "start": "2015-04-27 17:15:42.893756", "warnings": []}
stderr: Error: Can’t select database
...ignoring
failed: [default] => (item={'key': 'main-site.dev', 'value': {'site_install': True, 'admin_user': 'admin', 'local_path': '../main-site.dev', 'system_cron': True, 'repo': 'git@git$
ab.dev:aldenlibrary/main-site.git', 'ssl': {'enabled': False}, 'multisite': {'enabled': False, 'subdomains': False}, 'site_title': 'OU Libraries (Dev)', 'admin_password': 'admin'$
 'env': {'db_name': 'mainsite', 'wp_env': 'development', 'db_user': 'devel_user', 'db_password': 'devel_pass', 'wp_home': 'http://main-site.dev', 'wp_siteurl': 'http://main-site.$
ev/wp'}, 'site_hosts': ['main-site.dev'], 'admin_email': 'ciarlill@ohio.edu'}}) => {"changed": true, "cmd": ["wp", "core", "is-installed", "--allow-root"], "delta": "0:00:01.0970$
7", "end": "2015-04-27 17:15:44.487901", "item": {"key": "main-site.dev", "value": {"admin_email": "ciarlill@ohio.edu", "admin_password": "admin", "admin_user": "admin", "env": {$
db_name": "mainsite", "db_password": "devel_pass", "db_user": "devel_user", "wp_env": "development", "wp_home": "http://main-site.dev", "wp_siteurl": "http://main-site.dev/wp"}, $
local_path": "../main-site.dev", "multisite": {"enabled": false, "subdomains": false}, "repo": "git@gitlab.dev:aldenlibrary/main-site.git", "site_hosts": ["main-site.dev"], "site$
install": true, "site_title": "OU Libraries (Dev)", "ssl": {"enabled": false}, "system_cron": true}}, "rc": 1, "start": "2015-04-27 17:15:43.390844", "warnings": []}
...ignoring

 ______________________________________
< TASK: wordpress-install | Install WP >
 --------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||


failed: [default] => (item={u'cmd': [u'wp', u'core', u'is-installed', u'--allow-root'], u'end': u'2015-04-27 17:15:43.255098', u'stderr': u'Error: Can\u2019t select database', u'$
tdout': u'', u'changed': True, u'rc': 1, 'item': {'value': {'site_install': True, 'admin_user': 'admin', 'local_path': '../ou-history.dev', 'system_cron': True, 'repo': 'git@gitl$
b.dev:aldenlibrary/ou-history.git', 'ssl': {'enabled': False}, 'multisite': {'enabled': False, 'subdomains': False}, 'site_title': 'OU History (Dev)', 'admin_password': 'admin', $
env': {'db_name': 'ouhistory', 'wp_env': 'development', 'db_user': 'devel_user', 'db_password': 'devel_pass', 'wp_home': 'http://ou-history.dev', 'wp_siteurl': 'http://ou-history$
dev/wp'}, 'site_hosts': ['ou-history.dev'], 'admin_email': 'ciarlill@ohio.edu'}, 'key': 'ou-history.dev'}, u'warnings': [], u'delta': u'0:00:00.361342', 'invocation': {'module_na$
e': u'command', 'module_args': u'wp core is-installed --allow-root'}, 'stdout_lines': [], u'start': u'2015-04-27 17:15:42.893756'}) => {"changed": true, "cmd": ["wp", "core", "in$
tall", "--allow-root", "--url=http://ou-history.dev", "--title=OU History (Dev)", "--admin_user=admin", "--admin_password=admin", "--admin_email=ciarlill@ohio.edu"], "delta": "0:$
0:00.108328", "end": "2015-04-27 17:15:44.788034", "item": {"changed": true, "cmd": ["wp", "core", "is-installed", "--allow-root"], "delta": "0:00:00.361342", "end": "2015-04-27 $
7:15:43.255098", "invocation": {"module_args": "wp core is-installed --allow-root", "module_name": "command"}, "item": {"key": "ou-history.dev", "value": {"admin_email": "ciarlil$
@ohio.edu", "admin_password": "admin", "admin_user": "admin", "env": {"db_name": "ouhistory", "db_password": "devel_pass", "db_user": "devel_user", "wp_env": "development", "wp_h$
me": "http://ou-history.dev", "wp_siteurl": "http://ou-history.dev/wp"}, "local_path": "../ou-history.dev", "multisite": {"enabled": false, "subdomains": false}, "repo": "git@git$
ab.dev:aldenlibrary/ou-history.git", "site_hosts": ["ou-history.dev"], "site_install": true, "site_title": "OU History (Dev)", "ssl": {"enabled": false}, "system_cron": true}}, "$
c": 1, "start": "2015-04-27 17:15:42.893756", "stderr": "Error: Can’t select database", "stdout": "", "stdout_lines": [], "warnings": []}, "rc": 1, "start": "2015-04-27 17:15:44.$
79706", "warnings": []}
stderr: Error: Can’t select database
changed: [default] => (item={u'cmd': [u'wp', u'core', u'is-installed', u'--allow-root'], u'end': u'2015-04-27 17:15:44.487901', u'stderr': u'', u'stdout': u'', u'changed': True, $
'rc': 1, 'item': {'value': {'site_install': True, 'admin_user': 'admin', 'local_path': '../main-site.dev', 'system_cron': True, 'repo': 'git@gitlab.dev:aldenlibrary/main-site.git$
, 'ssl': {'enabled': False}, 'multisite': {'enabled': False, 'subdomains': False}, 'site_title': 'OU Libraries (Dev)', 'admin_password': 'admin', 'env': {'db_name': 'mainsite', '$
p_env': 'development', 'db_user': 'devel_user', 'db_password': 'devel_pass', 'wp_home': 'http://main-site.dev', 'wp_siteurl': 'http://main-site.dev/wp'}, 'site_hosts': ['main-sit$
.dev'], 'admin_email': 'ciarlill@ohio.edu'}, 'key': 'main-site.dev'}, u'warnings': [], u'delta': u'0:00:01.097057', 'invocation': {'module_name': u'command', 'module_args': u'wp $
ore is-installed --allow-root'}, 'stdout_lines': [], u'start': u'2015-04-27 17:15:43.390844'})

FATAL: all hosts have already failed -- aborting
 ____________

And here is my group_vars/development

mysql_root_password: devpw

web_user: vagrant

wordpress_sites:
  main-site.dev:
    site_hosts:
      - main-site.dev
    local_path: '../main-site.dev' # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@gitlab.dev:aldenlibrary/main-site.git
    site_install: true
    site_title: OU Libraries (Dev)
    admin_user: admin
    admin_password: admin
    admin_email: ciarlill@ohio.edu
    multisite:
      enabled: false
      subdomains: false
    ssl:
      enabled: false
    system_cron: true
    env:
      wp_home: http://main-site.dev
      wp_siteurl: http://main-site.dev/wp
      wp_env: development
      db_name: mainsite
      db_user: devel_user
      db_password: devel_pass
  ou-history.dev:
    site_hosts:
      - ou-history.dev
    local_path: '../ou-history.dev' # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@gitlab.dev:aldenlibrary/ou-history.git
    site_install: true
    site_title: OU History (Dev)
    admin_user: admin
    admin_password: admin
    admin_email: ciarlill@ohio.edu
    multisite:
      enabled: false
      subdomains: false
    ssl:
      enabled: false
    system_cron: true
    env:
      wp_home: http://ou-history.dev
      wp_siteurl: http://ou-history.dev/wp
      wp_env: development
      db_name: ouhistory
      db_user: devel_user
      db_password: devel_pass

php_error_reporting: 'E_ALL'
php_display_errors: 'On'
php_display_startup_errors: 'On'
php_track_errors: 'On'
php_mysqlnd_collect_memory_statistics: 'On'
php_opcache_enable: 0

xdebug_install: false
php_xdebug_remote_enable: true
php_xdebug_remote_connect_back: true
php_xdebug_remote_host: localhost
php_xdebug_remote_port: 9000
php_xdebug_remote_log: /tmp/xdebug.log
php_xdebug_idekey: XDEBUG
php_max_nesting_level: 200

I had this working prior to updating bedrock-ansible to the latest. Not sure if it is due to the changes in config syntax or something else.

So it looks like my issue was related to trying to use the same user on 2 different databases. I ran across the possibility here: Multiple sites on one Vagrant box with bedrock-ansible and tried changing the username for the second database and it worked! Odd bug it seems like.

1 Like