I’d like to run several sites on one VM provisioned with bedrock-ansible. I’ve read this thread:
where @emaildano was trying to achieve the same set-up. I can see there is a number of hints on how this can be achieved, but I thought maybe this process is now simplified in the latest version of bedrock-ansible ?
I noticed that the latest Vagrantfile is now designed so that it iterates through wordpress.sites and syncronizes folders for each site. It made me think that the previous thread might be now outdated.
It’s great that the process has been simplified so much.
However, I’ve added another site to group_vars/development, reloaded Vagrant with the --provision flag, saw tasks passing successfully until it came to
I inspected .env in the current folder on my Vagrant machine and it contains correct database information. However, .env on my local drive is totally empty. This might be the problem because these files are supposed to be shared, aren’t they?
Also, just to clarify, I assume that do not need to manually create a database for my second site.
I think you might also need to run vagrant reload. Vagrant needs to set up the other synced folder and I don’t think that happens just running vagrant provision.
I actually run vagrant reload --provision at my first attempt. Anyway, I managed to get the database working be reloading vagrant yet again.
Unfortunately, another obstacle has come up. I have two sites added to my group_vars/development file. It appears that the second defined database overrides the first one so, in consequence, I end up with two wordpress installs, but only with one database - the one that was defined last.
To be clearer, my configuration of databases look like this:
I don’t know what version of bedrock-ansible you’re using, but here’s the current code that creates the databases:
You can see that it loops over wordpress_sites and creates a database for each one. There may have been a bug at some point so maybe you can post your code?
It will either be in roles/wordpress-sites/tasks/database.yml or roles/wordpress-setup/tasks/database.yml
I’m totally new to ansible, but it does not seem to be overwriting each created database with the next database it is creating. Might the reason be that I’m using the same user for both databases, or is it irrelevant?
I can’t think of any reason why that wouldn’t be working. db_user wouldn’t matter. Only thing that would is the db_name and you have yours set correctly.
You can manually verify which databases exist from the command line:
I managed to solve the issue. Once I used a different user for each stie’s database, all is working as expected. Both sites can communicate with their databases. I only need to log in to these mysql databases with different credentials.
I’m still wondering where in the configuration files it is determined that one db_user should have only one database assigned to him…
If you are working locally and want to use one user for all databases, you may as well use the root user. If it’s for a staging/production site, then you’ll be safer using one user per database/site anyways.
However, I’d still like to see when in the ansible playbooks it is determined that there should be one db user for one database. I was not able to find such fragment of configuration in the playbooks. Just pure curiosity
If this is indeed happening it’s a bug and not by design. And a weird bug too since I’m not sure why the user would matter. I did take a look earlier and didn’t see any issues (without trying it).