I have a django application using postgres DB.
I have a chef recipe that installs a postgres database, including setting up a postgres username / password to use the django application.
This username / password is then used by the DATABASES settings.py value.
At the moment, I should have postgres details in both attributes.rb and settings.py . How can I use them in only one place?
The options that I was currently considering are:
Having settings.py (or part of it) generated by the chef's template. Therefore, the details should only be in the chef's recipe. The disadvantage of this is that the django application is incomplete if it is not deployed through the chef. (This may not be such a big problem, since even a local developer works with a stray + chef).
Having a known file on the file system that settings.py checks and loads some values. This file is generated by the chef. This is a little better than the first solution. It also requires some template code in settings.py to load and parse the file.
Enter the data in settings.py and let the chef extract it (somehow). This approach is problematic because it gets confused with the order in the chef's recipe (I have to check my django application, extract the value, use the values ββto configure postgres, and then run django). This in itself is not so bad, but the real problem arises when / if I want to switch to a system in which passwords are not in files with a controlled source, but in something like a chef's data packets.
I searched a bit on googled, but apart from various discussions in the settings.py layout and general talk about how to use django and chef, I can not find a suitable solution. Surely someone else has deployed a django application with postgres using a chef and stumbled upon this before?
source share