Skip to content

mohitsethi/chef-git-user

Repository files navigation

git_user

Build Status

Description

This cookbook features:

  • A Chef LWRP to configure:
    • git config.name and config.email
    • a git-specific private ssh key
    • known ssh hosts
  • A companion recipe for user::data_bag which adds the aforementioned configuration.

Usage

Include recipe[git_user] in your run_list and git_user resource will become available.

The git_user::data_bag recipe assumes that you're using the user::data_bag recipe from the excellent user cookbook. It lets you configure git-related aspects in user specific data_bags, e.g.

{
  "id"       : "testman",
  "home"     : "/home/testman"
  ...
  "git_user" : {
  	"enabled"    : true,
  	"full_name"  : "Test Man Jr.",
  	"email"      : "[email protected]",
  	"private_key": "ABC123",
  	"known_hosts": ["github.com"]
  }
}

Requirements

Platform

This cookbook has been tested with the following OSes:

  • centos / redhat
  • ubuntu
  • gentoo

Cookbooks

The cookbook has got the following dependencies:

Recipes

default

No-op, does nothing.

data_bag

Processes node['users'] and performs the configuration for the ones whose data_bags enable it, e.g.

{
  "id"        : "ranger",
  ...
  "git_user" : { "enabled": true, "email": "[email protected]" }
}

Resources and Providers

git_user

Actions

Action Description Default
create Creates .gitconfig and/or configures the ssh key and known hosts. Yes

Attributes

Attribute Description Default Value Required
login Name attribute: The login of the user. nil yes
home User's home directory. /home/username or /root no
full_name A value for git config.name username no
email A value for git config.email "username@#{node['fqdn']}" no
private_key A private SSH key to use for git, will be created as /home/username/.ssh/git_user_rsa nil no
known_hosts Hosts which the private_key will be used with [] yes if private_key is specified

Example

git_user 'charlie' do
  private_key get_my_super_secret_key
  known_hosts %w{ github.com bitbucket.org }
end

git_user 'bob' do
  full_name   'Bob McAllister'
  email       '[email protected]'
end

License

Copyright:: Vasily Mikhaylichenko and LxMx.

Licensed under BSD license.

http://opensource.org/licenses/BSD-2-Clause

About

Chef LWRP to configure user git settings and repository access

Resources

Stars

Watchers

Forks

Packages

No packages published