Skip to content
Maikel Linke edited this page Nov 12, 2015 · 27 revisions

Setup of the Ansible Playbooks

If you haven't done it already, clone the deployment repository:

git clone https://github.com/openfoodfoundation/ofn_deployment.git

Setup Host Configuration

You will need a vars.yml file. It defines important customisations of your deployment like locale, domain name, database and admin passwords. Copy the example file and edit it:

cp vars.example.yml vars.yml
# edit vars.yml with your favourite editor

If you want to deploy to multiple servers, you probably want to have a vars file for each of them. Place them in the host_vars directory, for example:

mkdir host_vars
cp vars.example.yml host_vars/www.openfoodnetwork.au.yml
cp vars.example.yml host_vars/staging.openfoodnetwork.au.yml
# edit host_vars/*.yml with your favourite editor

If you're not familiar with YAML, read more at the official YAML site. You can validate the syntax of your vars file with the Online YAML Parser.

Seed data

By default, the OFN is installed with Australia specific data like states and postcodes. The Open Food Foundation collects more localisation data repositories. They follow the name scheme l10n_<country-code> like l10n_gb or l10n_fr.

If you are the first to run an OFN app for a country, you have to create a repository with that data first. It should contain the following files:

Publish that repository somewhere accessible for your server. The Open Food Foundation will be happy to put your repository amongst the others. Then change the l10n_repo variable in your vars file to match your repository.

Languages

The OFN comes with several language files in config/locales. You choose the language in the vars file by setting the locale variable. If you want to change the language of the application at a later point, you can do that directly on the server:

ssh example.com
cd apps/openfoodnetwork/current
vi config/application.yml  # change LOCALE
rm public/assets/darkswarm/all*.js
bundle exec rake RAILS_ENV=staging assets:precompile:primary RAILS_GROUPS=assets
bundle exec rake RAILS_ENV=staging assets:precompile:nondigest RAILS_GROUPS=assets
service unicorn_openfoodnetwork restart

SSL certificate files

For production and staging environments, you will need SSL certificates for the domain name. (The domain name is specified in the vars.yml file.)

  • Purchase a certificate from a provider.
  • Create two text files: ssl.crt and ssl.key.
  • In ssl.crt add the content of the certificate and chain bundle.
  • In ssl.key add the content of the private key.

Note: the formatting of these text blocks must be that there are no spaces other than in the start/end lines and each line is 64 characters long.

  • Put these in the files folder.

Continue with the Provisioning of your server.