From 31bd4a964820e26eec3883696f47595d27662f03 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 6 Feb 2014 14:15:13 +0100 Subject: [PATCH] Create a global .gitconfig for the git user --- files/gitlab-cookbooks/gitlab/attributes/default.rb | 2 ++ files/gitlab-cookbooks/gitlab/recipes/users.rb | 11 ++++++++++- files/gitlab-cookbooks/gitlab/templates/default/gitconfig.erb | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 files/gitlab-cookbooks/gitlab/templates/default/gitconfig.erb diff --git a/files/gitlab-cookbooks/gitlab/attributes/default.rb b/files/gitlab-cookbooks/gitlab/attributes/default.rb index da9ac2b..138d483 100644 --- a/files/gitlab-cookbooks/gitlab/attributes/default.rb +++ b/files/gitlab-cookbooks/gitlab/attributes/default.rb @@ -31,6 +31,8 @@ default['gitlab']['user']['group'] = "git" default['gitlab']['user']['shell'] = "/bin/sh" # The home directory for the chef services user default['gitlab']['user']['home'] = "/var/opt/gitlab" +default['gitlab']['user']['git_user_name'] = "GitLab" +default['gitlab']['user']['git_user_email'] = "gitlab@#{node['fqdn']}" #### diff --git a/files/gitlab-cookbooks/gitlab/recipes/users.rb b/files/gitlab-cookbooks/gitlab/recipes/users.rb index 60cf33e..1dea8f1 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/users.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/users.rb @@ -16,12 +16,21 @@ # gitlab_username = node['gitlab']['user']['username'] +gitlab_home = node['gitlab']['user']['home'] group gitlab_username # Create a user for Chef services to run as user gitlab_username do shell node['gitlab']['user']['shell'] - home node['gitlab']['user']['home'] + home gitlab_home gid gitlab_username end + +template File.join(gitlab_home, ".gitconfig") do + source "gitconfig.erb" + owner gitlab_username + group node['gitlab']['user']['group'] + mode "0644" + variables(node['gitlab']['user'].to_hash) +end diff --git a/files/gitlab-cookbooks/gitlab/templates/default/gitconfig.erb b/files/gitlab-cookbooks/gitlab/templates/default/gitconfig.erb new file mode 100644 index 0000000..8a60edb --- /dev/null +++ b/files/gitlab-cookbooks/gitlab/templates/default/gitconfig.erb @@ -0,0 +1,5 @@ +[user] + name = <%= node['gitlab']['user']['git_user_name'] %> + email = <%= node['gitlab']['user']['git_user_email'] %> +[core] + autocrlf = input -- libgit2 0.21.2