Commit 1c4bfc4d463012bd5ddae64554c8f9bb36035fe6

Authored by Lucas Moura
Committed by Luciano Prestes
1 parent 0d8a9ab3

Create admin on both colab and gitlab

In order to make gitlab indexing work on colab, it is necesary to get the private token from an admin user. Therefore, it is necessary to create an admin user on both colab and gitlab.

Signed-off-by: Lucas Moura  <lucas.moura128@gmail.com>
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
cookbooks/colab/recipes/default.rb
... ... @@ -100,3 +100,11 @@ service &#39;colab&#39; do
100 100 action [:enable, :start]
101 101 supports :restart => true
102 102 end
  103 +
  104 +execute 'create token-admin' do
  105 + user = "admin-gitlab"
  106 + email = "admin-gitlab@admin.com"
  107 + password = SecureRandom.random_number.to_s
  108 +
  109 + command "echo \"from colab.accounts.models import User; User.objects.create_superuser(\'#{user}\', \'#{email}\', \'#{password}\')\" | colab-admin shell"
  110 +end
... ...
cookbooks/gitlab/recipes/default.rb
... ... @@ -95,3 +95,19 @@ execute &#39;selinux-gitlab&#39; do
95 95 command 'selinux-install-module /etc/selinux/local/gitlab.te'
96 96 action :nothing
97 97 end
  98 +
  99 +execute 'admin-token' do
  100 + user = "admin-gitlab"
  101 + email = "admin-gitlab@admin.com"
  102 + password = SecureRandom.random_number.to_s
  103 +
  104 + command "bundle exec rails c production << EOF
  105 + user = User.create(name: \'#{name}\', username: \'#{name}\', email: \'#{email}\', password: \'#{password}\')
  106 + user.admin = true
  107 + user.save
  108 + exit
  109 + EOF"
  110 +
  111 + cwd '/usr/lib/gitlab'
  112 + user 'git'
  113 +end
... ...