valentinocossar / trellis-database-uploads-migration

Ansible playbook for Trellis that manages database and uploads migration.
MIT License
94 stars 13 forks source link

The fetch task assumes your site code is in a folder name match your site key #3

Closed grahamharper closed 7 years ago

grahamharper commented 7 years ago

Example: https://github.com/valentinocossar/trellis-database-and-uploads-migration/blob/master/database-pull.yml#L33

The recommended directory structure on the Trellis website is:

example.com/      # → Root folder for the project
├── trellis/      # → Your clone of this repository
└── site/         # → A Bedrock-based WordPress site
    └── web/
        ├── app/  # → WordPress content directory (themes, plugins, etc.)
        └── wp/   # → WordPress core (don't touch!)

so many people, like myself will have their site code in a folder called site rather than a folder name matching the site key which the example line above assumes.

The repo you based this on doesn't use the passed in site variable. https://github.com/hamedb89/trellis-db-push-and-pull/blob/master/db-pull.yml#L22

valentinocossar commented 7 years ago

Sorry for the delay. Yes, we use this naming convention because we use one Trellis to host more websites. This is the structure we have chosen to use:

project/                     # → Root folder for the project
├── _trellis-project/        # → Your clone of this repository
└── example.com/             # → A Bedrock-based WordPress site
    └── web/
        ├── app/             # → WordPress content directory (themes, plugins, etc.)
        └── wp/              # → WordPress core (don't touch!)

I've done a few updates to fix this problem and I've tested it with Ansible 2.3.0.0 and Ansible 2.0.2.0 and all seems to work fine. Now you can use which name do you want for the Bedrock folder.

In order to use the new version, I recommend you to re-install the tool and re-apply the new hosts configuration provided in the README. Could you help me to test this new version? Thank you 🙂

grahamharper commented 7 years ago

Thanks for some of the latest improvements but regarding the check for the folder you've added to the database script require me to pass site in as the second argument?

like this. ./bin/database.sh production site pull?

Won't this cause problems in the playbooks where {{ site }} is used? For example on remote servers using the recommended trellis structure

project_root: "{{ www_root }}/{{ site }}"

is

project_root: "/srv/www/example.com"

but if you pass site in as the second argument the script will be looking for

project_root: "/srv/www/site"

which won't exist.

Basically, the if statement in the script makes it not work for me. Removing it makes it work.

grahamharper commented 7 years ago

Also you should change on this line:

https://github.com/valentinocossar/trellis-database-and-uploads-migration/blob/master/database-pull.yml#L58

from {{ project_web_dir }} to {{ local_bedrock_dir }}

otherwise the dump file doesn't get deleted.

valentinocossar commented 7 years ago

Sorry, I forgot to push the last commit that removes the script that checks the folder existence. For the other change, I have to test with a fresh install with the same folder structure you use, to be sure it works fine with both naming conventions.

valentinocossar commented 7 years ago

Hi, sorry for the delay but in the last week I've done some fixes and improvements. Also, I've tested a lot this tool and now I would like to share this table with some of the tests I've done:

Trellis version Ansible version Passed Why not passed
0.9.6 2.0.2.0 Yes
0.9.9 2.0.2.0 Yes
0.9.9 2.2.0.0 Yes
0.9.9 2.2.1.0 No Not tested due to Trellis requirements
0.9.9 2.2.2.0 Yes
0.9.9 2.2.3.0 Yes
0.9.9 2.3.0.0 Yes
0.9.9 2.3.1.0 No Checksum error
1.0.0-rc.1 2.2.3.0 Yes
1.0.0-rc.1 2.3.0.0 Yes

Ansible was installed via pip and not Homebrew, if you are using Homebrew to install Ansible, I recommend you to install python and passlib using Homebrew and then install Ansible using pip.

To test the new version, I recommend you to completely reinstall the tool following the instructions provided in the README.

@grahamharper there's no need to change from {{ project_web_dir }} to {{ local_bedrock_dir }} on this line, because the problem was in the use of state=absentfor the dump file deletion (I don't know why but seems to be an Ansible issue), now the tool uses the classic rm instead.

Maybe this problem caused also the "nothing gets exchanged" problem reported by @ThriLLzd in the #1 issue.

Could you test the tool and provide me any kind feedback? Thank you.