Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Ohai 5.2.3 - ohai/plugin_helpers.rb is a version 6 plugin. Version 6 plugins are no longer supported by Ohai. #73

Closed
lukeseawalker opened this issue Jun 29, 2018 · 1 comment

Comments

@lukeseawalker
Copy link

Cookbook version

ohai (5.2.3)

Chef-client version

chef-client -v
Chef: 14.2.0

Platform Details

cat /etc/os-release
NAME="Amazon Linux AMI"
VERSION="2017.09"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2017.09"
PRETTY_NAME="Amazon Linux AMI 2017.09"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2017.09:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

cloud provider EC2

Error:

1530265806,,ui,message,    amazon-ebs: Synchronizing Cookbooks:
1530265806,,ui,message,    amazon-ebs:   - cfncluster (1.5.1)
1530265807,,ui,message,    amazon-ebs:   - build-essential (8.1.1)
1530265807,,ui,message,    amazon-ebs:   - poise-python (1.7.0)
1530265807,,ui,message,    amazon-ebs:   - tar (2.1.1)
1530265807,,ui,message,    amazon-ebs:   - selinux (2.1.1)
1530265807,,ui,message,    amazon-ebs:   - nfs (2.5.1)
1530265807,,ui,message,    amazon-ebs:   - sysctl (1.0.5)
1530265807,,ui,message,    amazon-ebs:   - yum (5.1.0)
1530265807,,ui,message,    amazon-ebs:   - yum-epel (3.1.0)
1530265807,,ui,message,    amazon-ebs:   - openssh (2.6.3)
1530265807,,ui,message,    amazon-ebs:   - apt (7.0.0)
1530265807,,ui,message,    amazon-ebs:   - hostname (0.4.2)
1530265807,,ui,message,    amazon-ebs:   - line (1.0.6)
1530265807,,ui,message,    amazon-ebs:   - seven_zip (3.0.0)
1530265807,,ui,message,    amazon-ebs:   - mingw (2.0.2)
1530265807,,ui,message,    amazon-ebs:   - poise (2.8.1)
1530265807,,ui,message,    amazon-ebs:   - poise-languages (2.1.2)
1530265807,,ui,message,    amazon-ebs:   - ohai (5.2.3)
1530265808,,ui,message,    amazon-ebs:   - iptables (4.3.4)
1530265808,,ui,message,    amazon-ebs:   - hostsfile (3.0.1)
1530265808,,ui,message,    amazon-ebs:   - windows (4.3.2)
1530265808,,ui,message,    amazon-ebs:   - poise-archive (1.5.0)
1530265808,,ui,message,    amazon-ebs: Installing Cookbook Gems:
1530265808,,ui,message,    amazon-ebs: Compiling Cookbooks...
1530265808,,ui,message,    amazon-ebs:
1530265808,,ui,message,    amazon-ebs: Running handlers:
1530265808,,ui,message,    amazon-ebs: [2018-06-29T09:50:08+00:00] ERROR: Running exception handlers
1530265808,,ui,message,    amazon-ebs: Running handlers complete
1530265808,,ui,message,    amazon-ebs: [2018-06-29T09:50:08+00:00] ERROR: Exception handlers complete
1530265808,,ui,message,    amazon-ebs: Chef Client failed. 0 resources updated in 04 seconds
1530265808,,ui,message,    amazon-ebs: [2018-06-29T09:50:08+00:00] FATAL: Stacktrace dumped to /tmp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
1530265808,,ui,message,    amazon-ebs: [2018-06-29T09:50:08+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
1530265808,,ui,message,    amazon-ebs: [2018-06-29T09:50:08+00:00] FATAL: Ohai::Exceptions::IllegalPluginDefinition: [DEPRECATION] Plugin at /tmp/packer-chef-solo/ohai/cookbook_plugins/ohai/plugin_helpers.rb is a version 6 plugin. Version 6 plugins are no longer supported by Ohai. This plugin will need to be updated to the v7 Ohai plugin format. See https://docs.chef.io/ohai_custom.html for v7 syntax.
1530265808,,ui,error,==> amazon-ebs: Error executing Chef: Non-zero exit status: 1

Stacktrace:

cat /tmp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
Generated at 2018-06-29 09:50:08 +0000
Ohai::Exceptions::IllegalPluginDefinition: [DEPRECATION] Plugin at /tmp/packer-chef-solo/ohai/cookbook_plugins/ohai/plugin_helpers.rb is a version 6 plugin. Version 6 plugins are no longer supported by Ohai. This plugin will need to be updated to the v7 Ohai plugin format. See https://docs.chef.io/ohai_custom.html for v7 syntax.
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.2.0/lib/ohai/loader.rb:122:in `load_plugin_class'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.2.0/lib/ohai/loader.rb:83:in `block in load_additional'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.2.0/lib/ohai/loader.rb:81:in `collect'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.2.0/lib/ohai/loader.rb:81:in `load_additional'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.2.0/lib/ohai/system.rb:115:in `run_additional_plugins'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/run_context/cookbook_compiler.rb:122:in `compile_ohai_plugins'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/run_context.rb:199:in `load'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/policy_builder/expand_node_object.rb:97:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/client.rb:512:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/client.rb:278:in `run'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/application.rb:303:in `run_with_graceful_exit_option'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/application.rb:279:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/application.rb:261:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/application/client.rb:441:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/application.rb:66:in `run'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/bin/chef-client:26:in `<top (required)>'
/usr/bin/chef-client:75:in `load'
/usr/bin/chef-client:75:in `<main>'

/tmp/packer-chef-solo/ohai/cookbook_plugins/ohai/plugin_helpers.rb is

cat /tmp/packer-chef-solo/ohai/cookbook_plugins/ohai/plugin_helpers.rb
#
# 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

which is latest version (5.2.3)

@lukeseawalker
Copy link
Author

I solved removing the .berkshelf folder stored in the profile of the user running packer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant