From c619706f514b1ca0a56cc76ecd4a274301aedaef Mon Sep 17 00:00:00 2001 From: Lucas Moura Date: Thu, 11 Jun 2015 11:43:18 -0300 Subject: [PATCH] Creating colab user for gitlab indexing --- cookbooks/colab/recipes/default.rb | 16 ++++++++++++---- cookbooks/colab/templates/admin-gitlab.json.erb | 13 +++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 cookbooks/colab/templates/admin-gitlab.json.erb diff --git a/cookbooks/colab/recipes/default.rb b/cookbooks/colab/recipes/default.rb index 4b82f77..cb18939 100644 --- a/cookbooks/colab/recipes/default.rb +++ b/cookbooks/colab/recipes/default.rb @@ -53,12 +53,20 @@ template '/etc/colab/settings.d/00-database.yaml' do notifies :restart, 'service[colab]' end -execute 'create-admin-token-colab' do - user = "admin-gitlab" - email = "admin-gitlab@admin.com" +template '/tmp/admin-gitlab.json' do + password = SecureRandom.random_number.to_s - command "echo \"from colab.accounts.models import User; User.objects.create_superuser(\'#{user}\', \'#{email}\', \'#{password}\')\" | colab-admin shell" + variables( + :password => password + ) +end + +execute 'create-admin-token-colab' do + command "colab-admin loaddata admin-gitlab.json" + + cwd '/tmp' + user 'root' end execute 'create-admin-token-gitlab' do diff --git a/cookbooks/colab/templates/admin-gitlab.json.erb b/cookbooks/colab/templates/admin-gitlab.json.erb new file mode 100644 index 0000000..6830d17 --- /dev/null +++ b/cookbooks/colab/templates/admin-gitlab.json.erb @@ -0,0 +1,13 @@ +[ + { + "model": "accounts.user", + "fields": { + "username": "admin-gitlab", + "first_name": "Admin", + "last_name": "Gitlab", + "email": "admin-gitlab@admin.com", + "password": "<%= @password %>", + "modified": "2015-06-11 14:22:00.332432+00" + } + } +] \ No newline at end of file -- libgit2 0.21.2