When you test your Chef cookbook in Test Kitchen you may get the following warning: warning: Insecure world writable dir MY_DIRECTORY/PATH in PATH, mode 040777 To stop this warning message, execute
Tag Archives: Ruby
Ruby tips and tricks
Bang methods (Exclamation point at the end of the method name) There are methods that have a permanent or dangerous version. The exclamation point designates to use the dangerous version of the method. String manipulation The bang versions of the string manipulation methods (with the exclamation point), modify the string variable in place. Some of these methods …
Undefined method or attribute error in a Chef recipe
There are multiple reasons Chef can display the following error message NoMethodError ————- Undefined method or attribute `…’ on `node’ There are many ways to reference an attribute in a Chef recipe: node[‘ATTRIBUTE_NAME’] (the recommended style) node[“ATTRIBUTE_NAME”] node[:ATTRIBUTE_NAME] (use it only if the single or double quotes (‘ or “) would cause a problem …
Continue reading “Undefined method or attribute error in a Chef recipe”
Generate a GUID in Chef with Ruby
When you need a unique string to name a resource in your Chef scrip, generate a GUID with SecureRandom.uuid To make sure the resource always gets a unique name: log “#{SecureRandom.uuid}” do message ‘My message’ level :info end
Last characters of a string in Ruby
To get the last characters of a string in Ruby, use the following instructions. If the string is shorter than the selected number of characters, the entire string is returned. a = ‘12345’ b = a[-3..-1] || a puts b Returns 345
SSL certificate is missing after installing ChefDK
When you install a new version of ChefDK and try to run Test Kitchen converge you may get the following error message >>>>>> ——Exception——- >>>>>> Class: Kitchen::ActionFailed >>>>>> Message: Failed to complete #create action: [SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed To solve the problem add the following to the Windows …
Continue reading “SSL certificate is missing after installing ChefDK”
Winrm is missing after installing ChefDK
When you install the new version of ChefDK you may get the following error message when you try to run Test Kitchen !!!!!! The `winrm` gem is missing and must be installed or cannot be properly activated. Run `gem install winrm –version ‘[“~> 1.6”]’` or add the following to your Gemfile if you are using …
Berkshelf is missing after installing ChefDK
When you install a new version of ChefDK and try to run Test Kitchen the following error message may appear !!!!!! The `berkshelf’ gem is missing and must be installed or cannot be properly activated. Run `gem install berkshelf` or add the following to your Gemfile if you are using Bundler: `gem ‘berkshelf’`. To reinstall …
Continue reading “Berkshelf is missing after installing ChefDK”
EC2 driver is missing after installing ChefDK
After installing a new version of ChefDK you may get the following error message when you try to run Test Kitchen: Message: Could not load the ‘ec2’ driver from the load path. Please ensure that your driver is installed as a gem or included in your Gemfile if using Bundler. To install the EC2 driver …
Continue reading “EC2 driver is missing after installing ChefDK”
Error in Test Kitchen after installing ChefDK
You may get the following error when you try to run Test Kitchen after installing the latest version of ChefDK: $ kitchen C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’: cannot load such file — dl/import (LoadError) from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’ from C:/Ruby22/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:1:in `<top (required)>’ from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’ from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’ from C:/Ruby22/lib/ruby/gems/2.2.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:5:in `<top (required)>’ from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’ from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’ from …
Continue reading “Error in Test Kitchen after installing ChefDK”