Skip to content
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
3 changes: 2 additions & 1 deletion access/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pickle-email-*.html
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
config/initializers/secret_token.rb
config/secrets.yml
config/database.yml

## Environment normalisation:
/.bundle
Expand All @@ -35,4 +36,4 @@ config/secrets.yml
bower.json

# Ignore pow environment settings
.powenv
.powenv
3 changes: 1 addition & 2 deletions access/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
Expand Down
2 changes: 0 additions & 2 deletions access/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.11)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
Expand Down Expand Up @@ -192,7 +191,6 @@ DEPENDENCIES
simplecov
simplecov-rcov
spring
sqlite3
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
Expand Down
26 changes: 0 additions & 26 deletions access/config/database.yml

This file was deleted.

15 changes: 13 additions & 2 deletions ansible/group_vars/database-servers
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
db_username: access
db_password: some_password_here
db_name: access-db
db_username: access
production:
name: production
db_type: postgresql
db_name: access-db
development:
name: development
db_type: sqlite3
db_name: db/development.sqlite3
test:
name: test
db_type: postgresql
db_name: access-db-test
22 changes: 10 additions & 12 deletions ansible/roles/access/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
service: name=httpd state=restarted enabled=yes

- name: Copy secrets.yml
template: src=config/secrets.yml.j2 dest={{application_path}}/access/config/secrets.yml
template: src=config/secrets.yml.j2 dest={{ application_path }}/access/config/secrets.yml
owner={{ application_user }} group={{ application_user }} mode=0644
notify: restart apache
tags: install_access

- name: restart apache
service: name=httpd state=restarted enabled=yes
- name: Copy database.yml
template: src=config/database.yml.j2 dest={{ application_path }}/access/config/database.yml
owner={{ application_user }} group={{ application_user }} mode=0640
notify: restart apache
tags: install_access

##########################################################
############ Change owner of the application ############
Expand Down Expand Up @@ -76,7 +79,7 @@
########### Rake db tasks ###########
#####################################
- name: rake db:migrate
shell: bash -lc "rake db:migrate" chdir="{{ application_path }}/access"
shell: bash -lc "rake db:schema:load" chdir="{{ application_path }}/access"
tags:
- rake_db_tasks

Expand All @@ -91,20 +94,15 @@
tags: install_access

- name: Change owner of database
file: path={{ application_path }}/access/db/development.sqlite3 owner={{ application_user }}
group={{ application_user }}
file: path={{ application_path }}/access/db/development.sqlite3 state=touch
owner={{ application_user }} group={{ application_user }}
notify: restart apache
tags: install_access

- name: restart apache
service: name=httpd state=restarted enabled=yes
when: development.db_type == 'sqlite3'

# This task is to be run once. If the data have already been seeded and the seed
# file has changed, the process of updating has to be done manually.
# - name: rake db:seed
# shell: bash -lc "rake db:seed" chdir="{{ application_path }}/access"
# tags:
# - rake_db_tasks

# tranfer all the data needed (e.g.database.yml)
# (maybe) run checks
14 changes: 14 additions & 0 deletions ansible/roles/access/templates/config/database.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% for env in [production, development, test] %}
{{ env.name }}:
adapter: {{ env.db_type }}
database: {{ env.db_name }}
{% if env.db_type == 'postgresql' %}
encoding: unicode
username: {{ db_username }}
password: {{ db_password }}
{% elif env.db_type == 'sqlite3'%}
pool: 5
timeout: 5000
{% endif %}

{% endfor %}
15 changes: 11 additions & 4 deletions ansible/roles/postgres/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
become: yes
become_user: postgres
tags: postgres_configure

- name: Enable password authentication for the new user
lineinfile: dest=/var/lib/pgsql/data/pg_hba.conf regexp="^local(.)*{{ db_username }}(\s)*md5$"
insertbefore="^local(.)*all(\s)*peer$"
line="local all {{ db_username }} md5"
state=present
tags: postgres_configure

- name: Create access application database
postgresql_db: name={{ db_name }} encoding='UTF-8' owner={{ db_username }}
postgresql_db: name={{ production.db_name }} encoding='UTF-8' owner={{ db_username }}
become: yes
become_user: postgres
tags: postgres_configure
tags: postgres_configure

- name: Create access development application database
postgresql_db: name={{ development.db_name }} encoding='UTF-8' owner={{ db_username }}
become: yes
become_user: postgres
tags: postgres_configure
when: development.db_type == 'postgres'