Update the mediawiki cookbook and upstream cookbooks
Compatibility with Chef 14
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
~FC016
|
||||
~FC009
|
||||
@@ -2,6 +2,39 @@
|
||||
|
||||
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.
|
||||
|
||||
@@ -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)
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
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
|
||||
@@ -16,7 +18,7 @@ Contains custom resources for adding Ohai hints and installing custom Ohai plugi
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 12.5+
|
||||
- Chef 12.7+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
@@ -113,9 +115,11 @@ You can check for the creation or deletion of ohai plugins with chefspec using t
|
||||
- create_ohai_plugin
|
||||
- delete_ohai_plugin
|
||||
|
||||
## License & Authors
|
||||
## Maintainers
|
||||
|
||||
**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))
|
||||
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.
|
||||
|
||||
|
||||
35
cookbooks/ohai/libraries/hint_helpers.rb
Normal file
35
cookbooks/ohai/libraries/hint_helpers.rb
Normal 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
|
||||
@@ -1,41 +0,0 @@
|
||||
#
|
||||
# Cookbook:: ohai
|
||||
# Library:: matchers
|
||||
#
|
||||
# Author:: Tim Smith (<tsmith@chef.io>)
|
||||
#
|
||||
# Copyright:: 2016-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.
|
||||
#
|
||||
|
||||
if defined?(ChefSpec)
|
||||
ChefSpec.define_matcher :ohai_hint
|
||||
ChefSpec.define_matcher :ohai_plugin
|
||||
|
||||
def create_ohai_hint(resource)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ohai_hint, :create, resource)
|
||||
end
|
||||
|
||||
def delete_ohai_hint(resource)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ohai_hint, :delete, resource)
|
||||
end
|
||||
|
||||
def create_ohai_plugin(resource)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ohai_plugin, :create, resource)
|
||||
end
|
||||
|
||||
def delete_ohai_plugin(resource)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:ohai_plugin, :delete, resource)
|
||||
end
|
||||
end
|
||||
77
cookbooks/ohai/libraries/plugin_helpers.rb
Normal file
77
cookbooks/ohai/libraries/plugin_helpers.rb
Normal 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
@@ -1,3 +1,7 @@
|
||||
|
||||
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
|
||||
@@ -8,14 +12,14 @@ action :create do
|
||||
recursive true
|
||||
end
|
||||
|
||||
file ohai_hint_path do
|
||||
file ohai_hint_file_path(new_resource.hint_name) do
|
||||
action :create
|
||||
content build_content
|
||||
content format_content(new_resource.content)
|
||||
end
|
||||
end
|
||||
|
||||
action :delete do
|
||||
file ohai_hint_path do
|
||||
file ohai_hint_file_path(new_resource.hint_name) do # ~FC009
|
||||
action :delete
|
||||
notifies :reload, ohai[reload ohai post hint removal]
|
||||
end
|
||||
@@ -25,25 +29,8 @@ action :delete do
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
def ohai_hint_path
|
||||
path = ::File.join(::Ohai::Config.ohai.hints_path.first, new_resource.hint_name)
|
||||
path << '.json' unless path.end_with?('.json')
|
||||
path
|
||||
end
|
||||
|
||||
def build_content
|
||||
# passing nil to file produces deprecation warnings so pass an empty string
|
||||
return nil if new_resource.content.nil? || new_resource.content.empty?
|
||||
JSON.pretty_generate(new_resource.content)
|
||||
end
|
||||
|
||||
def file_content(path)
|
||||
return JSON.parse(::File.read(path))
|
||||
rescue JSON::ParserError
|
||||
Chef::Log.debug("Could not parse JSON in ohai hint at #{ohai_hint_path}. It's probably an empty hint file")
|
||||
return nil
|
||||
end
|
||||
action_class do
|
||||
include OhaiCookbook::HintHelpers
|
||||
end
|
||||
|
||||
# this resource forces itself to run at compile_time
|
||||
|
||||
@@ -56,56 +56,8 @@ action :delete do
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
# 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
|
||||
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)
|
||||
# get the directory where we plan to stick the plugin (not the actual file path)
|
||||
desired_dir = ::File.directory?(path) ? path : ::File.dirname(path)
|
||||
|
||||
case node['platform']
|
||||
when 'windows'
|
||||
::Ohai::Config.ohai['plugin_path'].map(&:downcase).include?(desired_dir.downcase)
|
||||
else
|
||||
::Ohai::Config.ohai['plugin_path'].include?(desired_dir)
|
||||
end
|
||||
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
|
||||
action_class do
|
||||
include OhaiCookbook::PluginHelpers
|
||||
end
|
||||
|
||||
# this resource forces itself to run at compile_time
|
||||
|
||||
Reference in New Issue
Block a user