Add golang cookbook
Needs updating of ark and git cookbooks
This commit is contained in:
@@ -3,9 +3,8 @@ module GitCookbook
|
||||
# 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'
|
||||
return 'developer/versioning/git' if platform?('smartos')
|
||||
return 'scmgit' if platform?('smartos')
|
||||
'git'
|
||||
end
|
||||
|
||||
@@ -21,7 +20,7 @@ module GitCookbook
|
||||
|
||||
def parsed_source_checksum
|
||||
return new_resource.source_checksum if new_resource.source_checksum
|
||||
'8d53703d75890c03e26a915c7af3b7b98d8cfb94382f685a9bcbee1eeaec47b4' # 2.7.4 tarball
|
||||
'690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a' # 2.17.1 tarball
|
||||
end
|
||||
|
||||
# windows
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
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
|
||||
@@ -1,12 +1,6 @@
|
||||
class Chef
|
||||
class Provider
|
||||
class GitClient < Chef::Provider::LWRPBase
|
||||
use_inline_resources
|
||||
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
include GitCookbook::Helpers
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,20 +2,10 @@ class Chef
|
||||
class Provider
|
||||
class GitClient
|
||||
class Osx < Chef::Provider::GitClient
|
||||
include Chef::DSL::IncludeRecipe
|
||||
|
||||
provides :git_client, os: 'mac_os_x'
|
||||
provides :git_client, platform: '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
|
||||
package 'git'
|
||||
end
|
||||
|
||||
action :delete do
|
||||
|
||||
@@ -2,14 +2,9 @@ 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
|
||||
|
||||
@@ -2,30 +2,16 @@ 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')
|
||||
raise "#{node['platform']} is not supported by the git_client source resource" unless platform_family?('rhel', 'suse', 'fedora', 'debian', 'amazon')
|
||||
|
||||
include_recipe 'build-essential'
|
||||
include_recipe 'yum-epel' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5
|
||||
build_essential 'install compilation tools for git'
|
||||
|
||||
# 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 'rhel', 'fedora', 'amazon'
|
||||
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
|
||||
when 'debian'
|
||||
pkgs = %w(libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev)
|
||||
pkgs += %w( libpcre3-dev ) if new_resource.source_use_pcre
|
||||
@@ -52,7 +38,7 @@ class Chef
|
||||
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
|
||||
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
|
||||
|
||||
@@ -3,8 +3,6 @@ class Chef
|
||||
class Provider
|
||||
class GitClient
|
||||
class Windows < Chef::Provider::GitClient
|
||||
include Chef::DSL::IncludeRecipe
|
||||
|
||||
provides :git_client, os: 'windows'
|
||||
|
||||
action :install do
|
||||
@@ -22,7 +20,7 @@ class Chef
|
||||
else
|
||||
ENV['ProgramW6432'] || ENV['ProgramFiles']
|
||||
end
|
||||
GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd".freeze
|
||||
GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd"
|
||||
|
||||
# COOK-3482 - windows_path resource doesn't change the current process
|
||||
# environment variables. Therefore, git won't actually be on the PATH
|
||||
@@ -36,7 +34,7 @@ class Chef
|
||||
end
|
||||
|
||||
windows_path GIT_PATH do
|
||||
notifies :create, 'ruby_block[Add Git Path]', :immediately
|
||||
notifies :run, 'ruby_block[Add Git Path]', :immediately
|
||||
action :add
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
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'
|
||||
return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if platform?('windows')
|
||||
|
||||
include_recipe 'git'
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
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
|
||||
Reference in New Issue
Block a user