Skip to content

Chef cookbook to set up a basic git repository container to be accesed via ssh.

Notifications You must be signed in to change notification settings

bcs-de/git-ssh-server-cookbook

 
 

Repository files navigation

Description

Set up a basic git repository container to be accesed via ssh.

Requirements

Platform:

  • Amazon
  • Arch
  • CentOS
  • Debian
  • Fedora
  • Redhat
  • Scientific
  • Ubuntu

Cookbooks:

  • git

Attributes

Attribute Description Default
node['git-ssh-server']['base_path'] Git repository base path calculated
node['git-ssh-server']['user'] System user used to manage the repositories "git"
node['git-ssh-server']['group'] System group used to manage the repositories "git"
node['git-ssh-server']['shell'] Git user shell "/usr/bin/git-shell"
node['git-ssh-server']['hostname'] Machine hostname, used only in the README template calculated

Recipes

git-ssh-server::default

Configures a git repository container

Resources

git_ssh_server_bare[name]

Creates a new bare repostiory.

git_ssh_server_bare actions

  • create: Creates a bare respository (default).

git_ssh_server_bare attributes

Attribute Description Default
name Repository name resource name
base_path Git repository base path node['git-ssh-server']['base_path']
add_update_server_hook Create the post-update-hook with exec git update-server-info [true/false] false

git_ssh_server_bare example

git_ssh_server_bare 'library1'

git_ssh_server_bare 'webapp1' do
  add_update_server_hook true
end

git_ssh_server_ssh_key[keyname]

Grant access to an SSH key to all the repositories.

git_ssh_server_ssh_key actions

  • add: adds an SSH key (default).

git_ssh_server_ssh_key attributes

Attribute Description Default
keyname SSH key name resource name
key SSH RSA public key value required
keytype SSH RSA key type "ssh-rsa"
base_path Git repository base path node['git-ssh-server']['base_path']

git_ssh_server_ssh_key example

# the SSH public key from your ~/.ssh/*.pub file
git_ssh_server_ssh_key 'battle-laptop' do
  key 'AAAAB3NzaC1yc2EAAAABIwAAAQEA[...]'
end

Usage Example

Including in a Cookbook Recipe

include_recipe 'git-ssh-server::default' # or put it in your run_list

git_ssh_server_bare 'my-library-one'
git_ssh_server_bare 'my-library-two'
git_ssh_server_bare 'my-webapp'

git_ssh_server_ssh_key 'my-laptop-key' do
  key 'AAAAB3NzaC1yc2EAAAABIwAAAQEAv8lgaVb1BtGTLZG2cwc8WQF/X2Mxcuu/UPxN3yT6VQuFa6zl/LbSMND9OADS6ULw6p0hnWPnRDA8rSJvdcYO7pTSJOclScEuIMm4Nx8c3uhfePF/o39QPhH3WAyee/SFDay430Y11W5ZuOXuZ7Wb2PQEPUaQxs9k/MUHjIIcNLS7qG/FP5IGAb0df9KkAnSGXTgZ/Z9Xh+4mAkoBkXIr99oZsphF/PcxcVQfq4V6dTg81LUPLfaSj6U8gXmjRpRYNgk5uEdci7loKDmv1EPKhzwsJIEp9wxpAJqel5sezHaYN5w3zplbr7UY1+YuEBn2jnYhzbdBZcVDmL1D5F/G+Q=='
end

git_ssh_server_ssh_key 'another-developer' do
  key 'AAAAB3NzaC1yc2EAAAABIwAAAQEAqFEaEEv9Fx+6Qv8LPoY+e9rsvaARGJJbvc7y2Tl73zoA6rB7VTxqoyV6mhG+ozRiB4i5g5andBCSDjDXPS0ycUQmiR2OrLZDUpf3uUhaeOO1SFjIbUyFdqy1MBkcmkDzBtXJ/qgn/ydUX59lT00AoPY4URVMt13uaI6GCWrsxRFX+Hxk5prVjoUqJQ7iSidXJ9CHksKTamgn3Ywc9w1MMYcegB+NVg0GsHDZMyq1PxFKGtqNS2PriQfoUrva76rolTej2rbnyH9drZZNi8lsxZ/Xi8ObjT68gc3OfswA64DRhQuN+aQT4bBK1xU+2AE88P9L2LSEYkekTzt7CElqrw=='
end

Don't forget to include the git-ssh-server cookbook as a dependency in the metadata.

# metadata.rb
[...]

depends 'git-ssh-server'

Including in the Run List

Another alternative is to include the default recipe in your Run List.

{
  "name": "git.onddo.com",
  [...]
  "run_list": [
    [...]
    "recipe[git-ssh-server]"
  ]
}

Testing

Requirements

  • vagrant
  • berkshelf >= 1.4.0
  • test-kitchen >= 1.0.0.alpha
  • kitchen-vagrant >= 0.10.0

Running the tests

$ kitchen test
$ kitchen verify
[...]

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add_component_x)
  3. Write you change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request using Github

License and Author

Author: Raúl Rodríguez ([email protected])
Author: Xabier de Zuazo ([email protected])
Copyright: Copyright (c) 2013 Onddo Labs, SL. (www.onddo.com)
License: Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Chef cookbook to set up a basic git repository container to be accesed via ssh.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 85.9%
  • Shell 14.1%