Commit 7ec65795389d533681c4ed79dc7d752598650c56
1 parent
33df6d4c
Exists in
master
and in
90 other branches
Noosfero configuration
There are still a few TODO's
Showing
14 changed files
with
173 additions
and
1 deletions
Show diff stats
Rakefile
config/roles/database_server.rb
config/roles/social_server.rb
cookbooks/colab/templates/01-apps.yaml.erb
... | ... | @@ -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 | ... | ... |
... | ... | @@ -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 | +} | ... | ... |
... | ... | @@ -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 | ... | ... |
... | ... | @@ -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 | ... | ... |
... | ... | @@ -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 | ... | ... |