Add golang cookbook
Needs updating of ark and git cookbooks
This commit is contained in:
parent
217ab471ce
commit
0005f9ab7d
@ -32,12 +32,12 @@ cookbook 'build-essential', '~> 8.2.1'
|
||||
cookbook 'mysql', '~> 8.5.1'
|
||||
# cookbook 'postgresql', '= 7.1.8'
|
||||
cookbook 'apt', '~> 7.3.0'
|
||||
cookbook 'git', '= 6.0.0'
|
||||
cookbook 'git', '>= 6.0.0'
|
||||
cookbook 'hostsfile', '= 2.4.5'
|
||||
cookbook 'ohai', '~> 5.2.5'
|
||||
cookbook 'nodejs', '~> 5.0.0'
|
||||
cookbook 'timezone_iii', '= 1.0.4'
|
||||
cookbook 'ark', '= 3.1.0'
|
||||
cookbook 'ark', '>= 3.1.0'
|
||||
cookbook 'logrotate', '= 2.2.0'
|
||||
cookbook 'openssl', '~> 8.5.5'
|
||||
cookbook 'ntp', '= 3.4.0'
|
||||
@ -51,5 +51,5 @@ cookbook 'ipfs',
|
||||
ref: 'v0.4.1'
|
||||
cookbook 'elasticsearch', '= 4.2.0'
|
||||
cookbook 'java', '~> 4.3.0'
|
||||
|
||||
cookbook 'ulimit', '~> 1.0.0'
|
||||
cookbook 'golang', '~> 4.1.0'
|
||||
|
@ -4,14 +4,15 @@ DEPENDENCIES
|
||||
application_git (= 1.1.0)
|
||||
application_javascript (~> 1.0.0)
|
||||
apt (~> 7.3.0)
|
||||
ark (= 3.1.0)
|
||||
ark (>= 3.1.0)
|
||||
build-essential (~> 8.2.1)
|
||||
chef-sugar (= 3.3.0)
|
||||
compat_resource (= 12.19.0)
|
||||
composer (~> 2.6.1)
|
||||
elasticsearch (= 4.2.0)
|
||||
firewall (~> 2.6.3)
|
||||
git (= 6.0.0)
|
||||
git (>= 6.0.0)
|
||||
golang (~> 4.1.0)
|
||||
homebrew (= 3.0.0)
|
||||
hostname (= 0.4.2)
|
||||
hostsfile (= 2.4.5)
|
||||
@ -67,10 +68,8 @@ GRAPH
|
||||
poise-javascript (~> 1.0)
|
||||
poise-service (~> 1.0)
|
||||
apt (7.3.0)
|
||||
ark (3.1.0)
|
||||
build-essential (>= 0.0.0)
|
||||
ark (5.0.0)
|
||||
seven_zip (>= 0.0.0)
|
||||
windows (>= 0.0.0)
|
||||
build-essential (8.2.1)
|
||||
mingw (>= 1.1)
|
||||
seven_zip (>= 0.0.0)
|
||||
@ -80,7 +79,6 @@ GRAPH
|
||||
apt (>= 0.0.0)
|
||||
php (>= 0.0.0)
|
||||
windows (>= 0.0.0)
|
||||
dmg (4.1.1)
|
||||
elasticsearch (4.2.0)
|
||||
apt (>= 0.0.0)
|
||||
ark (>= 0.0.0)
|
||||
@ -88,10 +86,9 @@ GRAPH
|
||||
yum (>= 0.0.0)
|
||||
firewall (2.6.5)
|
||||
chef-sugar (>= 0.0.0)
|
||||
git (6.0.0)
|
||||
build-essential (>= 0.0.0)
|
||||
dmg (>= 0.0.0)
|
||||
yum-epel (>= 0.0.0)
|
||||
git (10.0.0)
|
||||
golang (4.1.0)
|
||||
ark (~> 5.0)
|
||||
homebrew (3.0.0)
|
||||
hostname (0.4.2)
|
||||
hostsfile (>= 0.0.0)
|
||||
|
@ -1 +0,0 @@
|
||||
~FC016
|
@ -2,6 +2,27 @@
|
||||
|
||||
This file is used to list changes made in each version of the ark cookbook.
|
||||
|
||||
## 5.0.0 (2020-01-02)
|
||||
|
||||
- Require Chef Infra Client 14+ and remove the need for the build_essential dependency - [@tas50](https://github.com/tas50)
|
||||
- Use Ruby classes in resource properties - [@tas50](https://github.com/tas50)
|
||||
- Simplify the platform check logic - [@tas50](https://github.com/tas50)
|
||||
- Remove the .foocritic file - [@tas50](https://github.com/tas50)
|
||||
- Remove long_description and recipe metadata - [@tas50](https://github.com/tas50)
|
||||
- Expand testing - [@tas50](https://github.com/tas50)
|
||||
- Remove Ubuntu 14.04 testing - [@tas50](https://github.com/tas50)
|
||||
|
||||
## 4.0.0 (2018-07-25)
|
||||
|
||||
- Support append_env_path property on Windows, which increases the minimum required Chef release to Chef 13.4
|
||||
|
||||
## 3.1.1 (2018-07-24)
|
||||
|
||||
- Remove ChefSpec matchers since these are autogenerated now
|
||||
- Update specs to the latest platform versions
|
||||
- Remove template out of defaults directory
|
||||
- Remove dependency on the Windows cookbook
|
||||
|
||||
## 3.1.0 (2017-05-06)
|
||||
|
||||
- Ensure the dependencies get installed on Chef 13 Amazon Linux systems
|
||||
|
@ -1,15 +0,0 @@
|
||||
<!-- 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)
|
@ -25,7 +25,7 @@ The `ark` resource will:
|
||||
|
||||
By default, the ark will not run again if the `:path` is not empty. Ark provides many actions to accommodate different use cases, such as `:dump`, `:cherry_pick`, `:put`, and `:install_with_make`.
|
||||
|
||||
At this time ark only handles files available from URLs using the [remote_file](http://docs.chef.io/resource_remote_file.html) provider. It does handle local files using the `file://` protocol.
|
||||
For remote files ark supports URLs using the [remote_file](http://docs.chef.io/resource_remote_file.html) resource. Local files are accessed with the `file://` syntax.
|
||||
|
||||
## Requirements
|
||||
|
||||
@ -36,7 +36,7 @@ At this time ark only handles files available from URLs using the [remote_file](
|
||||
- Fedora
|
||||
- FreeBSD
|
||||
- SmartOS
|
||||
- Mac OS X
|
||||
- macOS
|
||||
- openSUSE / SUSE Linux Enterprises
|
||||
- Windows
|
||||
|
||||
@ -44,13 +44,11 @@ Should work on common Unix/Linux systems with typical userland utilities like ta
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 12.7+
|
||||
- Chef 14+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
- build-essential
|
||||
- seven_zip
|
||||
- windows
|
||||
|
||||
## Attributes
|
||||
|
||||
|
@ -58,7 +58,6 @@ module Ark
|
||||
new_resource.path = defaults.path
|
||||
new_resource.release_file = defaults.release_file
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def set_put_paths
|
||||
new_resource.extension = defaults.extension
|
||||
|
@ -1,44 +0,0 @@
|
||||
|
||||
if defined?(ChefSpec)
|
||||
ChefSpec.define_matcher :ark
|
||||
|
||||
def install_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :install, resource_name)
|
||||
end
|
||||
|
||||
def dump_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :dump, resource_name)
|
||||
end
|
||||
|
||||
def cherry_pick_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :cherry_pick, resource_name)
|
||||
end
|
||||
|
||||
def put_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :put, resource_name)
|
||||
end
|
||||
|
||||
def install_with_make_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :install_with_make, resource_name)
|
||||
end
|
||||
|
||||
def configure_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :configure, resource_name)
|
||||
end
|
||||
|
||||
def setup_py_build_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :setup_py_build, resource_name)
|
||||
end
|
||||
|
||||
def setup_py_install_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :setup_py_install, resource_name)
|
||||
end
|
||||
|
||||
def setup_py_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :setup_py, resource_name)
|
||||
end
|
||||
|
||||
def unzip_ark(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ark, :unzip, resource_name)
|
||||
end
|
||||
end
|
@ -25,9 +25,7 @@ module Ark
|
||||
end
|
||||
|
||||
def sevenzip_command
|
||||
if resource.strip_components <= 0
|
||||
return sevenzip_command_builder(resource.path, 'x')
|
||||
end
|
||||
return sevenzip_command_builder(resource.path, 'x') if resource.strip_components <= 0
|
||||
|
||||
tmpdir = make_temp_directory.tr('/', '\\')
|
||||
cmd = sevenzip_command_builder(tmpdir, 'x')
|
||||
|
File diff suppressed because one or more lines are too long
16
cookbooks/ark/metadata.rb
Normal file
16
cookbooks/ark/metadata.rb
Normal file
@ -0,0 +1,16 @@
|
||||
name 'ark'
|
||||
maintainer 'Chef Software, Inc.'
|
||||
maintainer_email 'cookbooks@chef.io'
|
||||
license 'Apache-2.0'
|
||||
description 'Provides a custom resource for installing runtime artifacts in a predictable fashion'
|
||||
version '5.0.0'
|
||||
|
||||
%w(ubuntu debian redhat centos suse opensuse opensuseleap scientific oracle amazon windows mac_os_x smartos freebsd).each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
depends 'seven_zip' # for windows os
|
||||
|
||||
source_url 'https://github.com/chef-cookbooks/ark'
|
||||
issues_url 'https://github.com/chef-cookbooks/ark/issues'
|
||||
chef_version '>= 14.0'
|
@ -18,6 +18,6 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package node['ark']['package_dependencies'] unless %w(windows mac_os_x).include?(node['platform_family'])
|
||||
package node['ark']['package_dependencies'] unless platform_family?('windows', 'mac_os_x')
|
||||
|
||||
include_recipe 'seven_zip' if node['platform_family'] == 'windows'
|
||||
include_recipe 'seven_zip' if platform_family?('windows')
|
||||
|
@ -83,8 +83,16 @@ action :install do
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# usually on windows there is no central directory with executables where the applications are linked
|
||||
unless node['platform_family'] == 'windows'
|
||||
if platform_family?('windows')
|
||||
# usually on windows there is no central directory with executables where the applications are linked
|
||||
# so ignore has_binaries for now
|
||||
|
||||
# Add to PATH permanently on Windows if append_env_path
|
||||
windows_path "#{new_resource.path}/bin" do
|
||||
action :add
|
||||
only_if { new_resource.append_env_path }
|
||||
end
|
||||
else
|
||||
# symlink binaries
|
||||
new_resource.has_binaries.each do |bin|
|
||||
link ::File.join(new_resource.prefix_bin, ::File.basename(bin)) do
|
||||
|
@ -1,142 +0,0 @@
|
||||
# dmg Cookbook CHANGELOG
|
||||
|
||||
This file is used to list changes made in each version of the dmg cookbook.
|
||||
|
||||
## 4.1.1 (2018-04-06)
|
||||
|
||||
- The dmg_package resource is now included in Chef 14 and this cookbook has been deprecated. We highly recommend updating to Chef 14 so you can use this resource without the need for a cookbook dependency.
|
||||
- Validate the type field in the resource
|
||||
- Remove the now autogenerated ChefSpec matchers
|
||||
|
||||
## 4.1.0 (2017-11-15)
|
||||
|
||||
- Adds allow_untrusted property for older packages that aren't signed
|
||||
- Resolve Chef 14 deprecation warnings
|
||||
- Minor testing updates and cleanup
|
||||
|
||||
## 4.0.0 (2017-04-27)
|
||||
|
||||
- Converted the existing LWRP to a custom resource which increases the required chef-client release to 12.5+
|
||||
- Added Test Kitchen config with private atlas boxes for 10.10 and 10.11
|
||||
- Added a test recipe to installed Tunnelblick
|
||||
- Added an Inspec test to confirm that Tunnelblick actually installs
|
||||
- Remove unused attributes and the entire attributes file
|
||||
- Add a warning if you include the default recipe on your runlist
|
||||
- Update specs to run on 10.12 and against the test recipe since dmg::default is empty and the existing spec tested nothing
|
||||
|
||||
## 3.1.1 (2017-04-11)
|
||||
|
||||
- Cookstyle updates
|
||||
- Test with Local Delivery and not Rake
|
||||
- Update apache2 license string
|
||||
- Remove foodcritic exclusions
|
||||
|
||||
## 3.1.0 (2017-01-18)
|
||||
|
||||
- Fixed pkg,mpkg installation when it was using mounted app name while it was actually mounted under different name for some applications
|
||||
- Cookstyle fixes
|
||||
|
||||
## 3.0.0 (2016-09-06)
|
||||
|
||||
- Add chef_version metadata
|
||||
- Run the specs against a mock of OS X
|
||||
- Testing updates
|
||||
- Require Chef 12+
|
||||
|
||||
## v2.4.0 (2016-04-26)
|
||||
|
||||
- Added support for local .dmg files with the file property. See the readme for details
|
||||
- Resolved all rubocop warnings
|
||||
|
||||
## v2.3.0 (2015-10-20)
|
||||
|
||||
- Add new headers property to the LWRP for custom http headers. See the readme for more information
|
||||
- Removed pivotal tracker example in the readme
|
||||
- Added travis and cookbook version badges to the readme
|
||||
- Added a .foodcritic file to exclude rules
|
||||
- Updated chefignore and .gitignore files
|
||||
- Updated platforms in Test Kitchen
|
||||
- Added standard Rubocop file
|
||||
- Updated Travis to test using ChefDK for the latest deps
|
||||
- Added a Berksfile
|
||||
- Updated contributing and testing docs
|
||||
- Updated Gemfile with the latest testing deps
|
||||
- Added maintainers.md and maintainers.toml
|
||||
- Added rakefile for simplified testing
|
||||
- Added source_url and issues_url metadata
|
||||
- Added basic converge chefspec
|
||||
|
||||
## v2.2.2 (2014-11-12)
|
||||
|
||||
- # 23, add chefspec matchers
|
||||
|
||||
## v2.2.0 (2014-02-25)
|
||||
|
||||
- [COOK-4285] Accept long EULAs
|
||||
|
||||
## v2.1.4 (2014-01-26)
|
||||
|
||||
- [COOK-4157] - dmg_package LWRP broken due to "puts" instead of "system"
|
||||
- [COOK-4065] - dmg cookbook outputs the name of packages when checking if they are installed
|
||||
|
||||
## v2.1.2
|
||||
|
||||
Cleaning up merge errors
|
||||
|
||||
## v2.1.0
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3946](https://tickets.chef.io/browse/COOK-3946)** - Syntax error in resources/package.rb
|
||||
- **[COOK-2672](https://tickets.chef.io/browse/COOK-2672)** - EULA for package is displayed instead accepted
|
||||
|
||||
## v2.0.8
|
||||
|
||||
Adding a Chef 10 compatibility check in provider
|
||||
|
||||
## v2.0.6
|
||||
|
||||
# BUG
|
||||
|
||||
- [COOK-3302] - Sometimes hdiutil detach fails due to cfprefsd running in background
|
||||
|
||||
# IMPROVEMENT
|
||||
|
||||
- Adding foodcritic and rubocop to .travis.yml
|
||||
|
||||
## v2.0.4
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3331](https://tickets.chef.io/browse/COOK-3331)** - Fix an issue where `dmg_package` with no source raises an exception
|
||||
|
||||
## v2.0.2
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3578](https://tickets.chef.io/browse/COOK-3578)** - Support `package_id`s with spaces
|
||||
- **[COOK-3302](https://tickets.chef.io/browse/COOK-3302)** - Fix an issue where `hdiutil detach` fails due to `cfprefsd` running in the background
|
||||
|
||||
## v2.0.0
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3389](https://tickets.chef.io/browse/COOK-3389)** - Use `rsync` instead of `cp` (potentially a breaking change on some systems)
|
||||
|
||||
## v1.1.0
|
||||
|
||||
- [COOK-1847] - accept owner parameter for installing packages
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- [COOK-852] - Support "pkg" in addition to "mpkg" package types
|
||||
|
||||
## v0.7.0
|
||||
|
||||
- [COOK-854] - use `cp -R` instead of `cp -r`
|
||||
- [COOK-855] - specify a file or directory to check for prior install
|
||||
|
||||
## v0.6.0
|
||||
|
||||
- option to install software that is an .mpkg inside a .dmg
|
||||
- ignore failure on chmod in case mode is already set, or is root owned
|
@ -1,2 +0,0 @@
|
||||
Please refer to
|
||||
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD
|
@ -1,149 +0,0 @@
|
||||
The dmg_package resource is now included in Chef 14 and this cookbook has been deprecated. We highly recommend updating to Chef 14 so you can use this resource without the need for a cookbook dependency.
|
||||
|
||||
# dmg Cookbook
|
||||
|
||||
[](https://travis-ci.org/chef-cookbooks/dmg) [](https://supermarket.chef.io/cookbooks/dmg)
|
||||
|
||||
Resource to install OS X applications (.app) from dmg files.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Platforms
|
||||
|
||||
- macOS
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 12.5+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
- none
|
||||
|
||||
## Resources/Providers
|
||||
|
||||
### dmg_package
|
||||
|
||||
This resource will install a DMG "Package". It will retrieve the DMG from a remote URL, mount it using OS X's `hdid`, copy the application (.app directory) to the specified destination (/Applications), and detach the image using `hdiutil`. The dmg file will be stored in the `Chef::Config[:file_cache_path]`. If you want to install an application that has already been downloaded (not using the `source` parameter), copy it to the appropriate location. You can find out what directory this is with the following command on the node to run chef:
|
||||
|
||||
```bash
|
||||
knife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb
|
||||
```
|
||||
|
||||
Optionally, the LWRP can install an "mpkg" or "pkg" package using installer(8).
|
||||
|
||||
#### Actions
|
||||
|
||||
- :install - Installs the application.
|
||||
|
||||
#### Parameter attributes:
|
||||
|
||||
- `app` - This is the name of the application used by default for the /Volumes directory and the .app directory copied to /Applications.
|
||||
- `source` - remote URL for the dmg to download if specified. Default is nil.
|
||||
- `file` - local dmg full file path. Default is nil.
|
||||
- `owner` - owner that should own the package installation.
|
||||
- `destination` - directory to copy the .app into. Default is /Applications.
|
||||
- `checksum` - sha256 checksum of the dmg to download. Default is nil.
|
||||
- `type` - type of package, "app", "pkg" or "mpkg". Default is "app". When using "pkg" or "mpkg", the destination must be /Applications.
|
||||
- `volumes_dir` - Directory under /Volumes where the dmg is mounted. Not all dmgs are mounted into a /Volumes location matching the name of the dmg. If not specified, this will use the name attribute.
|
||||
- `package_id` - Package id registered with pkgutil when a pkg or mpkg is installed
|
||||
- `dmg_name` - Specify the name of the dmg if it is not the same as `app`, or if the name has spaces.
|
||||
- `dmg_passphrase` - Specify a passphrase to use to unencrypt the dmg while mounting.
|
||||
- `accept_eula` - Specify whether to accept the EULA. Certain dmgs require acceptance of EULA before mounting. Can be true or false, defaults to false.
|
||||
- `headers` - Allows custom HTTP headers (like cookies) to be set on the remote_file resource.
|
||||
- `allow_untrusted` - Allows packages with untrusted certs to be installed.
|
||||
|
||||
#### Examples
|
||||
|
||||
Install `/Applications/Tunnelblick.app` from the primary download site.
|
||||
|
||||
```ruby
|
||||
dmg_package 'Tunnelblick' do
|
||||
source 'https://tunnelblick.net/release/Tunnelblick_3.7.0_build_4790.dmg'
|
||||
checksum '5053038aa8caf7dea66dcab11d6d240672216e6546eff4c2622e216c61af85e5'
|
||||
action :install
|
||||
end
|
||||
```
|
||||
|
||||
Install Google Chrome. Uses the `dmg_name` because the application name has spaces. Installs in `/Applications/Google Chrome.app`.
|
||||
|
||||
```ruby
|
||||
dmg_package 'Google Chrome' do
|
||||
dmg_name 'googlechrome'
|
||||
source 'https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg'
|
||||
checksum '7daa2dc5c46d9bfb14f1d7ff4b33884325e5e63e694810adc58f14795165c91a'
|
||||
action :install
|
||||
end
|
||||
```
|
||||
|
||||
Install Dropbox. Uses `volumes_dir` because the mounted directory is different than the name of the application directory. Installs in `/Applications/Dropbox.app`.
|
||||
|
||||
```ruby
|
||||
dmg_package 'Dropbox' do
|
||||
volumes_dir 'Dropbox Installer'
|
||||
source 'http://www.dropbox.com/download?plat=mac'
|
||||
checksum 'b4ea620ca22b0517b75753283ceb82326aca8bc3c86212fbf725de6446a96a13'
|
||||
action :install
|
||||
end
|
||||
```
|
||||
|
||||
Install MacIrssi to `~/Applications` from the local file downloaded to the cache path into an Applications directory in the current user's home directory. Chef should run as a non-root user for this.
|
||||
|
||||
```ruby
|
||||
directory "#{ENV['HOME']}/Applications"
|
||||
|
||||
dmg_package 'MacIrssi' do
|
||||
destination "#{ENV['HOME']}/Applications"
|
||||
action :install
|
||||
end
|
||||
```
|
||||
|
||||
Install Virtualbox to `/Applications` from the .mpkg:
|
||||
|
||||
```ruby
|
||||
dmg_package 'Virtualbox' do
|
||||
source 'http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg'
|
||||
type 'mpkg'
|
||||
end
|
||||
```
|
||||
|
||||
Install pgAdmin to `/Applications` and automatically accept the EULA:
|
||||
|
||||
```ruby
|
||||
dmg_package 'pgAdmin3' do
|
||||
source 'http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg'
|
||||
checksum '9435f79d5b52d0febeddfad392adf82db9df159196f496c1ab139a6957242ce9'
|
||||
accept_eula true
|
||||
end
|
||||
```
|
||||
|
||||
Install Silverlight, with idempotence check based on pkgutil:
|
||||
|
||||
```ruby
|
||||
dmg_package 'Silerlight' do
|
||||
source 'http://silverlight.dlservice.microsoft.com/download/D/C/2/DC2D5838-9138-4D25-AA92-52F61F7C51E6/runtime/Silverlight.dmg'
|
||||
type 'pkg'
|
||||
checksum '6d4a0ad4552d9815531463eb3f467fb8cf4bffcc'
|
||||
package_id 'com.microsoft.installSilverlightPlugin'
|
||||
end
|
||||
```
|
||||
|
||||
## License & Authors
|
||||
|
||||
**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))
|
||||
|
||||
**Copyright:** 2011-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.
|
||||
```
|
File diff suppressed because one or more lines are too long
@ -1,20 +0,0 @@
|
||||
#
|
||||
# Cookbook:: dmg
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2011-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.
|
||||
#
|
||||
|
||||
Chef::Log.warn('The dmg::default recipe does not contain any resources and should not be applied to a node')
|
@ -1,102 +0,0 @@
|
||||
#
|
||||
# Author:: Joshua Timberman (<jtimberman@chef.io>)
|
||||
# Cookbook:: dmg
|
||||
# Resource:: package
|
||||
#
|
||||
# Copyright:: 2011-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.
|
||||
#
|
||||
|
||||
property :app, String, name_property: true
|
||||
property :source, String
|
||||
property :file, String
|
||||
property :owner, String
|
||||
property :destination, String, default: '/Applications'
|
||||
property :checksum, String
|
||||
property :volumes_dir, String
|
||||
property :dmg_name, String
|
||||
property :type, String, default: 'app', equal_to: %w(app pkg mpkg)
|
||||
property :installed, [true, false], default: false, desired_state: false
|
||||
property :package_id, String
|
||||
property :dmg_passphrase, String
|
||||
property :accept_eula, [true, false], default: false
|
||||
property :headers, [Hash, nil], default: nil
|
||||
property :allow_untrusted, [true, false], default: false
|
||||
|
||||
load_current_value do |new_resource|
|
||||
if ::File.directory?("#{new_resource.destination}/#{new_resource.app}.app")
|
||||
Chef::Log.info "Already installed; to upgrade, remove \"#{new_resource.destination}/#{new_resource.app}.app\""
|
||||
installed true
|
||||
elsif shell_out("pkgutil --pkgs='#{new_resource.package_id}'").exitstatus == 0
|
||||
Chef::Log.info "Already installed; to upgrade, try \"sudo pkgutil --forget '#{new_resource.package_id}'\""
|
||||
installed true
|
||||
else
|
||||
installed false
|
||||
end
|
||||
end
|
||||
|
||||
action :install do
|
||||
unless current_resource.installed
|
||||
|
||||
volumes_dir = new_resource.volumes_dir ? new_resource.volumes_dir : new_resource.app
|
||||
dmg_name = new_resource.dmg_name ? new_resource.dmg_name : new_resource.app
|
||||
|
||||
dmg_file = if new_resource.file.nil?
|
||||
"#{Chef::Config[:file_cache_path]}/#{dmg_name}.dmg"
|
||||
else
|
||||
new_resource.file
|
||||
end
|
||||
|
||||
remote_file "#{dmg_file} - #{new_resource.name}" do
|
||||
path dmg_file
|
||||
source new_resource.source
|
||||
headers new_resource.headers if new_resource.headers
|
||||
checksum new_resource.checksum if new_resource.checksum
|
||||
end if new_resource.source
|
||||
|
||||
passphrase_cmd = new_resource.dmg_passphrase ? "-passphrase #{new_resource.dmg_passphrase}" : ''
|
||||
ruby_block "attach #{dmg_file}" do
|
||||
block do
|
||||
cmd = shell_out("hdiutil imageinfo #{passphrase_cmd} '#{dmg_file}' | grep -q 'Software License Agreement: true'")
|
||||
software_license_agreement = cmd.exitstatus == 0
|
||||
raise "Requires EULA Acceptance; add 'accept_eula true' to package resource" if software_license_agreement && !new_resource.accept_eula
|
||||
accept_eula_cmd = new_resource.accept_eula ? 'echo Y | PAGER=true' : ''
|
||||
shell_out!("#{accept_eula_cmd} hdiutil attach #{passphrase_cmd} '#{dmg_file}' -mountpoint '/Volumes/#{volumes_dir}' -quiet")
|
||||
end
|
||||
not_if "hdiutil info #{passphrase_cmd} | grep -q 'image-path.*#{dmg_file}'"
|
||||
end
|
||||
|
||||
case new_resource.type
|
||||
when 'app'
|
||||
execute "rsync --force --recursive --links --perms --executability --owner --group --times '/Volumes/#{volumes_dir}/#{new_resource.app}.app' '#{new_resource.destination}'" do
|
||||
user new_resource.owner if new_resource.owner
|
||||
end
|
||||
|
||||
declare_resource(:file, "#{new_resource.destination}/#{new_resource.app}.app/Contents/MacOS/#{new_resource.app}") do
|
||||
mode '755'
|
||||
ignore_failure true
|
||||
end
|
||||
when 'mpkg', 'pkg'
|
||||
install_cmd = "installation_file=$(ls '/Volumes/#{volumes_dir}' | grep '.#{new_resource.type}$') && sudo installer -pkg \"/Volumes/#{volumes_dir}/$installation_file\" -target /"
|
||||
install_cmd += ' -allowUntrusted' if new_resource.allow_untrusted
|
||||
|
||||
execute install_cmd do
|
||||
# Prevent cfprefsd from holding up hdiutil detach for certain disk images
|
||||
environment('__CFPREFERENCES_AVOID_DAEMON' => '1')
|
||||
end
|
||||
end
|
||||
|
||||
execute "hdiutil detach '/Volumes/#{volumes_dir}' || hdiutil detach '/Volumes/#{volumes_dir}' -force"
|
||||
end
|
||||
end
|
@ -1 +0,0 @@
|
||||
~FC016
|
@ -2,6 +2,63 @@
|
||||
|
||||
This file is used to list changes made in each version of the git cookbook.
|
||||
|
||||
## 10.0.0 (2019-10-16)
|
||||
|
||||
- Add testing for CentOS 8, openSUSE 15, Ubuntu 18.04 in Travis
|
||||
- Require Chef Infra Client 14 or later so we can drop the dependency on build-essential
|
||||
- Resolve multiple cookstyle warnings
|
||||
|
||||
## 9.0.1 (2018-06-02)
|
||||
|
||||
- Update the platforms we test on
|
||||
- Remove extra attr_accessor in config and requires
|
||||
- Bump git version to 2.17.1 to resolve CVE
|
||||
|
||||
## 9.0.0 (2018-03-08)
|
||||
|
||||
- Remove the dependency on the homebrew cookbook by not automatically installing homebrew in the git resource on macOS systems. Homebrew needs to be setup before this resource runs and that should probably be the very first thing you do on a macOS system
|
||||
- Use the build_essential resource instead of including the default recipe. This requires version 5.0 or later of the build-essential cookbook and allows us to use the build_essential resource that will be built into Chef 14 when that ships
|
||||
- Remove extra includes in the resources that weren't necessary
|
||||
- Updated testing to include Fedora 27, Ubuntu 18.04, Debian 9, macOS 10.12, and Windows 2016
|
||||
|
||||
## 8.0.1 (2018-02-10)
|
||||
|
||||
- Resolve the new FC118 foodcritic warning
|
||||
- Remove the ChefSpec matchers which are auto generated now
|
||||
- Resolve FC104 warning
|
||||
|
||||
## 8.0.0 (2017-09-01)
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- macOS resource now properly executes and uses homebrew to install git instead of dmg and packages posted to SourceForge
|
||||
- Default to Git 2.9.5 now, which properly compiles on Fedora / Amazon Linux
|
||||
|
||||
## Other Changes
|
||||
|
||||
- Fixed support for Amazon Linux on Chef 13
|
||||
- Unified the package setup for source installs which fixes Amazon/Fedora
|
||||
- Removed an entirely duplicate service provider
|
||||
- Remove unused runit templates
|
||||
- Properly fail when we're on an unsupported platform
|
||||
|
||||
## 7.0.0 (2017-09-01)
|
||||
|
||||
- Remove support for RHEL 5 which removes the need for the yum-epel cookbook
|
||||
- Move templates out of the default directory now that we require Chef 12
|
||||
- Remove support for Ubuntu 10.04
|
||||
- Remove the version requirement on mac_os_x in the metadata
|
||||
- Move maintainer information to the readme
|
||||
- Expand Travis testing
|
||||
|
||||
## 6.1.0 (2017-05-30)
|
||||
|
||||
- Test with Local Delivery and not Rake
|
||||
- Remove EOL platforms from the kitchen configs
|
||||
- Use a SPDX standard license string
|
||||
- Updated default versions documented in README to fix Issue #120.
|
||||
- Remove class_eval and require chef 12.7+
|
||||
|
||||
## 6.0.0 (2017-02-14)
|
||||
|
||||
- Fail on deprecations is now enabled so we're fully Chef 13 compatible
|
||||
|
@ -1,15 +0,0 @@
|
||||
<!-- 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)
|
@ -20,17 +20,17 @@ The following platforms have been tested with Test Kitchen:
|
||||
|---------------+-------|
|
||||
| centos-7 | X |
|
||||
|---------------+-------|
|
||||
| centos-8 | X |
|
||||
|---------------+-------|
|
||||
| fedora | X |
|
||||
|---------------+-------|
|
||||
| debian-7 | X |
|
||||
| debian-9 | X |
|
||||
|---------------+-------|
|
||||
| debian-8 | X |
|
||||
|---------------+-------|
|
||||
| ubuntu-14.04 | X |
|
||||
| debian-10 | X |
|
||||
|---------------+-------|
|
||||
| ubuntu-16.04 | X |
|
||||
|---------------+-------|
|
||||
| openSUSE 13.2 | X |
|
||||
| ubuntu-18.04 | X |
|
||||
|---------------+-------|
|
||||
| openSUSE Leap | X |
|
||||
|---------------+-------|
|
||||
@ -38,13 +38,11 @@ The following platforms have been tested with Test Kitchen:
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 12.5+
|
||||
- Chef 14+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
- depends 'build-essential' - For compiling from source
|
||||
- depends 'dmg' - For macOS Support
|
||||
- depends 'yum-epel' - For older RHEL platform_family support
|
||||
- none
|
||||
|
||||
## Usage
|
||||
|
||||
@ -60,6 +58,8 @@ Add `git::default`, `git::source` or `git::windows` to your run_list OR add `dep
|
||||
|
||||
The `git_client` resource manages the installation of a Git client on a machine.
|
||||
|
||||
`Note`: on macOS systems homebrew must first be installed on the system before running this resource. Prior to version 9.0 of this cookbook homebrew was automatically installed.
|
||||
|
||||
#### Example
|
||||
|
||||
```ruby
|
||||
@ -68,6 +68,17 @@ git_client 'default' do
|
||||
end
|
||||
```
|
||||
|
||||
#### Example of source install
|
||||
|
||||
```ruby
|
||||
git_client 'source' do
|
||||
provider Chef::Provider::GitClient::Source
|
||||
source_version '2.14.2'
|
||||
source_checksum 'a03a12331d4f9b0f71733db9f47e1232d4ddce00e7f2a6e20f6ec9a19ce5ff61'
|
||||
action :install
|
||||
end
|
||||
```
|
||||
|
||||
### git_config
|
||||
|
||||
The `git_config` resource manages the configuration of Git client on a machine.
|
||||
@ -96,23 +107,15 @@ Currently, there are distinct sets of resource properties, used by the 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_version` - Defaults to 2.8.1
|
||||
- `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
|
||||
- `source_checksum` - Defaults to a known value for the 2.8.1 source tarball
|
||||
|
||||
# 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
|
||||
- `windows_package_checksum` - Defaults to the value for 2.8.1
|
||||
|
||||
## Recipes
|
||||
|
||||
@ -127,11 +130,6 @@ This cookbook ships with ready to use, attribute driven recipes that utilize the
|
||||
- `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
|
||||
@ -140,11 +138,13 @@ This cookbook ships with ready to use, attribute driven recipes that utilize the
|
||||
- `node['git']['checksum']` - tarball SHA256 checksum
|
||||
- `node['git']['use_pcre']` - if true, builds git with PCRE enabled
|
||||
|
||||
## License & Authors
|
||||
## Maintainers
|
||||
|
||||
- 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.
|
||||
This cookbook is maintained by Chef's Community Cookbook Engineering team. Our goal is to improve cookbook quality and to aid the community in contributing to cookbooks. To learn more about our team, process, and design goals see our [team documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/COOKBOOK_TEAM.MD). To learn more about contributing to cookbooks like this see our [contributing documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD), or if you have general questions about this cookbook come chat with us in #cookbok-engineering on the [Chef Community Slack](http://community-slack.chef.io/)
|
||||
|
||||
## License
|
||||
|
||||
**Copyright:** 2009-2017, Chef Software, Inc.
|
||||
|
||||
```
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -3,7 +3,7 @@
|
||||
# Cookbook:: git
|
||||
# Attributes:: default
|
||||
#
|
||||
# Copyright:: 2008-2016, Chef Software, Inc.
|
||||
# Copyright:: 2008-2019, 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.
|
||||
@ -29,17 +29,11 @@ when 'windows'
|
||||
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']['version'] = '2.17.1'
|
||||
default['git']['url'] = 'https://nodeload.github.com/git/git/tar.gz/v%{version}'
|
||||
default['git']['checksum'] = 'e08503ecaf5d3ac10c40f22871c996a392256c8d038d16f52ebf974cba29ae42'
|
||||
default['git']['checksum'] = '690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a'
|
||||
default['git']['use_pcre'] = false
|
||||
end
|
||||
|
||||
|
@ -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
|
File diff suppressed because one or more lines are too long
26
cookbooks/git/metadata.rb
Normal file
26
cookbooks/git/metadata.rb
Normal file
@ -0,0 +1,26 @@
|
||||
name 'git'
|
||||
maintainer 'Chef Software, Inc.'
|
||||
maintainer_email 'cookbooks@chef.io'
|
||||
license 'Apache-2.0'
|
||||
description 'Installs git and/or sets up a Git server daemon'
|
||||
version '10.0.0'
|
||||
|
||||
supports 'amazon'
|
||||
supports 'centos'
|
||||
supports 'debian'
|
||||
supports 'fedora'
|
||||
supports 'freebsd'
|
||||
supports 'mac_os_x'
|
||||
supports 'omnios'
|
||||
supports 'oracle'
|
||||
supports 'redhat'
|
||||
supports 'smartos'
|
||||
supports 'scientific'
|
||||
supports 'suse'
|
||||
supports 'opensuseleap'
|
||||
supports 'ubuntu'
|
||||
supports 'windows'
|
||||
|
||||
source_url 'https://github.com/chef-cookbooks/git'
|
||||
issues_url 'https://github.com/chef-cookbooks/git/issues'
|
||||
chef_version '>= 14'
|
@ -2,7 +2,7 @@
|
||||
# Cookbook:: git
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2008-2016, Chef Software, Inc.
|
||||
# Copyright:: 2008-2019, 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.
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Cookbook:: git
|
||||
# Recipe:: package
|
||||
#
|
||||
# Copyright:: 2008-2016, Chef Software, Inc.
|
||||
# Copyright:: 2008-2019, 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.
|
||||
@ -17,17 +17,6 @@
|
||||
# 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Cookbook:: git
|
||||
# Recipe:: server
|
||||
#
|
||||
# Copyright:: 2009-2016, Chef Software, Inc.
|
||||
# Copyright:: 2009-2019, 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.
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Cookbook:: git
|
||||
# Recipe:: windows
|
||||
#
|
||||
# Copyright:: 2008-2016, Chef Software, Inc.
|
||||
# Copyright:: 2008-2019, 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.
|
||||
|
@ -1,4 +1,4 @@
|
||||
property :key, String, name_attribute: true
|
||||
property :key, String, name_property: true
|
||||
property :value, String
|
||||
property :scope, equal_to: %w(local global system), default: 'global', desired_state: false
|
||||
property :path, String, desired_state: false
|
||||
@ -6,10 +6,6 @@ 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
|
||||
|
||||
@ -38,7 +34,7 @@ action :set do
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
action_class do
|
||||
def config_cmd
|
||||
"git config --#{new_resource.scope}"
|
||||
end
|
||||
|
@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
exec svlogd -tt ./main
|
@ -1,3 +0,0 @@
|
||||
#!/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"] %>
|
98
cookbooks/golang/CHANGELOG.md
Normal file
98
cookbooks/golang/CHANGELOG.md
Normal file
@ -0,0 +1,98 @@
|
||||
# CHANGELOG for golang
|
||||
|
||||
This file is used to list changes made in each version of golang.
|
||||
|
||||
## 4.1.0
|
||||
|
||||
- Create a custom resource to install Go from source or by downloading a package
|
||||
|
||||
## 4.0.0
|
||||
|
||||
- Update testing setup:
|
||||
- Use Chef Workstation instead of Rubygems
|
||||
- Includes dropping `foodcritic` in favor of current `cookstyle`
|
||||
- Add more recent & current distro versions
|
||||
- Add very basic unit tests
|
||||
- Use GitHub Actions instead of Travis CI
|
||||
- Refactor minitest to Inspec
|
||||
- Refactor to use current style of Chef Custom Resource
|
||||
- Update default version to Go v1.14.4
|
||||
- Use `build_essential` when building from source
|
||||
- Requires Chef >= 14.0.0
|
||||
- Omit attempting to install `bzr` on CentOS 8, they do not have that package available
|
||||
- Utilize default Chef order-of-operations instead of `notifies`
|
||||
- Use `ark` resource to simplify download & installation of binary & source
|
||||
- Clean up unnecessary env vars from source build
|
||||
- Build from source per [official Go docs](https://golang.org/doc/install/source)
|
||||
- Use native resources instead of shell commands when building from source
|
||||
- Set `$PATH` in `golang.sh` so that the existing values are last, per general practice
|
||||
- Tighten up `golang_package` so it does not perform actions at compile time, it uses `execute` in favor of `bash` resources, and in general is more Chef-y
|
||||
- Update tests to validate that non-root users can install Go and Go packages
|
||||
- Refactor attributes to add ability to install a version from source that differs from the packaged version (which is needed to build from source)
|
||||
|
||||
## 3.0.0
|
||||
|
||||
- rename to `chef-golang` so that metadata name matches repositoriy name
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- change attribute namespace to `node['golang']`
|
||||
|
||||
## 1.7.2
|
||||
|
||||
- Better chef12,13 support
|
||||
- Ruby 2.3
|
||||
- Update gems, lint
|
||||
|
||||
## 1.7.1
|
||||
|
||||
- Create a temporary directory
|
||||
|
||||
## 1.7.0
|
||||
|
||||
- Golang 1.5
|
||||
|
||||
## 1.6.2
|
||||
|
||||
- Ability to install from source
|
||||
|
||||
## 1.6.0
|
||||
|
||||
- Removed support for Ruby 1.9.3
|
||||
|
||||
## 1.5.1
|
||||
|
||||
- Fix testing with Vagrant, Test-Kitchen
|
||||
- Golang 1.4
|
||||
|
||||
## 1.5.0
|
||||
|
||||
- Golang 1.3
|
||||
|
||||
## 1.4.0
|
||||
|
||||
- Add build action to LWRP
|
||||
- Update default go version to 1.2.2
|
||||
- Add autodetection the platform architecture
|
||||
- Change package location to `http://golang.org/dl/`
|
||||
|
||||
## 1.3.0
|
||||
|
||||
## 1.2.0
|
||||
|
||||
## 1.1.0
|
||||
|
||||
- Added package LWRP
|
||||
- Configurable `gopath` & `gobin`
|
||||
|
||||
## 1.0.2
|
||||
|
||||
- Lets users easily specify another install dir
|
||||
|
||||
## 1.0.1
|
||||
|
||||
- Avoid extra unpacked copy of Go
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- Initial release of golang
|
4
cookbooks/golang/CONTRIBUTING.md
Normal file
4
cookbooks/golang/CONTRIBUTING.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Contributing
|
||||
|
||||
Please refer to
|
||||
[https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD)
|
77
cookbooks/golang/README.md
Normal file
77
cookbooks/golang/README.md
Normal file
@ -0,0 +1,77 @@
|
||||
# Golang (Go) Cookbook
|
||||
|
||||
[](https://supermarket.chef.io/cookbooks/golang)
|
||||
[](https://github.com/sous-chefs/golang/actions?query=workflow%3Aci)
|
||||
[](#backers)
|
||||
[](#sponsors)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
## Description
|
||||
|
||||
Chef cookbook for the [Go programming language](http://golang.org/).
|
||||
|
||||
## Requirements
|
||||
|
||||
### Platform
|
||||
|
||||
* Ubuntu >= 18.04
|
||||
* Debian >= 8
|
||||
* CentOS >= 7
|
||||
|
||||
## Usage
|
||||
|
||||
### golang::default
|
||||
|
||||
Include `golang` in your node's `run_list`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name":"my_node",
|
||||
"run_list": [
|
||||
"recipe[golang]"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### golang::packages
|
||||
|
||||
To install Go packages using node attributes add the packages to the `['golang']['packages']` attribute:
|
||||
|
||||
```json
|
||||
{
|
||||
"name":"my_node",
|
||||
"golang": {
|
||||
"packages": [
|
||||
"github.com/go-check/check"
|
||||
]
|
||||
},
|
||||
"run_list": [
|
||||
"recipe[golang]"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Contributors
|
||||
|
||||
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
|
||||
|
||||
### Backers
|
||||
|
||||
Thank you to all our backers!
|
||||
|
||||

|
||||
|
||||
### Sponsors
|
||||
|
||||
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
15
cookbooks/golang/attributes/default.rb
Normal file
15
cookbooks/golang/attributes/default.rb
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Cookbook:: golang
|
||||
# Attribute:: default
|
||||
#
|
||||
|
||||
default['golang']['scm'] = true
|
||||
default['golang']['scm_packages'] = value_for_platform(
|
||||
'centos' => { '>= 8' => %w(git mercurial) },
|
||||
'default' => %w(git mercurial bzr)
|
||||
)
|
||||
|
||||
default['golang']['install_dir'] = '/usr/local'
|
||||
default['golang']['gopath'] = '/opt/go'
|
||||
default['golang']['gobin'] = '/opt/go/bin'
|
||||
default['golang']['packages'] = []
|
1
cookbooks/golang/metadata.json
Normal file
1
cookbooks/golang/metadata.json
Normal file
@ -0,0 +1 @@
|
||||
{"name":"golang","version":"4.1.0","description":"Installs go programming language","long_description":"","maintainer":"Sous Chefs","maintainer_email":"help@sous-chefs.org","license":"Apache-2.0","platforms":{"debian":">= 0.0.0","ubuntu":">= 0.0.0","redhat":">= 0.0.0","centos":">= 0.0.0","fedora":">= 0.0.0","amazon":">= 0.0.0","scientific":">= 0.0.0","oracle":">= 0.0.0"},"dependencies":{"ark":"~> 5.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/sous-chefs/golang","issues_url":"https://github.com/sous-chefs/golang/issues","chef_version":[[">= 14.0"]],"ohai_version":[]}
|
20
cookbooks/golang/metadata.rb
Normal file
20
cookbooks/golang/metadata.rb
Normal file
@ -0,0 +1,20 @@
|
||||
name 'golang'
|
||||
maintainer 'Sous Chefs'
|
||||
maintainer_email 'help@sous-chefs.org'
|
||||
license 'Apache-2.0'
|
||||
description 'Installs go programming language'
|
||||
source_url 'https://github.com/sous-chefs/golang'
|
||||
issues_url 'https://github.com/sous-chefs/golang/issues'
|
||||
chef_version '>= 14.0'
|
||||
version '4.1.0'
|
||||
|
||||
supports 'debian'
|
||||
supports 'ubuntu'
|
||||
supports 'redhat'
|
||||
supports 'centos'
|
||||
supports 'fedora'
|
||||
supports 'amazon'
|
||||
supports 'scientific'
|
||||
supports 'oracle'
|
||||
|
||||
depends 'ark', '~> 5.0'
|
30
cookbooks/golang/recipes/default.rb
Normal file
30
cookbooks/golang/recipes/default.rb
Normal file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Cookbook:: golang
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2013, Alexander Rozhnov
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
golang 'Install go' do
|
||||
from_source node['golang']['from_source']
|
||||
version node['golang']['version'] if node['golang']['version'] # go version
|
||||
source_version node['golang']['source_version'] if node['golang']['source_version'] # go version from source
|
||||
owner node['golang']['owner'] if node['golang']['owner']
|
||||
group node['golang']['group'] if node['golang']['group']
|
||||
end
|
||||
|
||||
node['golang']['packages'].each do |package|
|
||||
golang_package package
|
||||
end
|
167
cookbooks/golang/resources/default.rb
Normal file
167
cookbooks/golang/resources/default.rb
Normal file
@ -0,0 +1,167 @@
|
||||
#
|
||||
# Cookbook:: golang
|
||||
# Resource:: default
|
||||
#
|
||||
# Copyright:: 2020, Sous-chefs
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Install golang by compiling from source
|
||||
property :from_source, [true, false], default: false
|
||||
|
||||
# Base directory for go
|
||||
property :install_dir, String, default: '/usr/local'
|
||||
property :gopath, String, default: '/opt/go'
|
||||
property :gobin, String, default: '/opt/go/bin'
|
||||
|
||||
# Directory and file attributes
|
||||
property :owner, String, default: 'root'
|
||||
property :group, String, default: 'root'
|
||||
property :directory_mode, String, default: '0755'
|
||||
|
||||
# version to install
|
||||
# ark input binaries and stuff download
|
||||
# e.g. https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz
|
||||
# https://dl.google.com/go/go1.14.4/linux-amd64.tar.gz
|
||||
# https://golang.org/dl/go1.14.6.darwin-amd64.tar.gz
|
||||
# https://golang.org/dl/go1.14.6.linux-amd64.tar.gz
|
||||
property :url, String, default: 'https://golang.org/dl/goVERSION.OS-PLATFORM.tar.gz'
|
||||
property :version, String, default: '1.14.4'
|
||||
|
||||
# ark input source
|
||||
# e.g. https://dl.google.com/go/go1.14.4.src.tar.gz
|
||||
property :source_url, String, default: 'https://golang.org/dl/goVERSION.src.tar.gz'
|
||||
property :source_version, String, default: '1.14.4'
|
||||
|
||||
# installation script from the source repository
|
||||
property :source_method, String, default: 'all.bash'
|
||||
|
||||
# install SCM packages
|
||||
property :scm, [true, false], default: true
|
||||
property :scm_packages, [String, Array], default: %w(git mercurial)
|
||||
|
||||
action_class do
|
||||
def bin_url
|
||||
return new_resource.url if property_is_set?(:url)
|
||||
new_resource.url.sub(/PLATFORM/, platform).sub(/OS/, os).sub(/VERSION/, new_resource.version)
|
||||
end
|
||||
|
||||
def source_url
|
||||
return new_resource.source_url if property_is_set?(:source_url)
|
||||
new_resource.source_url.sub(/VERSION/, new_resource.source_version)
|
||||
end
|
||||
|
||||
def os
|
||||
node['os']
|
||||
end
|
||||
|
||||
def platform
|
||||
node['kernel']['machine'] =~ /i.86/ ? '386' : 'amd64'
|
||||
end
|
||||
end
|
||||
|
||||
action :install do
|
||||
directory new_resource.gopath do
|
||||
recursive true
|
||||
owner new_resource.owner
|
||||
group new_resource.group
|
||||
mode new_resource.directory_mode
|
||||
end
|
||||
|
||||
directory new_resource.gobin do
|
||||
recursive true
|
||||
owner new_resource.owner
|
||||
group new_resource.group
|
||||
mode new_resource.directory_mode
|
||||
end
|
||||
|
||||
directory new_resource.install_dir do
|
||||
recursive true
|
||||
mode new_resource.directory_mode
|
||||
end
|
||||
|
||||
directory ::File.join(Chef::Config[:file_cache_path], 'go') do
|
||||
recursive true
|
||||
end
|
||||
|
||||
template '/etc/profile.d/golang.sh' do
|
||||
source 'golang.sh.erb'
|
||||
mode new_resource.directory_mode
|
||||
variables gobin: new_resource.gobin,
|
||||
gopath: new_resource.gobin,
|
||||
install_dir: new_resource.install_dir
|
||||
end
|
||||
|
||||
if new_resource.scm
|
||||
apt_update do
|
||||
only_if { platform_family? 'debian' }
|
||||
end
|
||||
package new_resource.scm_packages
|
||||
end
|
||||
|
||||
# pgk to install go binaries, doc, base packages
|
||||
# ark is not idempotent by itself. Check to see if the go binary is the correct version
|
||||
url = bin_url
|
||||
ark 'go' do
|
||||
url url
|
||||
version new_resource.version
|
||||
not_if "/usr/local/go-#{new_resource.version}/bin/go version | grep #{new_resource.version}"
|
||||
end
|
||||
|
||||
##### SOURCE BUILD
|
||||
|
||||
if new_resource.from_source
|
||||
|
||||
directory ::File.join(new_resource.install_dir, 'go', 'bin') do
|
||||
recursive true
|
||||
mode new_resource.directory_mode
|
||||
end
|
||||
|
||||
build_essential
|
||||
|
||||
file "#{new_resource.install_dir}/go" do
|
||||
manage_symlink_source true
|
||||
action :delete
|
||||
only_if do
|
||||
# Create idempotency by not deleting symlink if it points to source build
|
||||
::File.exist?("#{new_resource.install_dir}/go") &&
|
||||
::File.ftype("#{new_resource.install_dir}/go") == 'link' &&
|
||||
::File.readlink("#{new_resource.install_dir}/go") != "#{new_resource.install_dir}/go-source"
|
||||
end
|
||||
end
|
||||
|
||||
url = source_url
|
||||
ark 'go' do # resource with the same name, that's an issue. Source install
|
||||
url url
|
||||
version 'source'
|
||||
action :put
|
||||
release_file '/tmp/ark_release_file'
|
||||
not_if "test -x #{::File.join(new_resource.install_dir, 'go', 'bin', 'go')} && #{::File.join(new_resource.install_dir, 'go', 'bin', 'go')} version | grep #{new_resource.source_version}"
|
||||
end
|
||||
|
||||
# see if build already done
|
||||
# converge_by if not done
|
||||
execute 'build-golang' do
|
||||
cwd "#{new_resource.install_dir}/go/src"
|
||||
command "./#{new_resource.source_method}"
|
||||
environment({
|
||||
# Use the package-installed Go as the bootstrap version b/c Go is built with Go
|
||||
GOROOT_BOOTSTRAP: "#{new_resource.install_dir}/go-#{new_resource.version}",
|
||||
GOROOT: "#{new_resource.install_dir}/go",
|
||||
GOBIN: "#{new_resource.install_dir}/go/bin",
|
||||
})
|
||||
not_if "test -x #{::File.join(new_resource.install_dir, 'go', 'bin', 'go')} && #{::File.join(new_resource.install_dir, 'go', 'bin', 'go')} version | grep #{new_resource.source_version}"
|
||||
end
|
||||
end
|
||||
end
|
52
cookbooks/golang/resources/package.rb
Normal file
52
cookbooks/golang/resources/package.rb
Normal file
@ -0,0 +1,52 @@
|
||||
#
|
||||
# Cookbook:: golang
|
||||
# Resource:: default
|
||||
#
|
||||
|
||||
default_action :install
|
||||
|
||||
gocache = '/tmp/go'
|
||||
|
||||
action :install do
|
||||
execute "go get #{new_resource.name}" do
|
||||
user node['golang']['owner']
|
||||
group node['golang']['group']
|
||||
environment({
|
||||
PATH: "#{node['golang']['install_dir']}/go/bin:#{node['golang']['gobin']}:" \
|
||||
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
GOPATH: node['golang']['gopath'],
|
||||
GOBIN: node['golang']['gobin'],
|
||||
GOCACHE: gocache,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
action :update do
|
||||
execute "go get -u #{new_resource.name}" do
|
||||
user node['golang']['owner']
|
||||
group node['golang']['group']
|
||||
environment({
|
||||
PATH: "#{node['golang']['install_dir']}/go/bin:#{node['golang']['gobin']}:" \
|
||||
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
GOPATH: node['golang']['gopath'],
|
||||
GOBIN: node['golang']['gobin'],
|
||||
GOCACHE: gocache,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
action :build do
|
||||
execute "go build -work -x #{new_resource.name}" do
|
||||
user node['golang']['owner']
|
||||
group node['golang']['group']
|
||||
cwd gocache
|
||||
environment({
|
||||
PATH: "#{node['golang']['install_dir']}/go/bin:#{node['golang']['gobin']}:" \
|
||||
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
HOME: "/home/#{node['golang']['owner']}",
|
||||
GOPATH: node['golang']['gopath'],
|
||||
GOBIN: node['golang']['gobin'],
|
||||
GOCACHE: gocache,
|
||||
})
|
||||
end
|
||||
end
|
3
cookbooks/golang/templates/golang.sh.erb
Normal file
3
cookbooks/golang/templates/golang.sh.erb
Normal file
@ -0,0 +1,3 @@
|
||||
export PATH="<%= ::File.join(@install_dir, 'go', 'bin') %>:<%= @gobin %>:$PATH"
|
||||
export GOPATH=<%= @gopath %>
|
||||
export GOBIN=<%= @gobin %>
|
@ -20,4 +20,4 @@ chef_version '>= 14.0'
|
||||
# source_url 'https://github.com/<insert_org_here>/kosmos-bitcoin'
|
||||
|
||||
depends "ark"
|
||||
depends "kosmos_encfs"
|
||||
depends "golang"
|
||||
|
Loading…
x
Reference in New Issue
Block a user