nathwill / chef-systemd

resource-driven chef cookbook for managing linux systems via systemd
Apache License 2.0
44 stars 33 forks source link

knife 12.5.1: uninitialized constant Chef::Resource::SystemdUnit #114

Closed tiago-cruz-movile closed 7 years ago

tiago-cruz-movile commented 7 years ago

OK: Chef: 12.20.3 ERROR: Chef: 12.5.1

[root@mexico01 ~]# chef-client -o systemd
[2017-09-13T12:49:28+00:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 12.5.1
[2017-09-13T12:49:28+00:00] INFO: *** Chef 12.5.1 ***
[2017-09-13T12:49:28+00:00] INFO: Chef-client pid: 20865
[2017-09-13T12:49:31+00:00] WARN: Run List override has been provided.
[2017-09-13T12:49:31+00:00] WARN: Overridden Run List: [recipe[systemd]]
[2017-09-13T12:49:32+00:00] INFO: Run List is [recipe[systemd]]
[2017-09-13T12:49:32+00:00] INFO: Run List expands to [systemd]
[2017-09-13T12:49:32+00:00] INFO: Running start handlers
[2017-09-13T12:49:32+00:00] INFO: Start handlers complete.
resolving cookbooks for run list: ["systemd"]
[2017-09-13T12:49:33+00:00] INFO: Loading cookbooks [systemd@3.1.1, compat_resource@12.19.0]
[2017-09-13T12:49:33+00:00] INFO: Skipping removal of obsoleted cookbooks from the cache
Synchronizing Cookbooks:
  - systemd (3.1.1)
  - compat_resource (12.19.0)
Compiling Cookbooks...

================================================================================
Recipe Compile Error in /var/cache/chef/cookbooks/systemd/resources/automount.rb
================================================================================

NameError
---------
uninitialized constant Chef::Resource::SystemdUnit

Cookbook Trace:
---------------
  /var/cache/chef/cookbooks/systemd/libraries/resource_factory.rb:59:in `build_resource'
  /var/cache/chef/cookbooks/systemd/libraries/resource_factory.rb:28:in `included'
  /var/cache/chef/cookbooks/systemd/resources/automount.rb:5:in `include'
  /var/cache/chef/cookbooks/systemd/resources/automount.rb:5:in `class_from_file'
  /var/cache/chef/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb:41:in `build_from_file'

Relevant File Content:
----------------------
/var/cache/chef/cookbooks/systemd/libraries/resource_factory.rb:

 52:            # Avoid chef-sugar before/after filter conflicts
 53:            # https://github.com/nathwill/chef-systemd/issues/103
 54:            define_method(:before) { |arg| unit_before arg }
 55:            define_method(:after) { |arg| unit_after arg }
 56:  
 57:            default_action :create
 58:  
 59>>           Chef::Resource::SystemdUnit.allowed_actions.each do |actn|
 60:              action actn do
 61:                systemd_unit "#{new_resource.name}.#{resource_type}" do
 62:                  triggers_reload new_resource.triggers_reload
 63:                  user new_resource.user if new_resource.user
 64:                  content property_hash(data)
 65:                  verify new_resource.verify
 66:                  action actn
 67:                end
 68:              end

Running handlers:
[2017-09-13T12:49:33+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-09-13T12:49:33+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 05 seconds
[2017-09-13T12:49:33+00:00] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
[2017-09-13T12:49:33+00:00] ERROR: uninitialized constant Chef::Resource::SystemdUnit
[2017-09-13T12:49:34+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
nathwill commented 7 years ago

yes; you'll need a newer version of Chef that includes Chef::Resource::SystemdUnit. We require Chef >= 12.11. If you can't do that, you can just pin to systemd cookbook v2.x.