NameError Cannot find a resource for apt_update on ubuntu version 14.04


#1

i get the below error when i connect to a node from the workstation and run the chef client, i have the apt folder uploaded. Dont know what is wrong
ssh node 'sudo chef-client'
[2018-09-15T16:30:39+00:00] INFO: Forking chef instance to converge...
[2018-09-15T16:30:40+00:00] INFO: *** Chef 11.8.2 ***
[2018-09-15T16:30:40+00:00] INFO: Chef-client pid: 1827
[2018-09-15T16:30:41+00:00] INFO: Run List is [recipe[my_cookbook]]
[2018-09-15T16:30:41+00:00] INFO: Run List expands to [my_cookbook]
[2018-09-15T16:30:41+00:00] INFO: Starting Chef Run for node
[2018-09-15T16:30:41+00:00] INFO: Running start handlers
[2018-09-15T16:30:41+00:00] INFO: Start handlers complete.
[2018-09-15T16:30:42+00:00] INFO: HTTP Request Returned 404 Not Found:
[2018-09-15T16:30:43+00:00] INFO: Loading cookbooks [apt, my_cookbook]

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/my_cookbook/recipes/default.rb

NameError

Cannot find a resource for apt_update on ubuntu version 14.04

Cookbook Trace:

/var/chef/cache/cookbooks/apt/recipes/default.rb:40:in from_file' /var/chef/cache/cookbooks/my_cookbook/recipes/default.rb:10:infrom_file'

Relevant File Content:


/var/chef/cache/cookbooks/apt/recipes/default.rb:

33: if node['apt']['compile_time_update'] && apt_installed?
34: apt_update('compile time') do
35: frequency node['apt']['periodic_update_min_delay']
36: ignore_failure true
37: end.run_action(:periodic)
38: end
39:
40>> apt_update 'periodic' do
41: frequency node['apt']['periodic_update_min_delay']
42: end
43:
44: # For other recipes to call to force an update
45: execute 'apt-get update' do
46: command 'apt-get update'
47: ignore_failure true
48: action :nothing
49: notifies :touch, 'file[/var/lib/apt/periodic/update-success-stamp]', :immediately

[2018-09-15T16:30:43+00:00] ERROR: Running exception handlers
[2018-09-15T16:30:43+00:00] ERROR: Exception handlers complete
[2018-09-15T16:30:43+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2018-09-15T16:30:43+00:00] ERROR: Cannot find a resource for apt_update on ubuntu version 14.04
[2018-09-15T16:30:43+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit co
de 1)

Below is my cookbook

    Default.rb                                      

Cookbook Name:: test

Recipe:: default

Copyright 2015, YOUR_COMPANY_NAME

All rights reserved - Do Not Redistribute

include_recipe "apt"

package 'nginx' do
action :install
end

service 'nginx' do
action [:start, :enable]
end

file '/usr/share/nginx/html/index.html' do
content '

hello world

'

#2

The first thing that stands out is that you're using Chef 11.8.2 which was end of lifed many years ago. If you upgrade to modern Chef (14) then the apt_update resource is built in to Chef. I highly recommend you get on at least a supported version as 11 or 12 are both End of Life.


#3

im actually using chefdk


#4

Based on [2018-09-15T16:30:40+00:00] INFO: *** Chef 11.8.2 *** somewhere in the mix you're still using an unsupported and very end of life chef-client. The ChefDK version you are using may not match the version being used on the node. Either way, a modern ChefDK (3) includes a similarly modern version of chef-client (14).