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

195
cookbooks/ohai/CHANGELOG.md Normal file
View File

@@ -0,0 +1,195 @@
# ohai Cookbook CHANGELOG
This file is used to list changes made in each version of the ohai cookbook.
## 5.2.5 (2018-09-04)
- Add note that ohai_hint will be removed April 2019 when Chef 13 goes EOL as this resource now ships in Chef 14+
## 5.2.4 (2018-08-28)
- Avoid deprecation warnings in Chef 14.3+ by not loading resources already in Chef
## 5.2.3 (2018-06-08)
- Make sure we properly compare a provided plugin path to the path on disk by stripping trailing slashes from the provided directory
- Don't reload ohai when the plugin exists in a subdirectory of the config's set plugin path
## 5.2.2 (2018-02-15)
- Remove ChefSpec matchers we no longer need since they're auto generated
## 5.2.1 (2018-01-25)
- Switch from a .foodcritic file to an inline comments which resolve Supermarket warnings
- Remove unused helper method
## 5.2.0 (2017-08-17)
- Resolve multiple issues with Windows paths that caused the cookbook to converge on every run or fail
- Move maintainer information to the readme
- Add testing on Chef 12.7 in Travis
- Move helpers to their own modules and add testing framework
## 5.1.0 (2017-05-06)
- Workaround action_class bug by requiring Chef 12.7+
## 5.0.4 (2017-04-25)
- Fix lack of .rb extension when deleting plugins.
## 5.0.3 (2017-04-06)
- Use class_eval again in the custom resource to provide Chef 12.5/12.6 compatibility
- Remove kind_of and use name_property not name_attribute
- Fix failures on Chef 13
## 5.0.2 (2017-03-24)
- Remove class_eval
## 5.0.1 (2017-03-14)
- Test with Delivery Local Mode
- Bump the dependency to 12.7+ due to failures on 12.5-12.6
## 5.0.0 (2017-02-23)
- Require Chef 12.5+ and remove compat_resource dependency
## 4.2.3 (2016-12-02)
- Prevent chef_version metadata from failing runs in Opsworks
- Better explain how to resolve the plugin_path issue
- Add suse as a supported platform
- Require at least compat_resource 12.14.7
## 4.2.2 (2016-09-19)
- Ignore case in plugin path check on Windows
## 4.2.1 (2016-09-08)
- Fix typo in compile warning text
- Depend on the latest compat_resource (12.14)
- Remove Chef 11 compat in the metadata
- Require Chef 12.1 not 12.0
- Define ohai_plugin matcher for Chefspec
## v4.2.0 (2016-07-19)
- Added the ability to specify the source cookbook for the cookbook_file or template used in the ohai_plugin resource.
- Added chef_version to the metadata
- Added testing on openSUSE and switched from Rubocop to Cookstyle
## v4.1.1 (2016-06-16)
- Fixed error in notifies reload for the delete action
- Bump the compat_resource requirement from 12.9+ to 12.10+ to prevent random failures
## v4.1.0 (2016-05-26)
- Added the ability to use templates and pass in variables with the plugin custom resource
## v4.0.2 (2016-05-23)
- Resolve failures on Windows nodes
## v4.0.1 (2016-05-19)
- Added .rb to the name of the plugins so they actually load
- Added testing to ensure the plugins are being loaded in the chef run
## v4.0.0 (2016-05-18)
### BREAKING CHANGE:
The 4.0 release of the Ohai cookbook removes the previous cookbook_file behavior that required forking the cookbook and adding your own plugins. Instead the cookbook ships with a new ohai_plugin custom resource for installing plugins. In addition to this new custom resource the cookbook now requires Chef 12+. See the readme and test recipe for examples. If you require Chef 11 support you'll need to pin to version 3.0 in your environment.
## v3.0.1 (2016-03-14)
- Fixed the Chefspec matchers
## v3.0.0 (2016-03-14)
- Change the default value for `node['ohai']['hints_path']` to use the Ohai config value. This should be the same value in most use cases, but if a custom path is specified in the chef client config this value will get used automatically by the cookbook.
- Removed backwards compatibility with Chefspec < 4.1 in the matchers library
- Fix bad link to the custom Ohai plugin documentation in the readme
- Improve documentation for `node['ohai']['plugin_path']`
## v2.1.0 (2016-01-26)
- Properly handle creating ohai hints without specifying the content. Previously if the content wasn't specified a deprecation notice would be thrown and the file would not be created
- Simplified the test suite and added inspec tests to ensure hints are created, especially if the content is not specified
- Added FreeBSD and Windows as supported platform in the metadata and add them to the Test Kitchen config
- Add Test Kitchen integration tests to Travis CI
- Updated testing Gems to the latest releases in the Gemfile
## v2.0.4 (2015-10-30)
- Resolved deprecation warnings with the Chefspec matchers
## v2.0.3 (2015-10-21)
- Validate the hints before loading them to avoid failures
- Added supported platforms to the metadata
- Updated .gitignore file
- Updated Test Kitchen config for the latest platforms
- Added Chef standard Rubocop config
- Added Travis CI testing
- Added Berksfile
- Updated contributing and testing docs
- Added maintainers.md and maintainers.toml files
- Added Travis and cookbook version badges to the readme
- Expanded the requirements section in the readme and clarify the minimum supported Chef release is 11
- Updated Opscode -> Chef Software
- Added a Rakefile for simplified testing
- Added a Chefignore file
- Resolved Rubocop warnings
- Added source_url and issues_url to the metadata
- Added Chefspec matchers
- Added basic convergence Chefspec test
## v2.0.1 (2014-06-07)
- [COOK-4683] Remove warnings about reopening resource
Please note, this changes the name of a remote_directory resource. It is not expected that anyone would be explicitly notifying this resource but, please review [PR #16](https://github.com/chef-cookbooks/ohai/pull/16/files) for more info.
## v2.0.0 (2014-02-25)
'[COOK-3865] - create lwrp ohai_hint'
## v1.1.12
- Dummy release due to a Community Site upload failure
## v1.1.10
### Bug
- **[COOK-3091](https://tickets.chef.io/browse/COOK-3091)** - Fix checking `Chef::Config[:config_file]`
## v1.1.8
- [COOK-1918] - Ohai cookbook to distribute plugins fails on windows
- [COOK-2096] - Ohai cookbook sets unix-only default path attribute
## v1.1.6
- [COOK-2057] - distribution from another cookbok fails if ohai attributes are loaded after the other cookbook
## v1.1.4
- [COOK-1128] - readme update, Replace reference to deprecated chef cookbook with one to chef-client
## v1.1.2
- [COOK-1424] - prevent plugin_path growth to infinity
## v1.1.0
- [COOK-1174] - custom_plugins is only conditionally available
- [COOK-1383] - allow plugins from other cookbooks
## v1.0.2
- [COOK-463] ohai cookbook default recipe should only reload plugins if there were updates

View File

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

138
cookbooks/ohai/README.md Normal file
View File

@@ -0,0 +1,138 @@
# ohai Cookbook
[![Build Status](https://travis-ci.org/chef-cookbooks/ohai.svg?branch=master)](https://travis-ci.org/chef-cookbooks/ohai) [![Build status](https://ci.appveyor.com/api/projects/status/lgok2kr6l007s8hf/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks/ohai/branch/master) [![Cookbook Version](https://img.shields.io/cookbook/v/ohai.svg)](https://supermarket.chef.io/cookbooks/ohai)
Contains custom resources for adding Ohai hints and installing custom Ohai plugins. Handles path creation as well as the reloading of Ohai so that new data will be available during the same run.
NOTE: The ohai_hint resource shipped in Chef 14.0 (April 2018). When Chef 15.0 is released (April 2019) and Chef 13 goes EOL the ohai_hint resource will be removed from this cookbook.
## Requirements
### Platforms
- Debian/Ubuntu
- RHEL/CentOS/Scientific/Amazon/Oracle
- openSUSE / SUSE Enterprise Linux
- FreeBSD
- Windows
### Chef
- Chef 12.7+
### Cookbooks
- none
## Custom Resources
### `ohai_hint`
Creates Ohai hint files, which are consumed by Ohai plugins in order to determine if they should run or not.
#### Resource Attributes
- `hint_name` - The name of hints file and key. Should be string, default is name of resource.
- `content` - Values of hints. It will be used as automatic attributes. Should be Hash, default is empty Hash
- `compile_time` - Should the resource run at compile time. This defaults to true
#### Examples
Hint file installed to the default directory:
```ruby
ohai_hint 'ec2'
```
Hint file not installed at compile time:
```ruby
ohai_hint 'ec2' do
compile_time false
end
```
Hint file installed with content:
```ruby
ohai_hint 'raid_present' do
content Hash[:a, 'test_content']
end
```
#### ChefSpec Matchers
You can check for the creation or deletion of ohai hints with chefspec using these custom matches:
- create_ohai_hint
- delete_ohai_hint
### `ohai_plugin`
Installs custom Ohai plugins.
#### Resource Attributes
- `plugin_name` - The name to give the plugin on the filesystem. Should be string, default is name of resource.
- `path` - The path to your custom plugin directory. Defaults to a directory named 'plugins' under the directory 'ohai' in the Chef config dir.
- `source_file` - The source file for the plugin in your cookbook if not NAME.rb.
- `cookbook` - The cookbook where the source file exists if not the cookbook where the ohai_plugin resource is running from.
- `resource` - The resource type for the plugin file. Either `:cookbook_file` or `:template`. Defaults to `:cookbook_file`.
- `variables` - Usable only if `resource` is `:template`. Defines the template's variables.
- `compile_time` - Should the resource run at compile time. This defaults to `true`.
#### examples
Simple Ohai plugin installation:
```ruby
ohai_plugin 'my_custom_plugin'
```
Installation where the resource doesn't match the filename and you install to a custom plugins dir:
```ruby
ohai_plugin 'My Ohai Plugin' do
name 'my_custom_plugin'
path '/my/custom/path/'
end
```
Installation using a template:
```ruby
ohai_plugin 'My Templated Plugin' do
name 'templated_plugin'
resource :template
variables node_type: :web_server
end
```
#### ChefSpec Matchers
You can check for the creation or deletion of ohai plugins with chefspec using these custom matches:
- create_ohai_plugin
- delete_ohai_plugin
## Maintainers
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:** 2011-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.
```

View File

@@ -0,0 +1,35 @@
#
# Cookbook:: ohai
# Library:: hint_helpers
#
# Author:: Tim Smith (<tsmith@chef.io>)
#
# Copyright:: 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.
#
module OhaiCookbook
module HintHelpers
def ohai_hint_file_path(filename)
path = ::File.join(::Ohai::Config.ohai.hints_path.first, filename)
path << '.json' unless path.end_with?('.json')
path
end
def format_content(content)
return '' if content.nil? || content.empty?
JSON.pretty_generate(content)
end
end
end

View File

@@ -0,0 +1,77 @@
#
# Cookbook:: ohai
# Library:: plugin_helpers
#
# Author:: Tim Smith (<tsmith@chef.io>)
#
# Copyright:: 2017-2018, 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.
#
module OhaiCookbook
module PluginHelpers
# return the path property if specified or
# CHEF_CONFIG_PATH/ohai/plugins if a path isn't specified
def desired_plugin_path
if new_resource.path
new_resource.path.chomp('/') # if the user gave us /foo/bar/ we need /foo/bar for later comparison
else
::File.join(chef_config_path, 'ohai', 'plugins')
end
end
# return the chef config files dir or fail hard
def chef_config_path
if Chef::Config['config_file']
::File.dirname(Chef::Config['config_file'])
else
Chef::Application.fatal!("No chef config file defined. Are you running \
chef-solo? If so you will need to define a path for the ohai_plugin as the \
path cannot be determined")
end
end
# is the desired plugin dir in the ohai config plugin dir array?
def in_plugin_path?(path)
normalized_path = normalize_path(path)
# get the directory where we plan to stick the plugin (not the actual file path)
desired_dir = ::File.directory?(normalized_path) ? normalized_path : ::File.dirname(normalized_path)
::Ohai::Config.ohai['plugin_path'].map { |x| normalize_path(x) }.any? do |d|
desired_dir.start_with?(d)
end
end
# return path to lower and with forward slashes so we can compare it
# this works around the 3 different way we can represent windows paths
def normalize_path(path)
path.downcase.gsub(/\\+/, '/')
end
def add_to_plugin_path(path)
::Ohai::Config.ohai['plugin_path'] << path # new format
end
# we need to warn the user that unless the path for this plugin is in Ohai's
# plugin path already we're going to have to reload Ohai on every Chef run.
# Ideally in future versions of Ohai /etc/chef/ohai/plugins is in the path.
def plugin_path_warning
Chef::Log.warn("The Ohai plugin_path does not include #{desired_plugin_path}. \
Ohai will reload on each chef-client run in order to add this directory to the \
path unless you modify your client.rb configuration to add this directory to \
plugin_path. The plugin_path can be set via the chef-client::config recipe. \
See 'Ohai Settings' at https://docs.chef.io/config_rb_client.html#ohai-settings \
for more details.")
end
end
end

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
#
# Cookbook:: ohai
# 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 Ohai cookbook default recipe has no content as of the 4.0 release. See the readme for instructions on using the custom resources.')

View File

@@ -0,0 +1,42 @@
chef_version_for_provides '< 14.0' if respond_to?(:chef_version_for_provides)
resource_name :ohai_hint
property :hint_name, String, name_property: true
property :content, Hash
property :compile_time, [true, false], default: true
action :create do
directory ::Ohai::Config.ohai.hints_path.first do
action :create
recursive true
end
file ohai_hint_file_path(new_resource.hint_name) do
action :create
content format_content(new_resource.content)
end
end
action :delete do
file ohai_hint_file_path(new_resource.hint_name) do # ~FC009
action :delete
notifies :reload, ohai[reload ohai post hint removal]
end
ohai 'reload ohai post hint removal' do
action :nothing
end
end
action_class do
include OhaiCookbook::HintHelpers
end
# this resource forces itself to run at compile_time
def after_created
return unless compile_time
Array(action).each do |action|
run_action(action)
end
end

View File

@@ -0,0 +1,69 @@
property :plugin_name, String, name_property: true
property :path, String
property :source_file, String
property :cookbook, String
property :resource, [:cookbook_file, :template], default: :cookbook_file
property :variables, Hash
property :compile_time, [true, false], default: true
action :create do
# why create_if_missing you ask?
# no one can agree on perms and this allows them to manage the perms elsewhere
directory desired_plugin_path do
action :create
recursive true
not_if { ::File.exist?(desired_plugin_path) }
end
if new_resource.resource.eql?(:cookbook_file)
cookbook_file ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do
cookbook new_resource.cookbook
source new_resource.source_file || "#{new_resource.plugin_name}.rb"
notifies :reload, "ohai[#{new_resource.plugin_name}]", :immediately
end
elsif new_resource.resource.eql?(:template)
template ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do
cookbook new_resource.cookbook
source new_resource.source_file || "#{new_resource.plugin_name}.rb"
variables new_resource.variables
notifies :reload, "ohai[#{new_resource.plugin_name}]", :immediately
end
end
# Add the plugin path to the ohai plugin path if need be and warn
# the user that this is going to result in a reload every run
unless in_plugin_path?(desired_plugin_path)
plugin_path_warning
Chef::Log.warn("Adding #{desired_plugin_path} to the Ohai plugin path for this chef-client run only")
add_to_plugin_path(desired_plugin_path)
reload_required = true
end
ohai new_resource.plugin_name do
action :nothing
action :reload if reload_required
end
end
action :delete do
file ::File.join(desired_plugin_path, new_resource.plugin_name + '.rb') do
action :delete
notifies :reload, 'ohai[reload ohai post plugin removal]'
end
ohai 'reload ohai post plugin removal' do
action :nothing
end
end
action_class do
include OhaiCookbook::PluginHelpers
end
# this resource forces itself to run at compile_time
def after_created
return unless compile_time
Array(action).each do |action|
run_action(action)
end
end