Vendor the external cookbooks

Knife-Zero doesn't include Berkshelf support, so vendoring everything in
the repo is convenient again
This commit is contained in:
Greg Karékinian
2019-10-13 19:17:42 +02:00
parent f4bfe31ac1
commit a32f34b408
1245 changed files with 100630 additions and 0 deletions

View File

@@ -0,0 +1 @@
~FC016

257
cookbooks/git/CHANGELOG.md Normal file
View File

@@ -0,0 +1,257 @@
# git Cookbook CHANGELOG
This file is used to list changes made in each version of the git cookbook.
## 6.0.0 (2017-02-14)
- Fail on deprecations is now enabled so we're fully Chef 13 compatible
- Define the chefspec matchers properly
- Remove the legacy platform mappings that fail on Chef 13
- Improve the test cookbook / integration tests
- Convert config LWRP to a custom resource and make it fully idempotent
- Require Chef 12.5 or later
## 5.0.2 (2017-01-18)
- Remove arch for the metadata
- Avoid deprecation warning during testing
- respond_to?(:chef_version) for < 12.6 compat
## 5.0.1 (2016-09-15)
- Clarify we require Chef 12.1 or later
## 5.0.0 (2016-09-02)
- Require Chef 12 or later
- Don't depend on the windows cookbook since windows_package is built into Chef 12
- Updates for testing
## v4.6.0 (2016-07-05)
- Added support for compiling git on suse
- Added the ability to pass a new group property to the config provider
- Documented the git_config provider
- Added the tar package on RHEL/Fedora for source installs as some minimal installs lack this package
- Added suse, opensuse, and opensuseleap as supported platforms in the metadata
- Switched to inspec for testing
- Switched to cookstyle for Ruby linting
- Added Travis integration testing of Debian 7/8
## v4.5.0 (2016-04-28)
- Update git versions to 2.8.1
## v4.4.1 (2016-03-31)
- PR #95 support 32 bit and 64 bit installs on windows @smurawski
## v4.4.0 (2016-03-23)
- PR #93 bump to latest git @ksubrama
## v4.3.7 (2016-02-03)
- PR #90 port node[git][server][export_all] to true/false @scalp42
- PR #89 make attributes more wrapper friendly @scalp42
- Update testing deps + rubocop fixes
- README fix @zverulacis
## v4.3.6 (2016-01-25)
- Windows fixes
## v4.3.5 (2015-12-15)
- Fixed installation on Windows nodes
- Removed the last of the Chef 10 compatibility code
- Added up to date contributing and testing docs
- Updated test deps in the Gemfile
- Removed test kitchen digital ocean config
- Test with kitchen-docker in Travis CI
- Removed uncessary windows cookbook entry from the Berksfile
- Added the chef standard rubocop.yml file and resolved all warnings
- Added chefignore file
- Removed bin dir
- Added maintainers.md and maintainers.toml files
- Added travis and supermarket version badges to the readme
## v4.3.4 (2015-09-06)
- Fixing package_id on OSX
- Adding 2.5.1 data for Windows
## v4.3.3 (2015-07-27)
- # 76: Use checksum keyname instead of value in source recipe
## v4.3.2 (2015-07-27)
- Fixing up Windows provider (issue #73)
- Supporting changes to source_prefix in source provider (#62)
## v4.3.1 (2015-07-23)
- Fixing up osx_dmg_source_url
## v4.3.0 (2015-07-20)
- Removing references to node attributes from provider code
- Name-spacing of client resource property names
- Addition of windows recipe
- Creation of package recipe
## v4.2.4 (2015-07-19)
- Fixing source provider selection bug from 4.2.3
## v4.2.3 (2015-07-18)
- mac_os_x provider mapping
- various rubocops
## v4.2.2 (2015-04-23)
- Fix up action in Chef::Resource::GitService
- Adding matchers
## v4.2.1 (2015-04-17)
- Fixing Chef 11 support.
- Adding provider mapping file
## v4.2.0 (2015-04-15)
- Converting recipes to resources.
- Keeping recipe interface for backwards compat
## v4.1.0 (2014-12-23)
- Fixing windows package checksums
- Various test coverage additions
## v4.0.2 (2014-04-23)
- [COOK-4482] - Add FreeBSD support for installing git client
## v4.0.0 (2014-03-18)
- [COOK-4397] Only use_inline_resources on Chef 11
## v3.1.0 (2014-03-12)
- [COOK-4392] - Cleanup git_config LWRP
## v3.0.0 (2014-02-28)
[COOK-4387] Add git_config type [COOK-4388] Fix up rubocops [COOK-4390] Add integration tests for default and server suites
## v2.10.0 (2014-02-25)
- [COOK-4146] - wrong dependency in git::source for rhel 6
- [COOK-3947] - Git cookbook adds itself to the path every run
## v2.9.0
Updating to depend on cookbook yum ~> 3 Fixing style to pass rubocop Updating test scaffolding
## v2.8.4
fixing metadata version error. locking to 3.0
## v2.8.1
Locking yum dependency to '< 3'
## v2.8.0
### Bug
- [COOK-3433] - git::server does not correctly set git-daemon's base-path on Debian
## v2.7.0
### Bug
- **[COOK-3624](https://tickets.chef.io/browse/COOK-3624)** - Don't restart `xinetd` on each Chef client run
- **[COOK-3482](https://tickets.chef.io/browse/COOK-3482)** - Force git to add itself to the current process' PATH
### New Feature
- **[COOK-3223](https://tickets.chef.io/browse/COOK-3223)** - Support Omnios and SmartOS package installs
## v2.6.0
### Improvement
- **[COOK-3193](https://tickets.chef.io/browse/COOK-3193)** - Add proper debian packages
## v2.5.2
### Bug
- [COOK-2813]: Fix bad string interpolation in source recipe
## v2.5.0
- Relax runit version constraint (now depend on 1.0+).
## v2.4.0
- [COOK-2734] - update git versions
## v2.3.0
- [COOK-2385] - update git::server for `runit_service` resource support
## v2.2.0
- [COOK-2303] - git::server support for RHEL `platform_family`
## v2.1.4
- [COOK-2110] - initial test-kitchen support (only available in GitHub repository)
- [COOK-2253] - pin runit dependency
## v2.1.2
- [COOK-2043] - install git on ubuntu 12.04 not git-core
## v2.1.0
The repository didn't have pushed commits, and so the following changes from earlier-than-latest versions wouldn't be available on the community site. We're releasing 2.1.0 to correct this.
- [COOK-1943] - Update to git 1.8.0
- [COOK-2020] - Add setup option attributes to Git Windows package install
## v2.0.0
This version uses `platform_family` attribute, making the cookbook incompatible with older versions of Chef/Ohai, hence the major version bump.
- [COOK-1668] - git cookbook fails to run due to bad `platform_family` call
- [COOK-1759] - git::source needs additional package for rhel `platform_family`
## v1.1.2
- [COOK-2020] - Add setup option attributes to Git Windows package install
## v1.1.0
- [COOK-1943] - Update to git 1.8.0
## v1.0.2
- [COOK-1537] - add recipe for source installation
## v1.0.0
- [COOK-1152] - Add support for Mac OS X
- [COOK-1112] - Add support for Windows
## v0.10.0
- [COOK-853] - Git client installation on CentOS
## v0.9.0
- Current public release

View File

@@ -0,0 +1,2 @@
Please refer to
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD

View File

@@ -0,0 +1,15 @@
<!-- This is a generated file. Please do not edit directly -->
# Maintainers
This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.
# Project Maintainer
* [Tim Smith](https://github.com/tas50)
# Maintainers
* [Jennifer Davis](https://github.com/sigje)
* [Tim Smith](https://github.com/tas50)
* [Thom May](https://github.com/thommay)

161
cookbooks/git/README.md Normal file
View File

@@ -0,0 +1,161 @@
# Git Cookbook
[![Build Status](https://travis-ci.org/chef-cookbooks/git.svg?branch=master)](https://travis-ci.org/chef-cookbooks/git) [![Cookbook Version](https://img.shields.io/cookbook/v/git.svg)](https://supermarket.chef.io/cookbooks/git)
Installs git_client from package or source. Optionally sets up a git service under xinetd.
## Scope
This cookbook is concerned with the Git SCM utility. It does not address ecosystem tooling or related projects.
## Requirements
### Platforms
The following platforms have been tested with Test Kitchen:
```
|---------------+-------|
| centos-6 | X |
|---------------+-------|
| centos-7 | X |
|---------------+-------|
| fedora | X |
|---------------+-------|
| debian-7 | X |
|---------------+-------|
| debian-8 | X |
|---------------+-------|
| ubuntu-14.04 | X |
|---------------+-------|
| ubuntu-16.04 | X |
|---------------+-------|
| openSUSE 13.2 | X |
|---------------+-------|
| openSUSE Leap | X |
|---------------+-------|
```
### Chef
- Chef 12.5+
### Cookbooks
- depends 'build-essential' - For compiling from source
- depends 'dmg' - For macOS Support
- depends 'yum-epel' - For older RHEL platform_family support
## Usage
Add `git::default`, `git::source` or `git::windows` to your run_list OR add `depends 'git', '~> 4.3'` to your cookbook's metadata.rb. include_recipe one of the recipes from your cookbook OR use the git_client resource directly, the same way you'd use core Chef resources (file, template, directory, package, etc).
## Resources Overview
- `git_client`: Manages a Git client installation on a machine. Acts as a singleton when using the (default) package provider. Source provider available as well.
- `git_service`: Sets up a Git service via xinetd. WARNING: This is insecure and will probably be removed in the future
- `git_config`: Sets up Git configuration on a node.
### git_client
The `git_client` resource manages the installation of a Git client on a machine.
#### Example
```ruby
git_client 'default' do
action :install
end
```
### git_config
The `git_config` resource manages the configuration of Git client on a machine.
#### Example
```ruby
git_config 'url.https://github.com/.insteadOf' do
value 'git://github.com/'
scope 'system'
options '--add'
end
```
#### Properties
Currently, there are distinct sets of resource properties, used by the providers for source, package, macos, and windows.
# used by linux package providers
- `package_name` - Package name to install on Linux machines. Defaults to a calculated value based on platform.
- `package_version` - Defaults to nil.
- `package_action` - Defaults to `:install`
# used by source providers
- `source_prefix` - Defaults to '/usr/local'
- `source_url` - Defaults to a calculated URL based on source_version
- `source_version` - Defaults to 2.7.4
- `source_use_pcre` - configure option for build. Defaults to false
- `source_checksum` - Defaults to a known value for the 2.7.4 source tarball
# used by OSX package providers
- `osx_dmg_app_name` - Defaults to 'git-2.7.1-intel-universal-mavericks'
- `osx_dmg_package_id` - Defaults to 'GitOSX.Installer.git271.git.pkg'
- `osx_dmg_volumes_dir` - Defaults to 'Git 2.7.1 Mavericks Intel Universal'
- `osx_dmg_url` - Defaults to Sourceforge
- `osx_dmg_checksum` - Defaults to the value for 2.7.1
# used by the Windows package providers
- `windows_display_name` - Windows display name
- `windows_package_url` - Defaults to the Internet
- `windows_package_checksum` - Defaults to the value for 2.7.4
## Recipes
This cookbook ships with ready to use, attribute driven recipes that utilize the `git_client` and `git_service` resources. As of cookbook 4.x, they utilize the same attributes layout scheme from the 3.x. Due to some overlap, it is currently impossible to simultaneously install the Git client as a package and from source by using the "manipulate a the node attributes and run a recipe" technique. If you need both, you'll need to utilize the git_client resource in a recipe.
## Attributes
### Windows
- `node['git']['version']` - git version to install
- `node['git']['url']` - URL to git package
- `node['git']['checksum']` - package SHA256 checksum
- `node['git']['display_name']` - `windows_package` resource Display Name (makes the package install idempotent)
### Mac OS X
- `node['git']['osx_dmg']['url']` - URL to git package
- `node['git']['osx_dmg']['checksum']` - package SHA256 checksum
### Linux
- `node['git']['prefix']` - git install directory
- `node['git']['version']` - git version to install
- `node['git']['url']` - URL to git tarball
- `node['git']['checksum']` - tarball SHA256 checksum
- `node['git']['use_pcre']` - if true, builds git with PCRE enabled
## License & Authors
- Author:: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io))
- Author:: Sean OMeara ([sean@sean.io](mailto:sean@sean.io))
- Copyright:: 2009-2017, Chef Software, Inc.
```
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.
```

View File

@@ -0,0 +1,47 @@
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
# Cookbook:: git
# Attributes:: default
#
# Copyright:: 2008-2016, Chef Software, Inc.
#
# 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.
case node['platform_family']
when 'windows'
default['git']['version'] = '2.8.1'
if node['kernel']['machine'] == 'x86_64'
default['git']['architecture'] = '64'
default['git']['checksum'] = '5e5283990cc91d1e9bd0858f8411e7d0afb70ce26e23680252fb4869288c7cfb'
else
default['git']['architecture'] = '32'
default['git']['checksum'] = '17418c2e507243b9c98db161e9e5e8041d958b93ce6078530569b8edaec6b8a4'
end
default['git']['url'] = 'https://github.com/git-for-windows/git/releases/download/v%{version}.windows.1/Git-%{version}-%{architecture}-bit.exe'
default['git']['display_name'] = "Git version #{node['git']['version']}"
when 'mac_os_x'
default['git']['osx_dmg']['app_name'] = 'git-2.8.1-intel-universal-mavericks'
default['git']['osx_dmg']['volumes_dir'] = 'Git 2.8.1 Mavericks Intel Universal'
default['git']['osx_dmg']['package_id'] = 'GitOSX.Installer.git281Universal.git.pkg'
default['git']['osx_dmg']['url'] = 'http://sourceforge.net/projects/git-osx-installer/files/git-2.8.1-intel-universal-mavericks.dmg/download'
default['git']['osx_dmg']['checksum'] = 'c2912895a1e2018d9be4c646765d511f7c82e0114275505dbd13d1ac70c62023'
else
default['git']['prefix'] = '/usr/local'
default['git']['version'] = '2.8.1'
default['git']['url'] = 'https://nodeload.github.com/git/git/tar.gz/v%{version}'
default['git']['checksum'] = 'e08503ecaf5d3ac10c40f22871c996a392256c8d038d16f52ebf974cba29ae42'
default['git']['use_pcre'] = false
end
default['git']['server']['base_path'] = '/srv/git'
default['git']['server']['export_all'] = true

View File

@@ -0,0 +1,48 @@
module GitCookbook
module Helpers
# linux packages default to distro offering
def parsed_package_name
return new_resource.package_name if new_resource.package_name
return 'git-core' if node['platform'] == 'ubuntu' && node['platform_version'].to_f < 10.10
return 'developer/versioning/git' if node['platform'] == 'omnios'
return 'scmgit' if node['platform'] == 'smartos'
'git'
end
def parsed_package_version
return new_resource.package_version if new_resource.package_version
end
# source
def parsed_source_url
return new_resource.source_url if new_resource.source_url
"https://nodeload.github.com/git/git/tar.gz/v#{new_resource.source_version}"
end
def parsed_source_checksum
return new_resource.source_checksum if new_resource.source_checksum
'8d53703d75890c03e26a915c7af3b7b98d8cfb94382f685a9bcbee1eeaec47b4' # 2.7.4 tarball
end
# windows
def parsed_windows_display_name
return new_resource.windows_display_name if new_resource.windows_display_name
"Git version #{parsed_windows_package_version}"
end
def parsed_windows_package_version
return new_resource.windows_package_version if new_resource.windows_package_version
'2.7.4'
end
def parsed_windows_package_url
return new_resource.windows_package_url if new_resource.windows_package_url
"https://github.com/git-for-windows/git/releases/download/v%#{parsed_windows_package_version}.windows.1/Git-%#{parsed_windows_package_version}-32-bit.exe"
end
def parsed_windows_package_checksum
return new_resource.windows_package_checksum if new_resource.windows_package_checksum
'49601d5102df249d6f866ecfa1eea68eb5672acc1dbb7e4051099e792f6da5fc'
end
end
end

View File

@@ -0,0 +1,16 @@
if defined?(ChefSpec)
ChefSpec.define_matcher(:git_client)
ChefSpec.define_matcher(:git_service)
def set_git_config(resource_name) # rubocop:disable Style/AccessorMethodName
ChefSpec::Matchers::ResourceMatcher.new(:git_config, :set, resource_name)
end
def install_git_client(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:git_client, :install, resource_name)
end
def install_git_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:git_service, :install, resource_name)
end
end

View File

@@ -0,0 +1,13 @@
class Chef
class Provider
class GitClient < Chef::Provider::LWRPBase
use_inline_resources
def whyrun_supported?
true
end
include GitCookbook::Helpers
end
end
end

View File

@@ -0,0 +1,26 @@
class Chef
class Provider
class GitClient
class Osx < Chef::Provider::GitClient
include Chef::DSL::IncludeRecipe
provides :git_client, os: 'mac_os_x'
action :install do
dmg_package 'GitOSX-Installer' do
app new_resource.osx_dmg_app_name
package_id new_resource.osx_dmg_package_id
volumes_dir new_resource.osx_dmg_volumes_dir
source new_resource.osx_dmg_url
checksum new_resource.osx_dmg_checksum
type 'pkg'
action :install
end
end
action :delete do
end
end
end
end
end

View File

@@ -0,0 +1,27 @@
class Chef
class Provider
class GitClient
class Package < Chef::Provider::GitClient
include Chef::DSL::IncludeRecipe
provides :git_client, os: 'linux'
action :install do
# FIXME: rhel 5
include_recipe 'yum-epel' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5
# Software installation
package "#{new_resource.name} :create #{parsed_package_name}" do
package_name parsed_package_name
version parsed_package_version
action new_resource.package_action
action :install
end
end
action :delete do
end
end
end
end
end

View File

@@ -0,0 +1,66 @@
class Chef
class Provider
class GitClient
class Source < Chef::Provider::GitClient
include Chef::DSL::IncludeRecipe
action :install do
return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" unless platform_family?('rhel', 'suse', 'fedora', 'debian')
include_recipe 'build-essential'
include_recipe 'yum-epel' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5
# move this to attributes.
case node['platform_family']
when 'fedora'
pkgs = %w(tar openssl-devel libcurl-devel expat-devel perl-ExtUtils-MakeMaker)
when 'rhel'
case node['platform_version'].to_i
when 5
pkgs = %w(tar expat-devel gettext-devel curl-devel openssl-devel zlib-devel)
pkgs += %w( pcre-devel ) if new_resource.source_use_pcre
when 6, 7
pkgs = %w(tar expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel)
pkgs += %w( pcre-devel ) if new_resource.source_use_pcre
else
pkgs = %w(expat-devel gettext-devel curl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel) if node['platform'] == 'amazon'
pkgs += %w( pcre-devel ) if new_resource.source_use_pcre
end
when 'debian'
pkgs = %w(libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev)
pkgs += %w( libpcre3-dev ) if new_resource.source_use_pcre
when 'suse'
pkgs = %w(tar libcurl-devel libexpat-devel gettext-tools zlib-devel libopenssl-devel)
pkgs += %w( libpcre2-devel ) if new_resource.source_use_pcre
end
package pkgs
# reduce line-noise-eyness
remote_file "#{Chef::Config['file_cache_path']}/git-#{new_resource.source_version}.tar.gz" do
source parsed_source_url # helpers.rb
checksum parsed_source_checksum # helpers.rb
mode '0644'
not_if "test -f #{Chef::Config['file_cache_path']}/git-#{new_resource.source_version}.tar.gz"
end
# reduce line-noise-eyness
execute "Extracting and Building Git #{new_resource.source_version} from Source" do
cwd Chef::Config['file_cache_path']
additional_make_params = ''
additional_make_params += 'USE_LIBPCRE=1' if new_resource.source_use_pcre
command <<-COMMAND
(mkdir git-#{new_resource.source_version} && tar -zxf git-#{new_resource.source_version}.tar.gz -C git-#{new_resource.source_version} --strip-components 1)
(cd git-#{new_resource.source_version} && make prefix=#{new_resource.source_prefix} #{additional_make_params} install)
COMMAND
not_if "git --version | grep #{new_resource.source_version}"
not_if "#{new_resource.source_prefix}/bin/git --version | grep #{new_resource.source_version}"
end
end
action :delete do
end
end
end
end
end

View File

@@ -0,0 +1,49 @@
# frozen_string_literal: true
class Chef
class Provider
class GitClient
class Windows < Chef::Provider::GitClient
include Chef::DSL::IncludeRecipe
provides :git_client, os: 'windows'
action :install do
windows_package parsed_windows_display_name do
action :install
source parsed_windows_package_url
checksum parsed_windows_package_checksum
installer_type :inno
end
# Git is installed to Program Files (x86) on 64-bit machines and
# 'Program Files' on 32-bit machines
PROGRAM_FILES = if node['git']['architecture'] == '32'
ENV['ProgramFiles(x86)'] || ENV['ProgramFiles']
else
ENV['ProgramW6432'] || ENV['ProgramFiles']
end
GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd".freeze
# COOK-3482 - windows_path resource doesn't change the current process
# environment variables. Therefore, git won't actually be on the PATH
# until the next chef-client run
ruby_block 'Add Git Path' do
block do
ENV['PATH'] += ";#{GIT_PATH}"
end
not_if { ENV['PATH'] =~ /GIT_PATH/ }
action :nothing
end
windows_path GIT_PATH do
notifies :create, 'ruby_block[Add Git Path]', :immediately
action :add
end
end
action :delete do
end
end
end
end
end

View File

@@ -0,0 +1,57 @@
class Chef
class Provider
class GitClient < Chef::Provider::LWRPBase
use_inline_resources
def whyrun_supported?
true
end
include Chef::DSL::IncludeRecipe
include GitCookbook::Helpers
provides :git_service, os: 'linux'
action :create do
return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if node['platform'] == 'windows'
include_recipe 'git'
directory new_resource.service_base_path do
owner 'root'
group 'root'
mode '0755'
end
case node['platform_family']
when 'debian'
package 'xinetd'
when 'rhel'
package 'git-daemon'
else
log 'Platform requires setting up a git daemon service script.'
log "Hint: /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=#{new_resource.service_base_path}"
return
end
template '/etc/xinetd.d/git' do
backup false
source 'git-xinetd.d.erb'
owner 'root'
group 'root'
mode '0644'
variables(
git_daemon_binary: value_for_platform_family(
'debian' => '/usr/lib/git-core/git-daemon',
'rhel' => '/usr/libexec/git-core/git-daemon'
)
)
end
service 'xinetd' do
action [:enable, :restart]
end
end
end
end
end

View File

@@ -0,0 +1,55 @@
class Chef
class Provider
class GitClient < Chef::Provider::LWRPBase
use_inline_resources
def whyrun_supported?
true
end
include Chef::DSL::IncludeRecipe
include GitCookbook::Helpers
action :create do
return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if node['platform'] == 'windows'
include_recipe 'git'
directory new_resource.service_base_path do
owner 'root'
group 'root'
mode '0755'
end
case node['platform_family']
when 'debian'
package 'xinetd'
when 'rhel'
package 'git-daemon'
else
log 'Platform requires setting up a git daemon service script.'
log "Hint: /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=#{new_resource.service_base_path}"
return
end
template '/etc/xinetd.d/git' do
backup false
source 'git-xinetd.d.erb'
owner 'root'
group 'root'
mode '0644'
variables(
git_daemon_binary: value_for_platform_family(
'debian' => '/usr/lib/git-core/git-daemon',
'rhel' => '/usr/libexec/git-core/git-daemon'
)
)
end
service 'xinetd' do
action [:enable, :restart]
end
end
end
end
end

View File

@@ -0,0 +1,38 @@
require 'chef/resource/lwrp_base'
class Chef
class Resource
class GitClient < Chef::Resource::LWRPBase
self.resource_name = :git_client
actions :install, :remove
default_action :install
provides :git_client
# used by source providers
attribute :source_checksum, kind_of: String, default: nil
attribute :source_prefix, kind_of: String, default: '/usr/local'
attribute :source_url, kind_of: String, default: nil
attribute :source_use_pcre, kind_of: [TrueClass, FalseClass], default: false
attribute :source_version, kind_of: String, default: nil
# used by linux package providers
attribute :package_name, kind_of: String, default: nil
attribute :package_version, kind_of: String, default: nil
attribute :package_action, kind_of: Symbol, default: :install
# used by OSX package providers
attribute :osx_dmg_app_name, kind_of: String, default: 'git-2.7.1-intel-universal-mavericks'
attribute :osx_dmg_package_id, kind_of: String, default: 'GitOSX.Installer.git271.git.pkg'
attribute :osx_dmg_volumes_dir, kind_of: String, default: 'Git 2.7.1 Mavericks Intel Universal'
attribute :osx_dmg_url, kind_of: String, default: 'http://sourceforge.net/projects/git-osx-installer/files/git-2.7.1-intel-universal-mavericks.dmg/download'
attribute :osx_dmg_checksum, kind_of: String, default: '260b32e8877eb72d07807b26163aeec42e2d98c350f32051ab1ff0cc33626440' # 2.7.1
# used by Windows providers
attribute :windows_display_name, kind_of: String, default: nil
attribute :windows_package_url, kind_of: String, default: nil
attribute :windows_package_checksum, kind_of: String, default: nil
attribute :windows_package_version, kind_of: String, default: nil
end
end
end

View File

@@ -0,0 +1,16 @@
require 'chef/resource/lwrp_base'
class Chef
class Resource
class GitService < Chef::Resource::LWRPBase
self.resource_name = :git_service
actions :create
default_action :create
provides :git_service
# used by the service xinetd provider
attribute :service_base_path, kind_of: String, default: '/srv/git'
end
end
end

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,19 @@
#
# Cookbook:: git
# Recipe:: default
#
# Copyright:: 2008-2016, Chef Software, Inc.
#
# 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.
include_recipe 'git::package'

View File

@@ -0,0 +1,37 @@
#
# Cookbook:: git
# Recipe:: package
#
# Copyright:: 2008-2016, Chef Software, Inc.
#
# 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.
case node['platform']
when 'mac_os_x'
# FIXME: The resource has three distinct groups of properties used in
# different providers... should we make multiple resource types instead?
git_client 'default' do
osx_dmg_app_name node['git']['osx_dmg']['app_name']
osx_dmg_package_id node['git']['osx_dmg']['package_id']
osx_dmg_volumes_dir node['git']['osx_dmg']['volumes_dir']
osx_dmg_url node['git']['osx_dmg']['url']
osx_dmg_checksum node['git']['osx_dmg']['checksum']
action :install
end
when 'windows'
include_recipe 'git::windows'
else
git_client 'default' do
action :install
end
end

View File

@@ -0,0 +1,22 @@
#
# Cookbook:: git
# Recipe:: server
#
# Copyright:: 2009-2016, Chef Software, Inc.
#
# 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.
git_service 'default' do
service_base_path node['git']['server']['base_path']
action :create
end

View File

@@ -0,0 +1,28 @@
#
# Cookbook:: git
# Recipe:: source
#
# Copyright:: 2012-2016, Brian Flad, Fletcher Nichol
#
# 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.
# drive version from node attributes
git_client 'default' do
provider Chef::Provider::GitClient::Source
source_checksum node['git']['checksum']
source_prefix node['git']['prefix']
source_url format(node['git']['url'], version: node['git']['version'])
source_use_pcre node['git']['use_pcre']
source_version node['git']['version']
action :install
end

View File

@@ -0,0 +1,24 @@
#
# Cookbook:: git
# Recipe:: windows
#
# Copyright:: 2008-2016, Chef Software, Inc.
#
# 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.
git_client 'default' do
windows_display_name node['git']['display_name']
windows_package_url format(node['git']['url'], version: node['git']['version'], architecture: node['git']['architecture'])
windows_package_checksum node['git']['checksum']
action :install
end

View File

@@ -0,0 +1,49 @@
property :key, String, name_attribute: true
property :value, String
property :scope, equal_to: %w(local global system), default: 'global', desired_state: false
property :path, String, desired_state: false
property :user, String, desired_state: false
property :group, String, desired_state: false
property :options, String, desired_state: false
attr_accessor :exists
require 'mixlib/shellout'
def initialize(*args)
super
@run_context.include_recipe 'git'
end
load_current_value do
cmd_env = user ? { 'USER' => user, 'HOME' => ::Dir.home(user) } : nil
config_vals = Mixlib::ShellOut.new("git config --get --#{scope} #{key}", user: user, group: group, cwd: path, env: cmd_env)
config_vals.run_command
if config_vals.stdout.empty?
value nil
else
value config_vals.stdout.chomp
end
end
action :set do
converge_if_changed do
execute "#{config_cmd} #{new_resource.key} \"#{new_resource.value}\" #{new_resource.options}".rstrip do
cwd new_resource.path
user new_resource.user
group new_resource.group
environment cmd_env
end
end
end
action_class.class_eval do
def config_cmd
"git config --#{new_resource.scope}"
end
def cmd_env
new_resource.user ? { 'USER' => new_resource.user, 'HOME' => ::Dir.home(new_resource.user) } : nil
end
end

View File

@@ -0,0 +1,10 @@
service git
{
disable = no
socket_type = stream
wait = no
user = nobody
server = <%= @git_daemon_binary %>
server_args = --base-path=<%= node["git"]["server"]["base_path"] %> <%= node['git']['server']['export_all'] ? '--export-all' : nil %> --syslog --inetd --verbose
log_on_failure += USERID
}

View File

@@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd -tt ./main

View File

@@ -0,0 +1,3 @@
#!/bin/sh
exec 2>&1
exec /usr/bin/git daemon <%= node['git']['server']['export_all'] ? '--export-all' : nil %> --user=nobody --group=daemon --syslog --base-path=<%= node["git"]["server"]["base_path"] %> <%= node["git"]["server"]["base_path"] %>