Maybe someone faced with the same situation
We have a clean instance on redis who try to put a chef
Default recipe has only
include_recipe "redisio :: install"
When I cook getting the following error
Enviroment AWS ec2.micro ubuntu 12.04
When I run cook to receive an error
================================================================================
Recipe Compile Error in /tmp/chef-solo/cookbooks/main/recipes/default.rb
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/tmp/chef-solo/cookbooks/ulimit/recipes/default.rb:13:in `block in from_file'
/tmp/chef-solo/cookbooks/ulimit/recipes/default.rb:12:in `from_file'
/tmp/chef-solo/cookbooks/redisio/recipes/install.rb:20:in `from_file'
/tmp/chef-solo/cookbooks/main/recipes/default.rb:11:in `from_file'
Relevant File Content:
----------------------
/tmp/chef-solo/cookbooks/ulimit/recipes/default.rb:
6: # All rights reserved - Do Not Redistribute
7: #
8: ulimit = node['ulimit']
9:
10: case node[:platform]
11: when "debian", "ubuntu"
12: template "/etc/pam.d/su" do
13>> cookbook ulimit['pam_su_template_cookbook']
14: end
15: end
16:
[2013-04-06T14:09:50+00:00] ERROR: Running exception handlers
[2013-04-06T14:09:50+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2013-04-06T14:09:50+00:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out
[2013-04-06T14:09:50+00:00] FATAL: NoMethodError: undefined method `[]' for nil:NilClass
ERROR: RuntimeError: chef-solo failed. See output above.
Resource https://github.com/Piom/redis-chef.git
I ran into this issue as well. I have one way to solve it but I am also just started looking into chef.
the issue is redisio depends on ulimit and looks like the recipe does not handle when you don't have any attributes for ulimit defined.
ulimit = node['ulimit']
try to get a hash of attributes but is getting nil. So if you define some attributes it should work.
there might be an updated version of the recipe since you downloaded it. If not in ulimit/attributes/default.rb I have default['ulimit']['pam_su_template_cookbook'] = nil and it worked for me.
ulimit let you limit resources. I think it can be used to limit redis resources. (again I am new too.) So the better way might be figure how you want to configure ulimit and set the correct attribute rather than nil
Related
I'm trying to get a server up and running via knife bootstrap via this command:
knife bootstrap "<ip-address>"
-x ec2-user
-r recipe[connector],recipe[all-servers]
-N "serv-name"
-E staging
-i "~/.chef/mycert.pem"
--sudo
--no-host-key-verify
The all-servers recipe includes dependencies for windows that are broken in chef 13+:
(TLDRS, full stack traces are at the bottom)
13: undefined method “kernel” (outdated 7-zip cookbook dependency 3.0 instead of 2.0)
14: cannot load such file -- chef/mixin/language (windows cookbook dependency, 3.0 + for windows cookbook would fix this)
15: manual license acceptance required and cannot load such file -- chef/mixin/language error (windows cookbook dependency, 3.0 + for windows cookbook would fix this)
The big problem is that a bunch of under-maintained services use the older versions and upgrading any of them is likely to cause multitudes of problems throughout the chef org, so I want to have just this server use a newer version of either the windows or 7-zip cookbook.
What I tried to do to solve for this was created a new cookbook "all-servers-dev" and created dev versions of all the cookbooks in the dependency tree all the way down to "windows" where I downloaded the updated windows cookbook and replaced it at the bottom of the dependency tree. This didn't work however because chef keeps trying to sync all cookbooks even the windows one even though it's not included anywhere in the dependency tree that I can find.
I even tried removing the all-servers recipe and just installing the connector recipe whose only dependency is yum-epel whose only dependency is "compat_resource" which has no dependencies.
13.12.14
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/seven_zip/attributes/default.rb
================================================================================
NoMethodError
-------------
undefined method `kernel' for #<Chef::Node::Attribute:xxxxxxxxxxxxxxxxx>
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/seven_zip/attributes/default.rb:21:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/seven_zip/attributes/default.rb:
14: # Unless required by applicable law or agreed to in writing, software
15: # distributed under the License is distributed on an "AS IS" BASIS,
16: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: # See the License for the specific language governing permissions and
18: # limitations under the License.
19: #
20:
21>> if kernel['machine'] =~ /x86_64/
22: default['seven_zip']['url'] = 'http://www.7-zip.org/a/7z1514-x64.msi'
23: default['seven_zip']['checksum'] = 'xxxxxxxxxx'
24: default['seven_zip']['package_name'] = '7-Zip 15.14 (x64 edition)'
25: else
26: default['seven_zip']['url'] = 'http://www.7-zip.org/a/7z1514.msi'
27: default['seven_zip']['checksum'] = 'xxxxxxxxxx'
28: default['seven_zip']['package_name'] = '7-Zip 15.14'
29: end
30:
System Info:
------------
chef_version=13.12.14
platform=amazon
platform_version=2017.03
ruby=ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
program_name=chef-client worker: ppid=3493;start=17:29:14;
executable=/opt/chef/bin/chef-client
Running handlers:
[2019-12-04T17:29:32+00:00] ERROR: Running exception handlers
Running handlers complete
[2019-12-04T17:29:32+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 17 seconds
[2019-12-04T17:29:32+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2019-12-04T17:29:32+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-12-04T17:29:32+00:00] ERROR: undefined method `kernel' for #<Chef::Node::Attribute:xxxxxxxxxx>
[2019-12-04T17:29:32+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
14.14.29
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/windows/libraries/windows_package.rb
================================================================================
LoadError
---------
cannot load such file -- chef/mixin/language
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/windows/libraries/windows_package.rb:7:in `<top (required)>'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/windows/libraries/windows_package.rb:
1: require 'chef/resource/lwrp_base'
2: require 'chef/provider/lwrp_base'
3:
4: require 'win32/registry' if RUBY_PLATFORM =~ /mswin|mingw32|windows/
5:
6: require 'chef/mixin/shell_out'
7>> require 'chef/mixin/language'
8: class Chef
9: class Provider
10: class WindowsCookbookPackage < Chef::Provider::LWRPBase
11: include Chef::Mixin::ShellOut
12: include Windows::Helper
13:
14: # the logic in all action methods mirror that of
15: # the Chef::Provider::Package which will make
16: # refactoring into core chef easy
System Info:
------------
chef_version=14.14.29
platform=amazon
platform_version=2017.03
ruby=ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux]
program_name=/usr/bin/chef-client
executable=/opt/chef/bin/chef-client
Running handlers:
[2019-12-04T18:06:28+00:00] ERROR: Running exception handlers
Running handlers complete
[2019-12-04T18:06:28+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 35 seconds
[2019-12-04T18:06:28+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2019-12-04T18:06:28+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-12-04T18:06:28+00:00] FATAL: LoadError: cannot load such file -- chef/mixin/language
15.5.17
Chef has a new prompt that’s unhandled by knife bootstrap:
Do you accept the 2 product licenses (yes/no)?
You can’t accept these from the bootstrap CLI, so you have to ssh to the server and run chef manually which then results in the same error as 14:
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/windows/libraries/windows_package.rb
================================================================================
LoadError
---------
cannot load such file -- chef/mixin/language
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/windows/libraries/windows_package.rb:7:in `<top (required)>'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/windows/libraries/windows_package.rb:
1: require 'chef/resource/lwrp_base'
2: require 'chef/provider/lwrp_base'
3:
4: require 'win32/registry' if RUBY_PLATFORM =~ /mswin|mingw32|windows/
5:
6: require 'chef/mixin/shell_out'
7>> require 'chef/mixin/language'
8: class Chef
9: class Provider
10: class WindowsCookbookPackage < Chef::Provider::LWRPBase
11: include Chef::Mixin::ShellOut
12: include Windows::Helper
13:
14: # the logic in all action methods mirror that of
15: # the Chef::Provider::Package which will make
16: # refactoring into core chef easy
System Info:
------------
chef_version=15.5.17
platform=amazon
platform_version=2017.03
ruby=ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
program_name=/usr/bin/chef-client
executable=/opt/chef/bin/chef-client
Running handlers:
[2019-12-04T18:14:03+00:00] ERROR: Running exception handlers
Running handlers complete
[2019-12-04T18:14:03+00:00] ERROR: Exception handlers complete
Chef Infra Client failed. 0 resources updated in 18 seconds
[2019-12-04T18:14:03+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2019-12-04T18:14:03+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-12-04T18:14:03+00:00] FATAL: LoadError: cannot load such file -- chef/mixin/language
15.5.17 Chef has a new prompt that’s unhandled by knife bootstrap:
Do you accept the 2 product licenses (yes/no)?
You can’t accept these from the bootstrap CLI, so you have to ssh to
the server and run chef manually
that is incorrect, you can use --chef-license accept when you bootstrap the node to accept the chef license
if i understood your right, you wish to pin the different versions of the same cookbooks collection. if that is the case, you can acheive it by using environment:
Cookbook versions can be pinned in each environment, which allows you to control the rollout of new cookbook releases through successive testing environments before releasing new cookbook versions into production environments. See the environment format examples below for the cookbook pinning syntax.
so just remember to associate your nodes with specific chef environment, such that each environment has its own cookbook collection.
With version >=3.4.5 of the windows cookbook release, our instance builds are failing, since we're still on Chef 11.10 / Berkshelf 3.2.0.
I added cookbook 'windows', '= 3.4.4' to our Berksfile, but the build is still failing, since it's still loading windows 4.1.1, even with the added entry to Berksfile.
How do I override OpsWorks to use windows 3.4.4?
Here's the full error log:
Recipe Compile Error in /var/lib/aws/opsworks/cache.stage2/cookbooks/windows/resources/auto_run.rb
NoMethodError
-------------
undefined method `property' for #<Class:0x007f72ac6f8b20>
Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/windows/resources/auto_run.rb:22:in `class_from_file'
Relevant File Content:
----------------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/windows/resources/auto_run.rb:
21:
22>> property :program_name, String, name_property: true
23: property :path, String, coerce: proc { |x| x.tr('/', '\\') }
24: property :args, String
25: property :root, Symbol,
26: equal_to: %i(machine user),
27: default: :machine
28:
29: alias_method :program, :path
30:
31: action :create do
add below in berksfile, this should work for 11+ versions
cookbook 'windows', '<= 1.44.3'
I fixed this by adding this to the Berksfile
cookbook 'windows', '= 2.0.2'
Update cookbooks, setup. I also added it to the wrong git branch, so lost about 20 minutes figuring that out.
I have created a template in chef, sending the value from attributes and recipes but getting error :
[2015-12-09T08:09:19-05:00] ERROR: Running exception handlers
[2015-12-09T08:09:19-05:00] ERROR: Exception handlers complete
[2015-12-09T08:09:19-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-12-09T08:09:19-05:00] INFO: Sending resource update report (run-id: a9175420-0358-4631-8d30-664fdfd792c0)
[2015-12-09T08:09:19-05:00] ERROR: undefined method `default' for Chef::Resource::Template
[2015-12-09T08:09:19-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
How to resolve the error:
I have defined the attribute as :
default['abc']['LOG_FILE']=''
and in recipe it is
variables(
:LOG_FILE => default['abc']['LOG_FILE'],
Your syntax is wrong, you need to use node instead of default when referencing attributes:
variables(
:LOG_FILE => node['abc']['LOG_FILE'],
I'm getting some very unusual behaviour.
I followed these instructions for installing jetty but used the latest version instead (9.1.1v20140108)
I had reason to restart Jetty and found I was getting these errors (logged in as root)
Starting Jetty: FAILED Wed Feb 5 12:35:59 EST 2014
So I spent 30 mins looking for an answer, then for reasons I can't recall, I did service jetty check and it was running (had a pid).
So I tried again with service Jetty stop:
root#erp:/var/log# service jetty stop
/etc/init.d/jetty: line 13: chkconfig:: command not found
/etc/init.d/jetty: line 14: description:: command not found
/etc/init.d/jetty: line 15: processname:: command not found
Stopping Jetty: start-stop-daemon: warning: failed to kill 7817: No such process
1 pids were not killed
No process in pidfile '/var/run/jetty.pid' found running; none killed.
OK
None killed? Ok. Let's check that:
root#erp:/var/log# service jetty check
/etc/init.d/jetty: line 13: chkconfig:: command not found
/etc/init.d/jetty: line 14: description:: command not found
/etc/init.d/jetty: line 15: processname:: command not found
Checking arguments to Jetty:
START_INI = /srv/jetty/start.ini
JETTY_HOME = /srv/jetty
JETTY_BASE = /srv/jetty
JETTY_CONF = /srv/jetty/etc/jetty.conf
JETTY_PID = /var/run/jetty.pid
JETTY_START = /srv/jetty/start.jar
JETTY_LOGS = /srv/jetty/logs
CLASSPATH =
JAVA = /usr/bin/java
JAVA_OPTIONS = -Dsolr.solr.home=/srv/solr -Djetty.state=/srv/jetty/jetty.state -Djetty.logs=/srv/jetty/logs -Djetty.home=/srv/jetty -Djetty.base=/srv/jetty -Djava.io.tmpdir=/tmp
JETTY_ARGS = jetty.port=8085 jetty-logging.xml jetty-started.xml
RUN_CMD = /usr/bin/java -Dsolr.solr.home=/srv/solr -Djetty.state=/srv/jetty/jetty.state -Djetty.logs=/srv/jetty/logs -Djetty.home=/srv/jetty -Djetty.base=/srv/jetty -Djava.io.tmpdir=/tmp -jar /srv/jetty/start.jar jetty.port=8085 jetty-logging.xml jetty-started.xml
No PID? Let's check that:
root#erp:/var/log# service jetty start
/etc/init.d/jetty: line 13: chkconfig:: command not found
/etc/init.d/jetty: line 14: description:: command not found
/etc/init.d/jetty: line 15: processname:: command not found
Starting Jetty: FAILED Wed Feb 5 12:39:43 EST 2014
Ok, is there a PID?
root#erp:/var/log# service jetty check
/etc/init.d/jetty: line 13: chkconfig:: command not found
/etc/init.d/jetty: line 14: description:: command not found
/etc/init.d/jetty: line 15: processname:: command not found
Checking arguments to Jetty:
[edit]
Jetty running pid=7993
Weird. Sure enough, a stop and check will give the same results.
What's going on with the jetty startup script? And why am I getting FAILED errors on start which are incorrect, and fail to remove pid errors on stop which are also incorrect?
I have got a fix for all those who have been using that tutorial to install jetty
nano /etc/init.d/jetty
And change this syntax :
start-log-file="$JETTY_LOGS/start.log"
to
start-log-file="start.log"
It will fix everything in the latest jetty build and make it run like a charm.
Hope I could be of help
Ok, so this was a tricky one that was the result of a recent Java update.
I jumped into the jetty.sh at /etc/init.d/jetty and grabbed out the actually executed line:
$ /usr/bin/java -Dsolr.solr.home=/srv/solr -Djetty.state=/srv/jetty/jetty.state \
-Djetty.logs=/srv/jetty/logs -Djetty.home=/srv/jetty -Djetty.base=/srv/jetty \
-Djava.io.tmpdir=/tmp -jar /srv/jetty/start.jar jetty.port=8085 \
jetty-logging.xml jetty-started.xml
and I got this:
java.io.IOException: Cannot read file: modules/npn/npn-1.7.0_51.mod
at org.eclipse.jetty.start.Modules.registerModule(Modules.java:405)
at org.eclipse.jetty.start.Modules.registerAll(Modules.java:395)
at org.eclipse.jetty.start.Main.processCommandLine(Main.java:561)
at org.eclipse.jetty.start.Main.main(Main.java:102)
Which in turn lead me to this solution on the eclipse dev list:
$ cp /srv/jetty/modules/npn/npn-1.7.0_45.mod /srv/jetty/modules/npn/npn-1.7.0_51.mod
$ chown jetty:jetty /srv/jetty/modules/npn/npn-1.7.0_51.mod
Sure enough, Jetty restarted without hassle.
Try running below command in terminal.
sudo service jetty9 stop
I run Jetty 9.2.10.v201503 on pcDuino v3, Ubuntu 14.04. According to my experience with this relatively slow platform, this message may be reported when Jetty server itself starts longer than internal waiting loop in /etc/init.d/jetty script expects.
After adding “set –x” at the beginning of /etc/init.d/jetty file and running that script I noticed that internal waiting loop is implemented as “for” making 15 steps and periodically checking content of the $JETTY_BASE/jetty.state file.
After waiting additional couple of seconds, Jetty server is up and running ok, no errors/warrnings in log files.
in trying to write chefspec tests, following the examples on the chefspec README (https://github.com/acrmp/chefspec), I get the following error. I tried adding "depends 'chef_handler'" to my metadata.rb, without success:
$ bundle exec rspec
*[2013-08-15T11:55:01-07:00] WARN: found a directory cookbooks in the cookbook path, but it contains no cookbook files. skipping.
F*
Pending:
example::default should include
# Your recipe examples go here.
# ./spec/default_spec.rb:6
example::single_node should do something
# Your recipe examples go here.
# ./spec/single_node_spec.rb:5
Failures:
1) example::default logs the foo attribute
Failure/Error: chef_run.converge 'example::default'
Chef::Exceptions::CookbookNotFound:
Cookbook chef_handler not found. If you're loading chef_handler from another cookbook, make sure you configure the dependency in your metadata
# ./spec/default_spec.rb:16:in `block (2 levels) in <top (required)>'
I had the same problem trying to test a custom Chef handler, but I was trying to use Berkshelf to pull dependencies down via ChefSpec's native support for Berkshelf. Here's what worked for me:
Add a spec/spec_helper.rb with
require 'chefspec'
require 'chefspec/berkshelf'
Add a .rspec file to the root of the cookbook project with
--color
--format progress
--require spec_helper
Ensure your spec (spec/default_spec.rb) is setup correctly
describe 'my_chef_handlers::default' do
handler_path = File.join('files', 'default')
let(:chef_run) do
chef_runner = ChefSpec::Runner.new do |node|
node.set['chef_handler']['handler_path'] = handler_path
node.set['statsd']['server'] = '127.0.0.1'
end
chef_runner.converge 'my_chef_handlers::default'
end
end
Setting up the ChefSpec runner outside the let statement caused cookbook not found errors.
I ran into the same problem recently. Because chefspec aims to be fast and only simulate chef runs, it doesn't clone cookbooks from the chef server. It requires that the chef_handler cookbook needs to be local. By default, it looks for it at the same level as the cookbook you are testing.
e.g.
./test_cookbook
./chef_handler