Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

git-ssh-server (7) Versions 1.0.0

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

Policyfile
Berkshelf
Knife
cookbook 'git-ssh-server', '~> 1.0.0', :supermarket
cookbook 'git-ssh-server', '~> 1.0.0'
knife supermarket install git-ssh-server
knife supermarket download git-ssh-server
README
Dependencies
Changelog
Quality 17%

Git SSH Server Cookbook

Cookbook Version
GitHub Source
Dependency Status
Build Status

Chef cookbook to set up a basic git repository container to be accessed via SSH.

Requirements

Supported Platforms

This cookbook has been tested on the following platforms:

  • Amazon Linux
  • Arch
  • CentOS
  • Debian
  • Fedora
  • FreeBSD
  • OpenSUSE
  • Oracle Linux
  • RedHat
  • Scientific Linux
  • SUSE
  • Ubuntu
  • Windows

Please, let us know if you use it successfully on any other platform.

Required Cookbooks

Required Applications

  • Ruby 1.9.3 or higher.

Attributes

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

Recipes

git-ssh-server::default

Configures a git repository container

Resources

git_ssh_server_bare[name]

Creates a new bare repository.

git_ssh_server_bare Actions

  • create: Creates a bare repository (default).

git_ssh_server_bare Parameters

Parameters Default Description
name resource name Repository name.
base_path calculated Git repository base path.
add_update_server_hook false Create the post-update-hook with exec git update-server-info (true or false).

git_ssh_server_bare Example

git_ssh_server_bare 'library1'

git_ssh_server_bare 'webapp1' do
  add_update_server_hook true
end

Definitions

git_ssh_server_ssh_key[keyname]

Grant access to a SSH key to all the repositories.

git_ssh_server_ssh_key Parameters

Parameters Default Description
keyname resource name SSH key name.
key required SSH RSA public key value.
keytype 'ssh-rsa' SSH RSA key type.
base_path calculated Git repository 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(
    'AAAAB3NzaC1yc2EAAAADAQABAAABAQDjvOJeZHLa15iajIat6YxtDM2BtVwxZ/WMIcGh6NeQB'\
    'I1Nhs4nIpHRCC5bOG4Pg5d6QYaFLDXHx7rHWzprBMi7XuBANGUKESFemByF2DU7hO60/DhA+K'\
    'mzeEkCVIqGTh+G7GFucjNGvJgles7MjkOenIc7Xb+OXKcPdTRpQslwJErsIqb1EfRT+8kZvVn'\
    '9d9RBS9grWkiOz+d+SVU/D6S40st2f4VDE5NHxcA9/U0vT7tLvC+G6lNJ4+w8M1jpvTDosKeq'\
    'yfqQnucf61VWc6ClGh8p88WTSZ081jGB0OkM+nFBsOtzJ+Gmy/N2I+eJGjTykAC7MvLPUsQjA'\
    '0KYsZRL'
  )
end

git_ssh_server_ssh_key 'another-developer' do
  key(
    'AAAAB3NzaC1yc2EAAAADAQABAAABAQC75j5iuOWD2Xqw/hKVoJ32n0r6jRjlBofjtEkFDknZp'\
    'CMG3whdy64FGNvYYgoajLOc/TyhF+ntt/Go3CrasxNhEusnj6HQu57d0nAnnTleDBHLgcCxFW'\
    'QrGTXpop+JziHYXpZHT5bvMV0zfw0C6ezheUnlXlA5+2JNZx3JwhfZqu0L18iwOdWzWbL3zta'\
    'D84l0e030JTyg6SP/feXvM5bnQpySCWnqk6L2yzhXQh3tpg95l/8srSE1tuRwgWx4gW2k0E9x'\
    'gWtDwcx4lsskMdti6vZ/aM4Ll/jTFAO0hmXZEDnsSr0NEuwm/n8jvN9qwHPLBsk2YWf57VPKq'\
    'VQ2rYLx'
  )
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.example.com",
  "[...]": "[...]",
  "run_list": [
    "[...]",
    "recipe[git-ssh-server]"
  ]
}

Testing

See TESTING.md.

ChefSpec Matchers

git_ssh_server_bare(name)

Helper method for locating a git_ssh_server_bare resource in the collection.

resource = chef_run.git_ssh_server_bare(name)
expect(resource).to notify('service[apache2]').to(:reload)

create_git_ssh_server_bare(name)

Assert that the Chef Run creates a bare repository in the Git SSH Server.

expect(chef_run).to create_git_ssh_server_bare(name)

ChefSpec Matchers for the git_ssh_server_ssh_key Definition

To create ChefSpec tests for the git_ssh_server_ssh_key definition, you can use the render_file matcher to check the authorized_keys file content:

