Commit 7ec65795389d533681c4ed79dc7d752598650c56

Authored by Antonio Terceiro
1 parent 33df6d4c
Exists in master and in 90 other branches 3.x, add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup, backup_not_prod, cdtc_configuration, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev-lappis, dev_env_minimal, disable_email_dev, docs, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, performance, prezento, r3, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_backup_emails, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, stable-devel, support_docs, syslog, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Noosfero configuration

There are still a few TODO's
Rakefile
... ... @@ -33,4 +33,5 @@ task :bootstrap_common => '.ssh_config'
33 33  
34 34 unless ENV['nodeps']
35 35 task 'converge:integration' => 'converge:database'
  36 + task 'converge:social' => 'converge:database'
36 37 end
... ...
config/roles/database_server.rb
... ... @@ -5,4 +5,5 @@ run_list *[
5 5 'recipe[redis]',
6 6 'recipe[postgresql::colab]',
7 7 'recipe[postgresql::gitlab]',
  8 + 'recipe[postgresql::noosfero]',
8 9 ]
... ...
config/roles/social_server.rb
1 1 name 'database_server'
2 2 description 'Social networking server'
3   -#run_list 'recipe[noosfero]'
  3 +run_list *[
  4 + 'recipe[basics::nginx]',
  5 + 'recipe[noosfero]'
  6 +]
... ...
cookbooks/colab/templates/01-apps.yaml.erb
... ... @@ -2,3 +2,5 @@
2 2 PROXIED_APPS:
3 3 gitlab:
4 4 upstream: 'http://<%= node['peers']['integration'] %>:8081/gitlab/'
  5 + noosfero:
  6 + upstream: 'http://<%= node['peers']['social'] %>:8080/social/'
... ...
cookbooks/noosfero/files/noosfero-default 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +# MANAGED WITH CHEF; DO NOT MAKE MANUAL CHANGES
  2 +
  3 +export RAILS_RELATIVE_URL_ROOT=/social
  4 +
  5 +NOOSFERO_DIR="/usr/lib/noosfero"
  6 +NOOSFERO_USER="noosfero"
  7 +NOOSFERO_DATA_DIR="/var/lib/noosfero"
... ...
cookbooks/noosfero/recipes/default.rb 0 → 100644
... ... @@ -0,0 +1,52 @@
  1 +if node['platform'] == 'centos'
  2 + cookbook_file '/etc/yum.repos.d/noosfero.repo' do
  3 + owner 'root'
  4 + mode 0644
  5 + end
  6 +end
  7 +
  8 +package 'noosfero'
  9 +
  10 +template '/etc/noosfero/database.yml' do
  11 + owner 'noosfero'
  12 + group 'noosfero'
  13 + mode '0600'
  14 + notifies :restart, 'service[noosfero]'
  15 +end
  16 +
  17 +# create DB schema
  18 +execute 'noosfero:schema' do
  19 + command 'RAILS_ENV=production bundle exec rake db:schema:load && RAILS_ENV=production bundle exec rake db:data:minimal'
  20 + cwd '/usr/lib/noosfero'
  21 + user 'noosfero'
  22 + not_if do
  23 + # if the profiles table already exists, the schema was already loaded
  24 + system("psql -h database -U noosfero --no-align --tuples-only -q -c 'select count(*) from profiles'")
  25 + end
  26 + notifies :restart, 'service[noosfero]'
  27 +end
  28 +
  29 +# TODO remote user auth
  30 +# TODO spb plugin
  31 +# TODO theme
  32 +
  33 +template '/etc/noosfero/thin.yml' do
  34 + owner 'root'; group 'root'; mode 0644
  35 + notifies :restart, 'service[noosfero]'
  36 +end
  37 +
  38 +cookbook_file '/etc/default/noosfero' do
  39 + owner 'root'; group 'root'; mode 0644
  40 + source 'noosfero-default'
  41 + notifies :restart, 'service[noosfero]'
  42 +end
  43 +
  44 +service 'noosfero' do
  45 + action [:enable, :start]
  46 +end
  47 +
  48 +template '/etc/nginx/conf.d/noosfero.conf' do
  49 + owner 'root'; group 'root'; mode 0644
  50 + source 'nginx.conf.erb'
  51 + notifies :reload, 'service[nginx]'
  52 +end
... ...
cookbooks/noosfero/templates/database.yml.erb 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +# MANAGED WITH CHEF. DO NOT MAKE MANUAL CHANGES
  2 +production:
  3 + adapter: postgresql
  4 + encoding: unicode
  5 + database: noosfero
  6 + host: <%= node['peers']['database'] %>
  7 + user: noosfero
