Update the mediawiki cookbook and upstream cookbooks

Compatibility with Chef 14
This commit is contained in:
Greg Karékinian
2019-04-08 11:20:12 +02:00
parent 6e3e8cde1b
commit 777b85c2ab
312 changed files with 5603 additions and 14219 deletions

View File

@@ -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

View File

@@ -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