Commit 5063224a77188c41768b039730cb67ce4895e24a
Exists in
master
and in
79 other branches
Merge branch 'noosfero-token'
This implements creating an user in the Noosfero dabatase, an grabbing its API key for use in the Colab Noosfero plugin
Showing
8 changed files
with
58 additions
and
7 deletions
Show diff stats
Rakefile
@@ -136,6 +136,7 @@ task :bootstrap_common => 'config/local/ssh_config' | @@ -136,6 +136,7 @@ task :bootstrap_common => 'config/local/ssh_config' | ||
136 | 136 | ||
137 | unless ENV['nodeps'] | 137 | unless ENV['nodeps'] |
138 | task 'converge:integration' => 'converge:database' | 138 | task 'converge:integration' => 'converge:database' |
139 | + task 'converge:integration' => 'converge:social' | ||
139 | task 'converge:social' => 'converge:database' | 140 | task 'converge:social' => 'converge:database' |
140 | end | 141 | end |
141 | 142 |
cookbooks/colab/recipes/default.rb
@@ -148,6 +148,10 @@ template '/etc/colab/plugins.d/noosfero.py' do | @@ -148,6 +148,10 @@ template '/etc/colab/plugins.d/noosfero.py' do | ||
148 | group 'colab' | 148 | group 'colab' |
149 | mode 0640 | 149 | mode 0640 |
150 | notifies :restart, 'service[colab]' | 150 | notifies :restart, 'service[colab]' |
151 | + get_private_token = lambda do | ||
152 | + `psql --tuples-only --host database --user colab -c "select private_token from users where login = 'admin-noosfero'" noosfero`.strip | ||
153 | + end | ||
154 | + variables(:get_private_token => get_private_token) | ||
151 | end | 155 | end |
152 | 156 | ||
153 | template '/etc/colab/plugins.d/spb.py' do | 157 | template '/etc/colab/plugins.d/spb.py' do |
cookbooks/colab/templates/noosfero.py.erb
@@ -10,6 +10,8 @@ verbose_name = 'Noosfero Plugin' | @@ -10,6 +10,8 @@ verbose_name = 'Noosfero Plugin' | ||
10 | 10 | ||
11 | upstream = 'http://<%= node['peers']['social'] %>:80/social/' | 11 | upstream = 'http://<%= node['peers']['social'] %>:80/social/' |
12 | 12 | ||
13 | +private_token = '<%= @get_private_token.call %>' | ||
14 | + | ||
13 | urls = { | 15 | urls = { |
14 | 'include': 'colab_noosfero.urls', | 16 | 'include': 'colab_noosfero.urls', |
15 | 'namespace': 'noosfero', # TODO: do not allow to change namespace | 17 | 'namespace': 'noosfero', # TODO: do not allow to change namespace |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +#!/usr/bin/env ruby | ||
2 | + | ||
3 | +login = ARGV[0] | ||
4 | +email = ARGV[1] | ||
5 | +password = SecureRandom.random_number.to_s | ||
6 | + | ||
7 | +user = User.find_by_login(login) | ||
8 | +exit(0) if user | ||
9 | + | ||
10 | +user = User.create!( | ||
11 | + login: login, | ||
12 | + email: email, | ||
13 | + password: password, | ||
14 | + password_confirmation: password | ||
15 | +) | ||
16 | +user.activate | ||
17 | +user.generate_private_token_if_not_exist |
cookbooks/noosfero/recipes/default.rb
@@ -51,17 +51,24 @@ execute 'plugins:enable' do | @@ -51,17 +51,24 @@ execute 'plugins:enable' do | ||
51 | command '/usr/lib/noosfero/script/noosfero-plugins enable ' + plugins.join(' ') | 51 | command '/usr/lib/noosfero/script/noosfero-plugins enable ' + plugins.join(' ') |
52 | end | 52 | end |
53 | 53 | ||
54 | +plugins_spb = [ | ||
55 | + 'software_communities', | ||
56 | + 'gov_user', | ||
57 | + 'spb_migrations', | ||
58 | +] | ||
59 | + | ||
60 | +# HACK disable plugins_spb before migrating | ||
61 | +# FIXME fix the plugins to not depend on other pugins | ||
62 | +execute 'noosfero:plugins_spb:disable' do | ||
63 | + command '/usr/lib/noosfero/script/noosfero-plugins disable ' + plugins_spb.join(' ') | ||
64 | +end | ||
65 | + | ||
54 | execute 'noosfero:migrate' do | 66 | execute 'noosfero:migrate' do |
55 | command 'RAILS_ENV=production SCHEMA=/dev/null bundle exec rake db:migrate' | 67 | command 'RAILS_ENV=production SCHEMA=/dev/null bundle exec rake db:migrate' |
56 | cwd '/usr/lib/noosfero' | 68 | cwd '/usr/lib/noosfero' |
57 | user 'noosfero' | 69 | user 'noosfero' |
58 | end | 70 | end |
59 | 71 | ||
60 | -plugins_spb = [ | ||
61 | - 'software_communities', | ||
62 | - 'gov_user', | ||
63 | - 'spb_migrations', | ||
64 | -] | ||
65 | 72 | ||
66 | #FIXME: We did it, because we have to enable each plugin and migrate it separately. | 73 | #FIXME: We did it, because we have to enable each plugin and migrate it separately. |
67 | plugins_spb.each do |plugin| | 74 | plugins_spb.each do |plugin| |
@@ -127,6 +134,21 @@ cookbook_file '/usr/lib/noosfero/config/noosfero.yml' do | @@ -127,6 +134,21 @@ cookbook_file '/usr/lib/noosfero/config/noosfero.yml' do | ||
127 | source 'noosfero.yml' | 134 | source 'noosfero.yml' |
128 | notifies :restart, 'service[noosfero]' | 135 | notifies :restart, 'service[noosfero]' |
129 | end | 136 | end |
137 | + | ||
138 | +cookbook_file "/usr/local/bin/noosfero-create-api-user" do | ||
139 | + mode 0755 | ||
140 | +end | ||
141 | + | ||
142 | +execute 'create-admin-token-noosfero' do | ||
143 | + command [ | ||
144 | + "RAILS_ENV=production bundle exec rails runner", | ||
145 | + "/usr/local/bin/noosfero-create-api-user", | ||
146 | + "admin-noosfero", # username | ||
147 | + "noosfero@localhost.localdomain", # email | ||
148 | + ].join(' ') | ||
149 | + cwd '/usr/lib/noosfero' | ||
150 | + user 'noosfero' | ||
151 | +end | ||
130 | ############################################### | 152 | ############################################### |
131 | # SELinux: permission to access static files noosfero | 153 | # SELinux: permission to access static files noosfero |
132 | ################################################ | 154 | ################################################ |
cookbooks/postgresql/recipes/noosfero.rb
cookbooks/postgresql/templates/centos/pg_hba.conf.erb
@@ -10,3 +10,4 @@ host all all ::1/128 ident | @@ -10,3 +10,4 @@ host all all ::1/128 ident | ||
10 | host colab colab <%= node['peers']['integration'] %>/32 trust | 10 | host colab colab <%= node['peers']['integration'] %>/32 trust |
11 | host gitlab gitlab <%= node['peers']['integration'] %>/32 trust | 11 | host gitlab gitlab <%= node['peers']['integration'] %>/32 trust |
12 | host noosfero noosfero <%= node['peers']['social'] %>/32 trust | 12 | host noosfero noosfero <%= node['peers']['social'] %>/32 trust |
13 | +host noosfero colab <%= node['peers']['integration'] %>/32 trust |
roles/database_server.rb
@@ -3,7 +3,7 @@ description 'Database server' | @@ -3,7 +3,7 @@ description 'Database server' | ||
3 | run_list *[ | 3 | run_list *[ |
4 | 'recipe[postgresql]', | 4 | 'recipe[postgresql]', |
5 | 'recipe[redis]', | 5 | 'recipe[redis]', |
6 | - 'recipe[postgresql::colab]', | ||
7 | - 'recipe[postgresql::gitlab]', | 6 | + 'recipe[postgresql::colab]', # must come before the other apps |
8 | 'recipe[postgresql::noosfero]', | 7 | 'recipe[postgresql::noosfero]', |
8 | + 'recipe[postgresql::gitlab]', | ||
9 | ] | 9 | ] |