valentinocossar / trellis-database-uploads-migration

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

Issue during database pull/push with Ansible 2.4.1.0 #9

Closed partounian closed 6 years ago

partounian commented 6 years ago

TASK [Push database dump from development to staging]


System info: Ansible 2.4.1.0; Darwin Trellis at "Switch from .dev to .test"

The task includes an option with an undefined variable. The error was: {{ to_host.wordpress_sites[site].local_path }}: 'dict object' has no attribute 'wordpress_sites'

The error appears to have been in '[redacted]/database-push.yml': line 49, column 7, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Push database dump from development to {{ env }}
  ^ here

We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance:

with_items:
  - {{ foo }}

Should be written as:

with_items:
  - "{{ foo }}"

exception type: <class 'ansible.errors.AnsibleUndefinedVariable'> exception: {{ to_host.wordpress_sites[site].local_path }}: 'dict object' has no attribute 'wordpress_sites' fatal: [staging_host]: FAILED! => {"failed": true}

Note: An uploads push worked fine

Edit: This might also help

ERROR! The field 'hosts' has an invalid value, which includes an undefined variable. The error was: 'env' is undefined

The error appears to have been in '[redacted]/database-push.yml': line 2, column 3, but may ...

Edit 2: It also happens for pulling.

valentinocossar commented 6 years ago

Thank you for the feedback, now I have to reproduce the problem and fix it. I'll update the issue with more info as soon as possible.

partounian commented 6 years ago

No problem, thank you @valentinocossar for the plugin šŸ‘

partounian commented 6 years ago

Hey @valentinocossar have you had the chance to look at the issue?

valentinocossar commented 6 years ago

Hi @partounian, sorry for the delay, I've found that the problem is not related to the tool itself but it's an Ansible bug. The problem only affects Ansible 2.4.1.0 and it has been fixed in Ansible 2.4.2.0, in fact, the tool works without problems using Ansible 2.4.0.0 or Ansible 2.4.2.0.

These are the issues related to the problem you've reported: #32466, #31758, #31755. And here you can find the pull request with the fix #32269.

Now I would like to do more tests to ensure everything works well and then I'll update the README with an alert saying not to use Ansible 2.4.1.0 with this tool.

Thank you for the feedback.

partounian commented 6 years ago

Thank you for the update. Funny enough, now it seems like uploads pulling does not work or at least it throws this error "No such file or directory (2)\nrsync: rename failed for"

Upload pushing seems to work but not sure if it's taking a long time for mine to complete or that it does not complete the ansible prompt.

valentinocossar commented 6 years ago

I've not modified anything other than the README and I've not plans to release a new version only for this quick improvement. Could you open another issue for this bug with more information? Thank you.

luckyluggi commented 6 years ago

I still have this bug with ansible version 2.4.3.0 I also tried it with 2.4.0.0, 2.4.1.0, 2.4.2.0 and even 2.5.0.0 i always get this same error:


The task includes an option with an undefined variable. The error was: {{ to_host.wordpress_sites[site].local_path }}: 'dict object' has no attribute 'wordpress_sites'

The error appears to have been in '/home/me/dev/example.com/trellis /database-push.yml': line 49, column 7, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Push database dump from development to {{ env }}
  ^ here

We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance:

with_items:
  - {{ foo }}

Should be written as:

with_items:
  - "{{ foo }}"

exception type: <class 'ansible.errors.AnsibleUndefinedVariable'> exception: {{ to_host.wordpress_sites[site].local_path }}: 'dict object' has no attribute 'wordpress_sites' fatal: [IP-ADDRESS]: FAILED! => {} to retry, use: --limit @/home/me/dev/example.com/trellis/database-push.retry

am i doing something wrong? (i try to set this up the fiorst time) The command i'm running is (inside /trellis) ./bin/database.sh production example.com push

PS: the file pushing works

valentinocossar commented 6 years ago

Hi, Trellis version? macOS version?

luckyluggi commented 6 years ago

Hi, I'm working on ubuntu 17.10. The Server is an Ubuntu 16 DO-droplet. And i don't know where to see my actual trellis version, but since i pulled it 2 days ago it has to be the newest version i think.

valentinocossar commented 6 years ago

Sorry, but as reported in the README this tool has been tested only with macOS. I don't have a PC with Ubuntu to test it and unfortunately, I don't have so much time to support other operating systems. If you want, you can provide help to support Ubuntu, feel free to open a new issue or pull request.

luckyluggi commented 6 years ago

oh shit. i didn't see that its only tested on macos. Thx anyways!

valentinocossar commented 6 years ago

No worries! šŸ™‚

christophfahle commented 6 years ago

Hey Valentino, thanks for this little tool. It sounds like a really good thing to have. I am running on OSX 10.13.4 with Ansible 2.4.3.0 installed but I still get the same error. Did you ever find out what caused this error or get close to a fix?

Thanks in advance!!!

Christoph

valentinocossar commented 6 years ago

Hi @christophfahle, which version of Trellis are you using? Thank you!

davebowker commented 6 years ago

Adding to this, I opened up a new issue but looks like it could be this issue? Not sure.

Mac OS 10.13.5 Trellis Version 1.0.0-rc.2

valentinocossar commented 6 years ago

This issue was related to an Ansible 2.4.1.0 bug, fixed in Ansible 2.4.2.0. So I prefer to investigate your problem in the issue you've opened and close the comments to this one.