it 'allows bob to access git repositories' do
  expect(chef_run).to render_file('/srv/git/.ssh/authorized_keys')
    .with_content(/^ssh-rsa [A-Za-z0-9+\/=]+ bob@acme\.com$/)
end

You can also test against the internal template:

it 'creates /srv/git/.ssh/authorized_keys file' do
  expect(chef_run).to create_template('/srv/git/.ssh/authorized_keys')
end

Contributing

Please do not hesitate to open an issue with any questions or problems.

See CONTRIBUTING.md.

License and Author

Author: Raúl Rodríguez (raul@onddo.com)
Author: Xabier de Zuazo (xabier@zuazo.org)
Contributor: Arnold Krille
Copyright: Copyright (c) 2015, Xabier de Zuazo
Copyright: Copyright (c) 2013 Onddo Labs, SL.
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.

Dependent cookbooks

git >= 2.2.0
ssh_authorized_keys ~> 0.3

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

CHANGELOG for git-ssh-server

This file is used to list changes made in each version of git-ssh-server cookbook.

v1.0.0 (2015-09-10)

  • Breaking changes:

    • Fix all RuboCop offenses:
    • Ruby <= 1.9.2 compatibilty drop.
    • Convert the git_ssh_server_ssh_key resource to a definition using the ssh_authorized_keys cookbook:
    • From the ssh_authorize_key documentation:
    • This definition uses the Accumulator Pattern. This implies that any SSH key added using other methods (such as keys added by hand) will be deleted.
    • This may break resources calling the git_ssh_server_ssh_key resource. They will need to be converted to definitions for the accumulator pattern to work properly.
  • Improvements:

    • Add OpenSUSE support.
    • Add ChefSpec matchers and locators.
    • Fix foodcritic offenses.
    • Update chef links to use chef.io domain.
    • Update contact information and links after migration.
    • metadata: Add source_url and issues_url links.
  • Bug Fixes:

    • Fix CentOS 5 support: fatal: unable to access /home/vagrant/.config/git/config: Permission denied.
  • Documentation:

    • Add LICENSE file.
    • Add license headers to code files.
    • README:
    • Use Parameters instead of Properties.
    • Improve title and description.
    • User markdown tables.
    • Add GitHub badge.
  • Testing:

    • Replace bats tests by Serverspec tests.
    • Integrate should_not gem with the tests.
    • Update the Vagrantfile.
    • Move ChefSpec tests to test/unit.
    • Use ChefSpec::SoloRunner for tests.
    • Add ChefSpec tests for the git_ssh_server_bare resource and the git_ssh_server_ssh_key definition.
    • Update .kitchen.yml platforms.
    • Update some test related files: Gemfile, Guardfile, Rakefile, TESTING.md, ..
    • Add .kitchen.docker.yml file.
    • Integrate kitchen with Travis CI using kitchen-in-travis script.

v0.3.0 (2014-11-16)

  • Activate the post-update hook when the param is true (issue #3, thanks Arnold Krille).
  • git_ssh_server_bare: change user/group in shell_out command.
  • Add FreeBSD support.
  • Add ChefSpec tests for git-ssh-server::default recipe.
  • Enable ChefSpec coverage.
  • providers/bare: ignore FC023 rule.
  • Gemfile:
    • Move test-kitchen gems to :integration group.
    • Fix Illformed requirement in "berkshelf".
  • Add travis.yml file.
  • Test for the update-hook (issue #2, thanks Arnold Krille).
  • Update tests: add Gemfile, Berksfile and Rakefile templates.
  • Update kitchen.yml file.
  • Move test/kitchen/cookbooks to test/cookbooks.
  • README:
    • Split in multiple files.
    • Add multiple badges.
    • Fixes and improvements.

v0.2.0 (2014-01-18)

v0.1.3 (2013-11-17)

  • Fix: bare repositories do not have .git dir.
  • git_ssh_server_bare LWRP notify only when the action is executed.

v0.1.2 (2013-10-28)

  • metadata: provides without square brackets to avoid CHEF-3976.

v0.1.1 (2013-08-15)

  • metadata: Add minimum git cookbook version in depends.
  • Fix git_ssh_server_ssh_key LWRP default action (:add).

v0.1.0 (2013-06-08)

  • Initial release of git-ssh-server.

Collaborator Number Metric
            

1.0.0 failed this metric

Failure: Cookbook has 1 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

1.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

1.0.0 failed this metric

FC066: Ensure chef_version is set in metadata: git-ssh-server/metadata.rb:1
FC069: Ensure standardized license defined in metadata: git-ssh-server/metadata.rb:1
FC072: Metadata should not contain "attribute" keyword: git-ssh-server/metadata.rb:1
FC074: LWRP should use DSL to define resource's default action: git-ssh-server/resources/bare.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric
            

1.0.0 passed this metric

Testing File Metric
            

1.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

1.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number