diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 23f267c7..ab21fd71 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -60,7 +60,7 @@ :lsbdistid => 'debian', :lsbdistcodename => 'jessie', }} - it { is_expected.to contain_file('/etc/gitlab/gitlab.rb') } + describe 'edition = ce' do let(:params) { {:edition => 'ce'} } it { is_expected.to contain_package('gitlab-ce').with_ensure('installed') } @@ -155,8 +155,8 @@ it { is_expected.to contain_file('/etc/gitlab/gitlab.rb') \ .with_content(/^\s*gitlab_rails\['ldap_enabled'\] = true$/) - .with_content(/^\s*gitlab_rails\['ldap_servers'\] = {"main"=>{"label"=>"LDAP", "host"=>"_your_ldap_server", "port"=>(")?389(")?, "uid"=>"sAMAccountName", "method"=>"plain", "bind_dn"=>"_the_full_dn_of_the_user_you_will_bind_with", "password"=>"_the_password_of_the_bind_user", "active_directory"=>true, "allow_username_or_email_login"=>false, "block_auto_created_users"=>false, "base"=>"", "user_filter"=>""}}$/) - .with_content(/^\s*gitlab_rails\['omniauth_providers'\] = \[{"name"=>"google_oauth2", "app_id"=>"YOUR APP ID", "app_secret"=>"YOUR APP SECRET", "args"=>{"access_type"=>"offline", "approval_prompt"=>""}}\]$/) + .with_content(/^\s*gitlab_rails\['ldap_servers'\] = {\"main\"=>{\"active_directory\"=>true, \"allow_username_or_email_login\"=>false, \"base\"=>\"\", \"bind_dn\"=>\"_the_full_dn_of_the_user_you_will_bind_with\", \"block_auto_created_users\"=>false, \"host\"=>\"_your_ldap_server\", \"label\"=>\"LDAP\", \"method\"=>\"plain\", \"password\"=>\"_the_password_of_the_bind_user\", \"port\"=>(")?389(")?, \"uid\"=>\"sAMAccountName\", \"user_filter\"=>\"\"}}$/) + .with_content(/^\s*gitlab_rails\['omniauth_providers'\] = \[{\"app_id\"=>\"YOUR APP ID\", \"app_secret\"=>\"YOUR APP SECRET\", \"args\"=>{\"access_type\"=>\"offline\", \"approval_prompt\"=>\"\"}, \"name\"=>\"google_oauth2\"}\]$/) } end describe 'gitlab_git_http_server with hash value' do diff --git a/templates/gitlab.rb.erb b/templates/gitlab.rb.erb index fe9a25c5..169ff4a0 100644 --- a/templates/gitlab.rb.erb +++ b/templates/gitlab.rb.erb @@ -1,7 +1,19 @@ ## THIS CONFIGURATION IS MANAGED BY PUPPET # for all possible paramters, see: # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template -<%- def decorate(v) +<%- +# As this template is writing a config file based on some hashes and hashes are not meant to be in a certain order, +# We need to ensure that the order of the keys are always outputed in the same order. +# Otherwise puppet will always update(change) the config file. +def sort_nested_hash_inspect(h) + if h.class.name == 'Hash' + "{" + h.sort.map{|key, value| "\"#{key}\"=>#{sort_nested_hash_inspect(value)}"}.join(", ") + "}" + else + h.inspect + end +end + +def decorate(v) if v =~ /\AYAML/ return v elsif v.is_a?(String) @@ -13,7 +25,7 @@ } return "[#{temp.join(',')}]" elsif v.is_a?(Hash) - return v.inspect + return sort_nested_hash_inspect(v) else return v end