Commit 064023e49718558286de994411609ff25aecbc81
Committed by
Thiago Ribeiro
1 parent
9b82b2e5
Exists in
master
and in
54 other branches
Create noosfero-admin and get this private_token
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Thiago Ribeiro <thiagitosouza@gmail.com>
Showing
2 changed files
with
36 additions
and
3 deletions
Show diff stats
cookbooks/colab/recipes/default.rb
| @@ -96,20 +96,52 @@ execute 'create-admin-token-gitlab' do | @@ -96,20 +96,52 @@ execute 'create-admin-token-gitlab' do | ||
| 96 | user 'git' | 96 | user 'git' |
| 97 | end | 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 | template '/etc/colab/settings.d/01-apps.yaml' do | 124 | template '/etc/colab/settings.d/01-apps.yaml' do |
| 100 | owner 'root' | 125 | owner 'root' |
| 101 | group 'colab' | 126 | group 'colab' |
| 102 | mode 0640 | 127 | mode 0640 |
| 103 | notifies :restart, 'service[colab]' | 128 | notifies :restart, 'service[colab]' |
| 104 | 129 | ||
| 105 | - get_private_token = lambda do | 130 | + get_gitlab_private_token = lambda do |
| 106 | Dir.chdir '/usr/lib/gitlab' do | 131 | Dir.chdir '/usr/lib/gitlab' do |
| 107 | `sudo -u git RAILS_ENV=production bundle exec rails runner \"puts User.find_by_name(\'admin-gitlab\').private_token\"`.strip | 132 | `sudo -u git RAILS_ENV=production bundle exec rails runner \"puts User.find_by_name(\'admin-gitlab\').private_token\"`.strip |
| 108 | end | 133 | end |
| 109 | end | 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 | variables( | 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 | end | 146 | end |
| 115 | 147 |
cookbooks/colab/templates/01-apps.yaml.erb
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | PROXIED_APPS: | 2 | PROXIED_APPS: |
| 3 | gitlab: | 3 | gitlab: |
| 4 | upstream: 'http://<%= node['peers']['integration'] %>:81/gitlab/' | 4 | upstream: 'http://<%= node['peers']['integration'] %>:81/gitlab/' |
| 5 | - private_token: '<%= @get_private_token.call %>' | 5 | + private_token: '<%= @get_gitlab_private_token.call %>' |
| 6 | noosfero: | 6 | noosfero: |
| 7 | upstream: 'http://<%= node['peers']['social'] %>:80/social/' | 7 | upstream: 'http://<%= node['peers']['social'] %>:80/social/' |
| 8 | + private_token: '<%= @get_noosfero_private_token.call %>' |