From 765d523585fb4d2415d031a2ca574c7c7a224652 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Fri, 13 Jan 2017 10:38:42 -0500 Subject: [PATCH 1/2] Expose Mattermost host on external url This commit adds an option to configure a Mattermost host url in case its not on the same omnibus install. --- CHANGELOG.md | 1 + files/gitlab-config-template/gitlab.rb.template | 5 +++++ files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb | 7 +++++-- spec/chef/recipes/gitlab-rails_spec.rb | 9 +++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 932d40b03..7e698302f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ omnibus-gitlab repository. - Allow users to specify an initial shared runner registration token - Update Mattermost to version 3.6 - Include Prometheus and Node Exporter, off by default +- Let uses expose Mattermost host if installed on other server 8.15.0 diff --git a/files/gitlab-config-template/gitlab.rb.template b/files/gitlab-config-template/gitlab.rb.template index 6c806670c..b44a49d48 100644 --- a/files/gitlab-config-template/gitlab.rb.template +++ b/files/gitlab-config-template/gitlab.rb.template @@ -137,6 +137,11 @@ external_url 'GENERATED_EXTERNAL_URL' # gitlab_rails['lfs_enabled'] = true # gitlab_rails['lfs_storage_path'] = "/mnt/storage/lfs-objects" +### GitLab Mattermost +###! These settings are void if Mattermost is installed on the same omnibus +###! install +# gitlab_rails['mattermost_host'] = "https://mattermost.example.com" + ### LDAP Settings ###! Docs: https://docs.gitlab.com/omnibus/settings/ldap.html ###! **Be careful not to break the indentation in the ldap_servers block. It is diff --git a/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb b/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb index dc5208c91..3c743f03d 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb @@ -229,6 +229,9 @@ templatesymlink "Create a gitlab.yml and create a symlink to Rails root" do owner "root" group "root" mode "0644" + + mattermost_host = Gitlab['mattermost_external_url'] || node['gitlab']['gitlab-rails']['mattermost_host'] + variables( node['gitlab']['gitlab-rails'].to_hash.merge( gitlab_ci_all_broken_builds: node['gitlab']['gitlab-ci']['gitlab_ci_all_broken_builds'], @@ -237,8 +240,8 @@ templatesymlink "Create a gitlab.yml and create a symlink to Rails root" do git_annex_enabled: node['gitlab']['gitlab-shell']['git_annex_enabled'], pages_external_http: node['gitlab']['gitlab-pages']['external_http'], pages_external_https: node['gitlab']['gitlab-pages']['external_https'], - mattermost_host: Gitlab['mattermost_external_url'], - mattermost_enabled: node['gitlab']['mattermost']['enable'] + mattermost_host: mattermost_host, + mattermost_enabled: node['gitlab']['mattermost']['enable'] || !mattermost_host.nil? ) ) restarts dependent_services diff --git a/spec/chef/recipes/gitlab-rails_spec.rb b/spec/chef/recipes/gitlab-rails_spec.rb index 3539219ba..c5743b231 100644 --- a/spec/chef/recipes/gitlab-rails_spec.rb +++ b/spec/chef/recipes/gitlab-rails_spec.rb @@ -118,6 +118,15 @@ describe 'gitlab::gitlab-rails' do with_content(/mattermost:\s+enabled: false\s+host:\s+/) end end + + context 'mattermost on another server' do + it 'sets the mattermost host' do + stub_gitlab_rb(gitlab_rails: { mattermost_host: 'http://my.host.com' }) + + expect(chef_run).to render_file('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml'). + with_content(/mattermost:\s+enabled: true\s+host: http:\/\/my.host.com\s+/) + end + end end end -- GitLab From b5821e75e3f178644e606479170552179d97b7f0 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Fri, 13 Jan 2017 10:59:32 -0500 Subject: [PATCH 2/2] Add test where both values are set --- spec/chef/recipes/gitlab-rails_spec.rb | 35 +++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/spec/chef/recipes/gitlab-rails_spec.rb b/spec/chef/recipes/gitlab-rails_spec.rb index c5743b231..efcf148bc 100644 --- a/spec/chef/recipes/gitlab-rails_spec.rb +++ b/spec/chef/recipes/gitlab-rails_spec.rb @@ -126,6 +126,17 @@ describe 'gitlab::gitlab-rails' do expect(chef_run).to render_file('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml'). with_content(/mattermost:\s+enabled: true\s+host: http:\/\/my.host.com\s+/) end + + context 'values set twice' do + it 'sets the mattermost external url' do + stub_gitlab_rb(mattermost: { enable: true }, + mattermost_external_url: 'http://my.url.com', + gitlab_rails: { mattermost_host: 'http://do.not/setme' }) + + expect(chef_run).to render_file('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml'). + with_content(/mattermost:\s+enabled: true\s+host: http:\/\/my.url.com\s+/) + end + end end end end @@ -178,10 +189,10 @@ describe 'gitlab::gitlab-rails' do it 'creates the template' do expect(chef_run).to create_template('/var/opt/gitlab/gitlab-rails/etc/database.yml') .with( - owner: 'root', - group: 'root', - mode: '0644', - ) + owner: 'root', + group: 'root', + mode: '0644', + ) expect(chef_run).to render_file('/var/opt/gitlab/gitlab-rails/etc/database.yml').with_content(/host: \'\/var\/opt\/gitlab\/postgresql\'/) expect(chef_run).to render_file('/var/opt/gitlab/gitlab-rails/etc/database.yml').with_content(/database: gitlabhq_production/) end @@ -264,10 +275,10 @@ describe 'gitlab::gitlab-rails' do it 'creates the template' do expect(chef_run).to create_template('/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret') .with( - owner: 'root', - group: 'root', - mode: '0644', - ) + owner: 'root', + group: 'root', + mode: '0644', + ) end it 'template triggers notifications' do @@ -300,10 +311,10 @@ describe 'gitlab::gitlab-rails' do it 'uses the correct owner and permissions' do expect(chef_run).to create_template('/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret') .with( - owner: 'root', - group: 'root', - mode: '0644', - ) + owner: 'root', + group: 'root', + mode: '0644', + ) end it 'template triggers notifications' do -- GitLab