-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved support for different project layouts. #92
Conversation
The current project layout assumes manage.py wsgi.py and the requirements file can be found in the root directory of the project. You can override this by editing paths in roles/web/defaults/main.yml but this means digging around in the internals of the project. It would be much nice if all the user editable parts were restricted to the env_var directory. The solution was to a "Project layout" section in env_vars/base.yml where the paths, relative to the root of the project can be defined. Since the requirements are often environment specific the relative path was also defined in env_vars/vagrant.yml and env_vars/development.yml so it can be overridden as needed. In roles/web/defaults/main.yml the definition for reuirements_file was changed to use the relative path and a new variable, django_path, was added, allowing the location of manage.py and wsgi.py to be decoupled from project_path. This gives more flexibility if the user still needs to go in and edit this file to match their project layout. NOTE: the changes to roles/web/defaults/main.yml are sufficient to support different layouts but creating the relative paths is useful so only the env_vars files need to be edited.
+1 I was just going to commit something similar Ps. Why are those tests failing? |
From the log output it appears that the following task: |
Reopened to trigger build on Travis. |
Build errored out once more as a result of a timeout. Closing and re-opening once more. |
@StuartMacKay yeah that's definitely what happened regarding the tests. Molecule v2 is out so it's possible that addressing #78 might make it run faster. In general though this requires configuring a server twice to ensure idempotence so it's going to be a long process no matter what. Looks like they're both passing now 👍 |
# requirements.txt can be found in the root directory of the project. | ||
# Override this value in env_vars/vagrant.yml and/or env_vars/development.yml | ||
# if you have different requirements for each environment. | ||
requirements_relative_file: ./requirements_local.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StuartMacKay shouldn't this be requirements.txt
? requirements_local.txt is specific to the Vagrant box I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had requirements.txt previously but the tests failed as a result. They are expecting django-debug-toolbar to be installed and that is defined in requirements_local.txt. See https://travis-ci.org/jcalazan/ansible-django-stack/builds/388667191
|
||
# Uncomment and change this if you have specific requirements when | ||
# running the app on the Vagrant VM. | ||
# requirements_relative_file: "./requirements_local.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StuartMacKay same issue here - shouldn't this be uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the commented out variables to development.yml and vagrant.yml so that you'd have the option to override the default in base.yml for local development.
To run the playbook I have a JSON file with all the variables I need and pass it on the command line using --extra-vars="@.json". That neatly solves the problem with Ansible vast and complicated precedence rules.
As a result I am not sure that having extra definitions that can be selectively uncommented make any sense. I'm happy with any change you want here.
@StuartMacKay I'm working on a fix to #78 which I'm hoping will help with the TravisCI suite failing. I added in particular this question on StackOverflow as it seems the Will come back to this once that's done. cc @jcalazan |
There are only really four points of contact between this project and a django application:
All of these are easily overridden by passing in extra vars on the command line when running the playbooks:
As a result changes in this PR are not really required and I am closing it. |
The current project layout assumes manage.py wsgi.py and the requirements
file can be found in the root directory of the project. You can override
this by editing paths in roles/web/defaults/main.yml but this means digging
around in the internals of the project. It would be much nice if all the
user editable parts were restricted to the env_var directory.
The solution was to a "Project layout" section in env_vars/base.yml where
the paths, relative to the root of the project can be defined. Since the
requirements are often environment specific the relative path was also
defined in env_vars/vagrant.yml and env_vars/development.yml so it can
be overridden as needed.
In roles/web/defaults/main.yml the definition for reuirements_file was
changed to use the relative path and a new variable, django_path, was
added, allowing the location of manage.py and wsgi.py to be decoupled
from project_path. This gives more flexibility if the user still needs
to go in and edit this file to match their project layout.
NOTE: the changes to roles/web/defaults/main.yml are sufficient to support
different layouts but creating the relative paths is useful so only the
env_vars files need to be edited.