Commit b20a64b537b4d81d51043fa49f4659e43b6eede8
1 parent
04719471
Exists in
master
and in
90 other branches
finish colab installation
Pending: nginx for colab
Showing
5 changed files
with
90 additions
and
8 deletions
Show diff stats
config/roles/integration_server.rb
1 | name "integration_server" | 1 | name "integration_server" |
2 | description "Application that manages user authentication, visual integration and gamification" | 2 | description "Application that manages user authentication, visual integration and gamification" |
3 | -run_list 'recipe[colab]' | 3 | + |
4 | +# TODO colab and mailman-api should be able to run in separate hosts at some | ||
5 | +# point in the future | ||
6 | +run_list 'recipe[mailman-api]', 'recipe[colab]' |
cookbooks/colab/recipes/default.rb
1 | -# TODO colab and mailman-api should be able to run in separate hosts at some | ||
2 | -# point in the future | ||
3 | -include_recipe 'mailman-api' | ||
4 | - | ||
5 | if node['platform'] == 'centos' | 1 | if node['platform'] == 'centos' |
6 | cookbook_file '/etc/yum.repos.d/colab.repo' do | 2 | cookbook_file '/etc/yum.repos.d/colab.repo' do |
7 | owner 'root' | 3 | owner 'root' |
@@ -11,6 +7,29 @@ end | @@ -11,6 +7,29 @@ end | ||
11 | 7 | ||
12 | package 'colab' | 8 | package 'colab' |
13 | 9 | ||
10 | +directory '/etc/colab' do | ||
11 | + owner 'root' | ||
12 | + group 'root' | ||
13 | + mode 0755 | ||
14 | +end | ||
15 | + | ||
16 | +execute 'secret-key' do | ||
17 | + f = '/etc/colab/secret.key' | ||
18 | + command "openssl rand -hex 32 -out #{f} && chown root:colab #{f} && chmod 0640 #{f}" | ||
19 | + not_if { File.exists?(f) } | ||
20 | + notifies :create, 'template[/etc/colab/settings.yaml]' | ||
21 | +end | ||
22 | + | ||
23 | +template '/etc/colab/settings.yaml' do | ||
24 | + owner 'root' | ||
25 | + group 'colab' | ||
26 | + mode 0640 | ||
27 | +end | ||
28 | + | ||
29 | +execute 'colab-admin migrate' | ||
30 | +execute 'colab-admin collectstatic --noinput' | ||
31 | + | ||
14 | service 'colab' do | 32 | service 'colab' do |
15 | action :start | 33 | action :start |
34 | + supports :restart => true | ||
16 | end | 35 | end |
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +DATABASES: | ||
2 | + default: | ||
3 | + ENGINE: django.db.backends.postgresql_psycopg2 | ||
4 | + NAME: colab | ||
5 | + USER: colab | ||
6 | + HOST: <%= node['peers']['database'] %> | ||
7 | + | ||
8 | +## Set to false in production | ||
9 | +DEBUG: false | ||
10 | +TEMPLATE_DEBUG: false | ||
11 | + | ||
12 | +## System admins | ||
13 | +ADMINS: &admin | ||
14 | +<%- node['config']['admins'].each do |admin| %> | ||
15 | + - | ||
16 | + <%- admin.each do |item| %> | ||
17 | + - <%= item %> | ||
18 | + <%- end %> | ||
19 | +<% end %> | ||
20 | + | ||
21 | +MANAGERS: *admin | ||
22 | + | ||
23 | +COLAB_FROM_ADDRESS: '<%= node['config']['colab_from_address'] %>' | ||
24 | +SERVER_EMAIL: '<%= node['config']['server_email'] %>' | ||
25 | + | ||
26 | +EMAIL_HOST: localhost | ||
27 | +EMAIL_PORT: 25 | ||
28 | +EMAIL_SUBJECT_PREFIX: <%= node['config']['email_subject_prefix'] %> | ||
29 | + | ||
30 | +SECRET_KEY: <%= File.read('/etc/colab/secret.key').strip %> | ||
31 | + | ||
32 | +SITE_URL: <%= node['config']['site_url'] %> | ||
33 | +BROWSERID_AUDIENCES: | ||
34 | + - <%= node['config']['site_url'].sub('http:', 'https:') %> | ||
35 | + - <%= node['config']['site_url'].sub('https:', 'http:') %> | ||
36 | + | ||
37 | +ALLOWED_HOSTS: | ||
38 | + - localhost # for tests | ||
39 | + - <%= node['config']['external_hostname'] %> | ||
40 | + | ||
41 | +## Disable indexing | ||
42 | +ROBOTS_NOINDEX: false |
nodes.yaml
@@ -2,6 +2,16 @@ vagrant@integration: | @@ -2,6 +2,16 @@ vagrant@integration: | ||
2 | run_list: | 2 | run_list: |
3 | - role[server] | 3 | - role[server] |
4 | - role[integration_server] | 4 | - role[integration_server] |
5 | + config: &CONFIG | ||
6 | + admins: | ||
7 | + - | ||
8 | + - Paulo Meirelles | ||
9 | + - paulo@softwarelivre.org | ||
10 | + external_hostname: beta.softwarepublico.gov.br | ||
11 | + site_url: https://beta.softwarepublico.gov.br | ||
12 | + colab_from_address: '"Portal do Software Publico" <noreply@beta.softwarepublico.gov.br>' | ||
13 | + server_email: '"Portal do Software Publico" <noreply@beta.softwarepublico.gov.br>' | ||
14 | + email_subject_prefix: '[spb]' | ||
5 | peers: &PEERS | 15 | peers: &PEERS |
6 | integration: 10.10.10.2 | 16 | integration: 10.10.10.2 |
7 | email: 10.10.10.3 | 17 | email: 10.10.10.3 |
test/colab_test.sh
1 | . $(dirname $0)/test_helper.sh | 1 | . $(dirname $0)/test_helper.sh |
2 | 2 | ||
3 | +test_database_connectivity() { | ||
4 | + assertTrue 'colab database connectivity' 'run_on integration psql -h database -U colab < /dev/null' | ||
5 | +} | ||
6 | + | ||
3 | test_colab_config_is_in_place() { | 7 | test_colab_config_is_in_place() { |
4 | - assertTrue 'colab settings.yml is in place' 'run_on colab test -f /etc/colab/settings.yml' | 8 | + assertTrue 'colab settings.yml is in place' 'run_on integration test -f /etc/colab/settings.yaml' |
9 | +} | ||
10 | + | ||
11 | +test_colab_running() { | ||
12 | + assertTrue 'colab service running' 'run_on integration pgrep -fa colab.wsgi' | ||
5 | } | 13 | } |
6 | 14 | ||
7 | -test_colab_installed_and_running() { | ||
8 | - assertTrue 'colab service running' 'run_on colab pgrep -fa colab.wsgi' | 15 | +test_colab_responds() { |
16 | + assertTrue 'colab responds' 'run_on integration curl --fail http://localhost:8001' | ||
9 | } | 17 | } |
10 | 18 | ||
11 | . shunit2 | 19 | . shunit2 |