... ...
cookbooks/noosfero/templates/nginx.conf.erb 0 → 100644
... ... @@ -0,0 +1,31 @@
  1 +upstream noosfero {
  2 +<% (1..(`nproc`.strip.to_i)).each do |p| %>
  3 + server 127.0.0.1:<%= 9000 + p - 1 %> fail_timeout=10s;
  4 +<% end %>
  5 +}
  6 +
  7 +server {
  8 + listen *:8080;
  9 + server_name <%= node['config']['external_hostname'] %>;
  10 +
  11 + access_log /var/log/nginx/noosfero.access.log;
  12 + error_log /var/log/nginx/noosfero.error.log;
  13 +
  14 + root /usr/lib/noosfero/public;
  15 + location /social/ {
  16 + alias /usr/lib/noosfero/public/;
  17 + try_files $uri @noosfero_proxy;
  18 + }
  19 + try_files $uri @noosfero_proxy;
  20 +
  21 + location @noosfero_proxy {
  22 + proxy_pass http://noosfero;
  23 + proxy_read_timeout 90;
  24 + proxy_connect_timeout 90;
  25 + proxy_redirect off;
  26 + proxy_set_header Host $host;
  27 + proxy_set_header X-Real-IP $remote_addr;
  28 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  29 + }
  30 +
  31 +}
... ...
cookbooks/noosfero/templates/thin.yml.erb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +---
  2 +chdir: /usr/lib/noosfero
  3 +environment: production
  4 +address: 127.0.0.1
  5 +port: 9000
  6 +timeout: 30
  7 +log: log/thin.log
  8 +pid: tmp/pids/thin.pid
  9 +max_conns: 1024
  10 +max_persistent_conns: 512
  11 +require: []
  12 +wait: 30
  13 +daemonize: true
  14 +servers: <%= `nproc`.strip %>
  15 +prefix: /social
... ...
cookbooks/postgresql/recipes/noosfero.rb 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +execute 'createuser:noosfero' do
  2 + command 'createuser noosfero'
  3 + user 'postgres'
  4 + only_if do
  5 + `sudo -u postgres -i psql --quiet --tuples-only -c "select count(*) from pg_user where usename = 'noosfero';"`.strip.to_i == 0
  6 + end
  7 +end
  8 +
  9 +execute 'createdb:noosfero' do
  10 + command 'createdb --owner=noosfero noosfero'
  11 + user 'postgres'
  12 + only_if do
  13 + `sudo -u postgres -i psql --quiet --tuples-only -c "select count(1) from pg_database where datname = 'noosfero';"`.strip.to_i == 0
  14 + end
  15 +end
  16 +
  17 +
... ...
cookbooks/postgresql/templates/centos/pg_hba.conf.erb
... ... @@ -9,3 +9,4 @@ host all all ::1/128 ident
9 9 # TYPE DATABASE USER ADDRESS METHOD
10 10 host colab colab <%= node['peers']['integration'] %>/32 trust
11 11 host gitlab gitlab <%= node['peers']['integration'] %>/32 trust
  12 +host noosfero noosfero <%= node['peers']['social'] %>/32 trust
... ...
test/colab_test.sh
... ... @@ -29,4 +29,8 @@ test_reverse_proxy_gitlab() {
29 29 assertTrue 'Reverse proxy for gitlab' "curl --header 'Host: softwarepublico.dev' http://$integration/gitlab/public/projects | grep -i '<meta.*gitlab.*>'"
30 30 }
31 31  
  32 +test_reverse_proxy_noosfero() {
  33 + assertTrue 'Reverse proxy for noosfero' "curl --header 'Host: softwarepublico.dev' http://$integration/social/search/people | grep -i '<meta.*noosfero.*>'"
  34 +}
  35 +
32 36 load_shunit2
... ...
test/noosfero_test.sh 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +. $(dirname $0)/test_helper.sh
  2 +
  3 +test_database_connectivity() {
  4 + assertTrue 'noosfero database connectivity' 'run_on social psql -h database -U noosfero < /dev/null'
  5 +}
  6 +
  7 +test_noosfero_running() {
  8 + assertTrue 'Noosfero running' 'run_on social pgrep -u noosfero -f thin'
  9 +}
  10 +
  11 +test_noosfero_on_subdir() {
  12 + local meta="$(run_on social curl --fail http://localhost:9000/social | sed -e '/noosfero:root/ !d; s/^\s*//')"
  13 + assertEquals '<meta property="noosfero:root" content="/social"/>' "$meta"
  14 +}
  15 +
  16 +test_reverse_proxy_noosfero() {
  17 + local meta="$(run_on social curl-host softwarepublico.dev http://localhost:8080/social | sed -e '/noosfero:root/ !d; s/^\s*//')"
  18 + assertEquals '<meta property="noosfero:root" content="/social"/>' "$meta"
  19 +}
  20 +
  21 +test_reverse_proxy_static_files() {
  22 + local content_type="$(curl-host softwarepublico.dev --head http://$social:8080/social/images/noosfero-network.png | grep-header Content-Type)"
  23 + assertEquals "Content-Type: image/png" "$content_type"
  24 +}
  25 +
  26 +
  27 +load_shunit2
... ...
test/postgresql_test.sh
... ... @@ -12,5 +12,9 @@ test_gitlab_database_created() {
12 12 assertTrue 'gitlab database created in PostgreSQL' 'run_on database sudo -u postgres -i psql gitlab < /dev/null'
13 13 }
14 14  
  15 +test_noosfero_database_created() {
  16 + assertTrue 'noosfero database created in PostgreSQL' 'run_on database sudo -u postgres -i psql noosfero < /dev/null'
  17 +}
  18 +
15 19 load_shunit2
16 20  
... ...