Gitlab CI Not Getting Automatically Authenticated To Connect With Gitlab on Same Machine
I've read somewhere that gitlab omnibus should automatically authenticate Gitlab CI to connect with Gitlab on same machine, in that it won't need to manually create an Application for the callback and app_id and app_secret.
I tried creating a fresh EC2 Ubuntu 14-64 instance. And then bootstrapped it using 'knife bootstrap`. I set this cookbook's node attributes to:
override_attributes(
{
'gitlab_omnibus': {
'external_url': 'http://gitlab.mydomain.com',
'ci_external_url': 'http://ci.gitlab.mydomain.net',
}
}
I also set the DNS of mydomain to resolve for the public IP of the created EC2 instance.
After bootstrapping, everything works fine, in that I can log in gitlab.mydomain.com and that I could create a git project there. However, the ci.gitlab.mydomain.com doesn't automatically authenticate with Gitlab. I had to manually create an Application with proper callback and then configure the node attributes once again and add the following attributes:
'gitlab_ci': {
'gitlab_server': {
'url': 'http://gitlab.mydomain.com',
'app_id': 'SOMEAPPIDGOESHERE',
'app_secret': 'SOMEAPPSECRETGOESHERE'
}
}
I wanted Gitlab CI to auto-authenticate automatically. So after some tries, I found out that after a fresh succesful EC2 bootstrap with just external_url and ci_external_url attributes (and without specifying the url, app_id, app_secret), I just ssh into the instance, and ran sudo gitlab-ctl reconfigure
and Gitlab CI finally automatically authenticates with Gitlab (in that I could now click the button Login with Gitlab
in ci.gitlab.mydomain.com` and that there is already an automatically created Application in Gitlab).
So, I cloned this cookbook git repo, and added another notifies :reconfigure in recipes/default.rb as shown below:
template '/etc/gitlab/gitlab.rb' do
source 'gitlab.rb.erb'
mode '0640'
# Must reconfigure immediately on first install otherwise service will fail to start
if first_install
notifies :reconfigure, 'gitlab_omnibus_service[gitlab]', :immediately
else
notifies :reconfigure, 'gitlab_omnibus_service[gitlab]'
notifies :restart, 'gitlab_omnibus_service[gitlab]'
end
notifies :reconfigure, 'gitlab_omnibus_service[gitlab]' # I added this line
end
Using my custom cloned cookbook, the Gitlab CI now then automatically authenticates with Gitlab on same machine.
I am fairly a beginner with Chef, so I might be missing something trivial.