jcalazan / ansible-django-stack

Ansible Playbook for setting up a Django app with Nginx, Gunicorn, PostgreSQL, Celery, RabbitMQ, Supervisor, Virtualenv, and Memcached. A Vagrantfile for provisioning a VirtualBox virtual machine is included as well.
MIT License
1.37k stars 391 forks source link

'db_name' is undefined error in Vagrant up /roles/db/tasks/main.yml task #193

Open jpmjpmjpm opened 1 year ago

jpmjpmjpm commented 1 year ago

Aiming at upgrading Ubuntu / python / Django and else, I'm back using this good playbook. However when running it 'as is' against a VM/Vagrant box, I got following error:

TASK [db : Ensure database is created] ***************************************
task path: ./roles/db/tasks/main.yml:35
fatal: [my-cool-app.local]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'db_name' is undefined. 'db_name' is undefined
The error appears to be in '/home/jpmerx/dev/ansible-django-stack/roles/db/tasks/main.yml': line 35, column 3, but maybe elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:\n\n\n- name: Ensure database is created\n  ^ here"}

I imagine that the root cause is that group_vars/vagrant/vars.yml variables are not taken into account.

However, I don't know why. Is there some specific thing that I have to manage on my side? Or is this a bug/regression? If the last point is true, then I can volunteer to fix it.

Thanks!

YPCrumble commented 1 year ago

@jpmjpmjpm I think there are quite a few updates to get the repo working for 22.04. @autn would you be able to make a PR here next week with the changes you made to get it working on 22.04 so we can get them into this repo?

jpmjpmjpm commented 1 year ago

@jpmjpmjpm I think there are quite a few updates to get the repo working for 22.04. @autn would you be able to make a PR here next week with the changes you made to get it working on 22.04 so we can get them into this repo?

@YPCrumble Thanks for your quick response. Do I understand well that the master branch of the repo is known to be currently broken?

autn commented 1 year ago

@jpmjpmjpm do you define db_name in group_vars/[your_environment_name]/vars.yml?

jpmjpmjpm commented 1 year ago

@jpmjpmjpm do you define db_name in group_vars/[your_environment_name]/vars.yml?

I just used the master repo without any changes.

YPCrumble commented 1 year ago

@jpmjpmjpm just had a chance to look at this. It looks like I had updated the repo for Ubuntu 22.04, but I do know that my team has had to make quite a few updates to things like RabbitMQ configuration that they will likely be able to make a PR into this repo for this week.

For your issue in particular, v2.0 of this repo is using Ansible's group_vars which you could take a look at in the Ansible documentation for managing inventory, as well as here in our README: https://github.com/jcalazan/ansible-django-stack#configuring-your-application

That's likely the source of your issue. I just made a PR to run our test suite every week; if that's passing then I believe the repo should be working as-is for Ubuntu 22.04.

You could also check this issue but I thought I had solved this problem as long as the directory structure is up to date with Ansible's group_vars: https://github.com/jcalazan/ansible-django-stack/issues/186

Let me know if none of this leads to the solution?

jpmjpmjpm commented 9 months ago

@jpmjpmjpm just had a chance to look at this. It looks like I had updated the repo for Ubuntu 22.04, but I do know that my team has had to make quite a few updates to things like RabbitMQ configuration that they will likely be able to make a PR into this repo for this week.

For your issue in particular, v2.0 of this repo is using Ansible's group_vars which you could take a look at in the Ansible documentation for managing inventory, as well as here in our README: https://github.com/jcalazan/ansible-django-stack#configuring-your-application

That's likely the source of your issue. I just made a PR to run our test suite every week; if that's passing then I believe the repo should be working as-is for Ubuntu 22.04.

You could also check this issue but I thought I had solved this problem as long as the directory structure is up to date with Ansible's group_vars: #186

Let me know if none of this leads to the solution?

Sorry for being late in responding!

In fact, in the past, running the command vagrant up without any change to the repo was working perfectly to provision a vanilla vagrant server. That was great to proceed from a working repo proceeding with updates. It is no longer the case, as now, we get the error I mentioned above.

Any idea how to solve that? I mean without forcing modifications to have a working tool form scratch?

Thanks!