Commit 32519fe4dda74d70f13943c5567d0930ba6833d2

Authored by Thiago Ribeiro
2 parents 8877960e 0897a8cc

Merge branch 'noosfero_private_token' into 'master'

Noosfero private token

See merge request !43
cookbooks/colab/recipes/default.rb
... ... @@ -96,20 +96,52 @@ execute 'create-admin-token-gitlab' do
96 96 user 'git'
97 97 end
98 98  
  99 +execute 'create-admin-token-noosfero' do
  100 + user = "admin-noosfero"
  101 + email = "admin-noosfero@example.com"
  102 + password = SecureRandom.random_number.to_s
  103 +
  104 + command "bundle exec rails c production <<EOF
  105 + user = User.create(login: \'#{user}\', email: \'#{email}\', password: \'#{password}\', password_confirmation: \'#{password}\')
  106 + user.activate
  107 + user.generate_private_token_if_not_exist
  108 + Environment.default.add_admin user.person
  109 + exit
  110 + "
  111 +
  112 + user_exist = lambda do
  113 + Dir.chdir '/usr/lib/noosfero' do
  114 + `RAILS_ENV=production bundle exec rails runner \"puts User.find_by_identifier(\'admin-noosdero\').nil?\"`.strip
  115 + end
  116 + end
  117 +
  118 + not_if {user_exist.call == "false"}
  119 +
  120 + cwd '/usr/lib/noosfero'
  121 + user 'noosfero'
  122 +end
  123 +
99 124 template '/etc/colab/settings.d/01-apps.yaml' do
100 125 owner 'root'
101 126 group 'colab'
102 127 mode 0640
103 128 notifies :restart, 'service[colab]'
104 129  
105   - get_private_token = lambda do
  130 + get_gitlab_private_token = lambda do
106 131 Dir.chdir '/usr/lib/gitlab' do
107 132 `sudo -u git RAILS_ENV=production bundle exec rails runner \"puts User.find_by_name(\'admin-gitlab\').private_token\"`.strip
108 133 end
109 134 end
110 135  
  136 + get_noosfero_private_token = lambda do
  137 + Dir.chdir '/usr/lib/noosfero' do
  138 + `sudo -u noosfero RAILS_ENV=production bundle exec rails runner \"puts User.find_by_name(\'admin-noosfero\').private_token\"`.strip
  139 + end
  140 + end
  141 +
111 142 variables(
112   - :get_private_token => get_private_token
  143 + :get_gitlab_private_token => get_gitlab_private_token,
  144 + :get_noosfero_private_token => get_noosfero_private_token
113 145 )
114 146 end
115 147  
... ...
cookbooks/colab/templates/01-apps.yaml.erb
... ... @@ -2,6 +2,7 @@
2 2 PROXIED_APPS:
3 3 gitlab:
4 4 upstream: 'http://<%= node['peers']['integration'] %>:81/gitlab/'
5   - private_token: '<%= @get_private_token.call %>'
  5 + private_token: '<%= @get_gitlab_private_token.call %>'
6 6 noosfero:
7 7 upstream: 'http://<%= node['peers']['social'] %>:80/social/'
  8 + private_token: '<%= @get_noosfero_private_token.call %>'
... ...
cookbooks/noosfero/recipes/default.rb
... ... @@ -57,14 +57,6 @@ execute &#39;noosfero:migrate&#39; do
57 57 user 'noosfero'
58 58 end
59 59  
60   -execute 'plugins:activate' do
61   - command "RAILS_ENV=production bundle exec rake noosfero:plugins:enable_all"
62   - cwd '/usr/lib/noosfero'
63   - user 'noosfero'
64   - only_if 'bundle exec rake -P | grep enable_all'
65   -end
66   -
67   -
68 60 plugins_spb = [
69 61 'software_communities',
70 62 'gov_user',
... ... @@ -74,10 +66,21 @@ plugins_spb = [
74 66 #FIXME: We did it, because we have to enable each plugin and migrate it separately.
75 67 plugins_spb.each do |plugin|
76 68 execute ('plugins_spb:activate:' + plugin) do
77   - command '/usr/lib/noosfero/script/noosfero-plugin enable ' + plugin +
78   - ' && RAILS_ENV=production SCHEMA=/dev/null bundle exec ' +
79   - 'rake db:migrate'
  69 + command '/usr/lib/noosfero/script/noosfero-plugins enable ' + plugin
80 70 end
  71 +
  72 + execute ('plugins_spb:migrate:' + plugin) do
  73 + command 'RAILS_ENV=production SCHEMA=/dev/null bundle exec rake db:migrate'
  74 + cwd '/usr/lib/noosfero'
  75 + user 'noosfero'
  76 + end
  77 +end
  78 +
  79 +execute 'plugins:activate' do
  80 + command "RAILS_ENV=production bundle exec rake noosfero:plugins:enable_all"
  81 + cwd '/usr/lib/noosfero'
  82 + user 'noosfero'
  83 + only_if 'bundle exec rake -P | grep enable_all'
81 84 end
82 85  
83 86 execute 'theme:enable' do
... ... @@ -89,7 +92,7 @@ execute &#39;software:create_licenses&#39; do
89 92 command 'sudo -u noosfero bundle exec rake software:create_licenses RAILS_ENV=production'
90 93 end
91 94  
92   -template '/etc/noosfero/unicorn.rb' do
  95 +cookbook_file '/etc/noosfero/unicorn.rb' do
93 96 owner 'root'; group 'root'; mode 0644
94 97 notifies :restart, 'service[noosfero]'
95 98 end
... ...