Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Ansible #256

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ charset = utf-8
[Makefile]
indent_style = tab

[*.{css,html,js,json}]
[*.{css,html,js,json,yml}]
indent_size = 2

[*.{rst,txt}]
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ docs/_build/
/.tox/
*.egg-info/

.ropeproject
.vagrant/
src/richard/static/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ python:
- '3.3'

env:
- DJANGO=""
- DJANGO="" DJANGO_SETTINGS_MODULE="richard.config.settings" DJANGO_CONFIGURATION="Testing"
# - DJANGO="https://github.com/django/django/archive/1.7b1.zip"

install:
- 'pip install -e .[dev]'
# - 'if ( test -n "$DJANGO" ); then pip install $DJANGO; fi'

script:
- 'python manage.py test'
- 'py.test ./tests'

notifications:
irc:
Expand Down
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Version 0.2: In development
* New API v2! Built on django-rest-framework, it should be simpler,
easier, and less buggy. See documentation for API details.

* Switched to django-configurations. You'll have to update your settings files,
but understanding where settings are coming from should now be much easier.


**Backwards-incompatible changes:**

Expand Down
62 changes: 62 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu/trusty64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 8000, host: 8000

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
#config.vm.synced_folder "..", "/vagrant_data"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
#
# View the documentation for the provider you're using for more
# information on available options.

config.vm.provision "ansible" do |ansible|
ansible.playbook = "provisioning/site.yml"
end
end
19 changes: 19 additions & 0 deletions docs/admin/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,22 @@
FIXME: This needs to be written. For now, you can look at the
:ref:`hacking-chapter`, use postgresql and skip the things that are
development-environment specific.

Settings
------------

richard relies extensively on environment settings which **will not work with
Apache/mod_wsgi setups**.

For configuration purposes, the following table maps the 'richard'
environment variables to their Django setting:

======================================= =========================== ============================================== ===========================================
Environment Variable Django Setting Development Default Production Default
======================================= =========================== ============================================== ===========================================
DJANGO_DATABASES DATABASES See code See code
DJANGO_DEBUG DEBUG True False
DJANGO_SECRET_KEY SECRET_KEY secret-value raises error
RICHARD_API API True False
RICHARD_SITE_URL SITE_URL http://127.0.0.1:8000 http://127.0.0.1:8000
======================================= =========================== ============================================== ===========================================
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# |version| and |release|, also used in various other places throughout the
# built documents.

sys.path.append('..')
sys.path.append('../src')
from richard import __version__ as version
release = version

Expand Down
10 changes: 0 additions & 10 deletions docs/contributors/dev_hacking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,6 @@ The superuser account you create here can be used to log into the
richard admin section.


Set up sample data (optional)
=============================

If you want to set up some initial data, do::

$ ./manage.py generatedata

This is useful to see how the site works.


Run the tests
=============

Expand Down
26 changes: 13 additions & 13 deletions docs/contributors/dev_layout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ directory tree like this::

richard
|- docs/ -- documentation
|- requirements/ -- requirements files for pip
\- richard/ -- richard django project
|- base/ -- base code shared by the other apps
|- pages/ -- code for "about", "contac", etc pages
|- sampledata/ -- code for loading sampledata from apps
|- sitenews/ -- code for sitenews
\- videos/ -- code for videos and search
|-src/
\- richard/ -- richard django project
|- base/ -- base code shared by the other apps
|- config/ -- settings and configuration
|- pages/ -- code for "about", "contac", etc pages
|- sampledata/ -- code for loading sampledata from apps
|- sitenews/ -- code for sitenews
\- videos/ -- code for videos and search


Here's what's there:
Expand All @@ -23,12 +24,7 @@ Here's what's there:
Documentation for the project build wtih Sphinx and formatted in
restructuredtext.

**richard/requirements/**

``.txt`` files that you use with pip to install richard's
requirements.

**richard/richard/**
**src/richard/**

This is the "Django project" part of the project and where the
"Django apps" go. There are a few:
Expand All @@ -39,6 +35,10 @@ Here's what's there:
central to the Django project. Middleware, context processors,
base templates, static assets, etc.

**config**

This is where the settings and wsgi files live.

**pages**

Like django.contrib.flatpages except that nothing is in the
Expand Down
43 changes: 15 additions & 28 deletions docs/contributors/dev_resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,18 @@ Project scaffolding
Settings
--------

`<https://docs.djangoproject.com/en/dev/topics/settings/#django.conf.settings.configure>`_
talks about settings, but doesn't cover separating settings into
multiple settings files.
richard has migrated to
`django-configurations <http://django-configurations.readthedocs.org/>`_
which makes settings in Django behave more like regular old class inheritance.
The classes ``Base``, ``Testing``, ``Dev`` and ``Prod`` in the ``settings.py``
module all handle the expected domains. You can override these by:

richard uses ``settings_local.py`` for locally overriding settings
defaults. Also, James Bennett talks about using ``local_settings.py`` in
"Practical Django Projects" [PDP2009] which is essentially the same,
but with a slightly different name. I like ``settings_local.py``
better than ``local_settings.py`` since then all my settings files
get listed next to each other when sorted alphabetically.

.. [PDP2009] Practical Django Projects, by James Bennett

For tests, richard uses ``settings_test.py`` which allows us to
override settings explicitly for the test environment. We do this at
Mozilla and it makes things a lot easier.
* creating a ``settings_local.py`` file
* ``from . import settings``
* creating your class (or creating a Dev / Prod class) and extending from
``settings.Base``
* Updating your deployment scripts to run ``manage.py --settings
richard.config.settings_local``


Requirements / environments / deployment
Expand All @@ -44,19 +40,10 @@ Requirements / environments / deployment
richard uses virtualenv and pip to build the environment for richard
to run.

Requirements are listed in ``requirements/`` in multiple files. The
base requirements are in ``requirements/base.txt`` and other
use-oriented requirements files include that and then add additional
requirements. This makes it easier to specify different kinds of
environments like development and deployment.

pip reads the requirements files, downloads requirements, and installs
them into the virtual environment.

It works pretty well except when PyPI is down.

We may revisit this later if this becomes an annoying problem.

Requirements are listed in the ``setup.py`` with ``extra_requires`` defined
for local development and postgres. Since richard is meant for deployment
rather than a framework, requirements are pinned hard. This makes it easy to
install various options without having multiple requirements files.

Documentation
-------------
Expand Down
5 changes: 3 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@


if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "richard.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "richard.config.settings")
os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')

from django.core.management import execute_from_command_line
from configurations.management import execute_from_command_line

execute_from_command_line(sys.argv)
1 change: 1 addition & 0 deletions provisioning/galaxy.roles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jdauphant.nginx
18 changes: 18 additions & 0 deletions provisioning/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: install latest pip from apt
apt: pkg=python-pip state=installed
tags: pip

- name: install pip from pypi
pip: name=pip version=1.5.6
tags: pip

- name: install virtualenv
pip: name=virtualenv version=1.11.6
tags: pip

- name: install build-essential
apt: pkg=build-essential state=installed

- name: install python-dev
apt: pkg=python-dev state=installed
12 changes: 12 additions & 0 deletions provisioning/roles/jdauphant.nginx/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
language: python
python: "2.7"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq python-apt python-pycurl
install:
- pip install ansible
script:
- echo localhost > inventory
- ansible-playbook --syntax-check -i inventory test.yml
- ansible-playbook -i inventory test.yml --connection=local --sudo -vvvv
Loading