Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitlab_rails['ldap_servers'] question #367

Closed
famfop opened this issue Nov 20, 2020 · 1 comment
Closed

gitlab_rails['ldap_servers'] question #367

famfop opened this issue Nov 20, 2020 · 1 comment

Comments

@famfop
Copy link

famfop commented Nov 20, 2020

I'm trying to fill the template with my node's configuration. I've stumbled upon the gitlab_rails['ldap_servers'] configuration which confuses me. I use hiera to fill in the template, which is easy for simple 'variables' but the ldap_servers key has multiple lines which may subsequently be templated, too.
The relevant part of my template so far, which I wish to exchange for your great template, looks as follows:

 gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' # remember to close this block with 'EOS' below
   main: # 'main' is the GitLab 'provider ID' of this LDAP server
     label: <%= @gitlab_rails['ldap_servers']['label'] %>
     host: <%= @gitlab_rails['ldap_servers']['host'] %>
     port: <%= @gitlab_rails['ldap_servers']['port'] %>
     uid: <%= @gitlab_rails['ldap_servers']['uid'] %>
     method: <%= @gitlab_rails['ldap_servers']['method'] %> # "tls" or "ssl" or "plain"
     bind_dn: <%= @gitlab_rails['ldap_servers']['bind_dn'] %>
     password: <%= @gitlab_rails['ldap_servers']['password'] %>
     active_directory: <%= @gitlab_rails['ldap_servers']['active_directory'] %>
     allow_username_or_email_login: <%= @gitlab_rails['ldap_servers']['allow_username_or_email_login'] %>
     block_auto_created_users: false
     base: <%= @gitlab_rails['ldap_servers']['base'] %>
     <% if gitlab_rails['ldap_servers'].has_key? 'user_filter' -%>
     user_filter: <%= @gitlab_rails['ldap_servers']['user_filter'] %>
     <% else -%>
     user_filter: ''
     <% end -%>
     username: <%= @gitlab_rails['ldap_servers']['username'] %>
     email:    <%= @gitlab_rails['ldap_servers']['email'] %>

     # If no full name could be found at the attribute specified for `name`,
     # the full name is determined using the attributes specified for
     # `first_name` and `last_name`.
     name:       <%= @gitlab_rails['ldap_servers']['name'] %>
     first_name: 'givenName'
     last_name:  'sn'

     ## EE only
     <% if gitlab_rails['ldap_servers'].has_key? 'group_base' -%>
     group_base: <%= @gitlab_rails['ldap_servers']['group_base'] %>
     <% else -%>
     group_base: ''
     <% end -%>
     admin_group: ''
     <% if gitlab_rails['ldap_servers'].has_key? 'sync_ssh_keys' -%>
     sync_ssh_keys: <%= @gitlab_rails['ldap_servers']['sync_ssh_keys'] %>
     <% end -%>
EOS

How can I accomplish the same with hiera (edit: using your template...)? I am willing to set each ldap_servers-part as its own block - if there is no nicer way possible -, too, but I am not familiar enough to understand how to do it with hiera. Could you please provide me with a simple example? It does not necessarily need to set all of the above settings, just for me to get me started.

EDIT2: This question is obviously quite general and not only restricted to ldap_servers. also gitlab_rails['omniauth_providers'] is a similar case, where I was setting each parameter independently.

On second thought, I feel like it would be nice to add those (special) multi-line-settings explicitly in the template, such that subsequent parameters may be set more consistently defined in a hiera file.

@famfop
Copy link
Author

famfop commented Jan 7, 2021

Sorry, I did not notice it says in the README already.

@famfop famfop closed this as completed Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant