Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 RUBY


  How to check which Ohai plugin hangs in chef client run

Ohai plugins are very important components in chef client which aims to provide resource management automation on a server. The data discovered by Ohai plugins are describing the current state of the server and they will be used to maintain the server in a desired state. Each Ohai plugin discovers a specific pierce of information about the server such as cpu, memory, middleware etc.However, there are rare occasions(well I am a bit optimistic here) someone may find that the chef client run is hanging and it hangs at Ohai plugin discovery stage. Given every server has its own unique co...

4,895 0       HOW TO CHEF-CLIENT OHAI UPTIME HANG


  A plugin to update last_error in Delayed Job

delayed_job is a process based asynchronous task processing gem which can be ran at background. It will fork the specified number of processes to execute the tasks asynchronously. The task status is usually stored in the database so that it can be easily integrated into a Rails application where asynchronous job execution is desired.Normally when a job fails to execute or error occurs, it would save the error into the database with the column last_error. Ideally all these will be handled by the delayed_job gem itself, we no need to worry about anything. However, in some extreme cases, we ...

3,672 0       RUBY RUBY ON RAILS DELAYED JOB LAST_ERROR


  Be careful when running knife vault command

While using Chef, one would frequently use knife commands which are used to manage resources on the Chef server. One can list all nodes, data bags, vault items and many other stuff on the Chef server. In this post, we would cover one command which may need your attention when using it -- knife vault.On Chef server, one can store data to data bags which can be accessed by registered clients. These data bags usually store the data in plain text format. In some cases, one would need to store data secretly on the Chef server, Chef provides the encrypted data bag which uses a shared symmetric secre...

7,393 0       CHEF KNIFE VAULT KNIFE DATA BAG CHEF-VAULT


  Handle NXDomain error when resolving IP address in Ruby DNS resolver

In another post, we covered how to resolve SystemStackError when resolving IP address in Ruby. In this post, we would cover another common issue where a NXDomain error is returned when resolving an IP address. The NXDomain error means that the queried domain name does not exist in the DNS.In Ruby, DNS resolver library will use /etc/resolv.conf by default get the name servers to resolve the domain name. There are multiple DNS name servers can be specified in /etc/resolv.conf with below format.nameserver nameserver nameserver ...By default, only the top MAXNS name servers(3 in Linux by...

4,189 0       RUBY RUBY ON RAILS NETWORK DNS NXDOMAIN


  Resolve SystemStackError issue when resolving IP address in Ruby

In Ruby, Resolv is the default DNS resolution implementation. It can be used to resolve IP address of a hostname. To use it, one just needs to require 'resolv' in the code. But sometimes, a user would want to check /etc/hosts first or some other mechanisms to resolve an IP address. In this case, one can require 'resolv-replace' and then replace the default DNS resolvers with customized DNS resolvers.For example, using resolv-replace, one would writerequire 'resolv-replace'Resolv::DefaultResolver.replace_resolvers([Resolv::Hosts.new, Resolv::DNS.new])Resolv.getaddress 'some-site.com'In this cas...

5,327 0       RUBY RUBY ON RAILS NETWORK


  Ruby WinRM undefined method `split' for nil:NilClass

WinRM service is a service provided by Windows to enable remote access a Windows system. It is similar to what SSH is for *nix. And it is frequently used in applications which want to automate process or accessing remote Windows system and perform actions on them. Ruby also provided the WinRM gem which is an implementation of the WinRM service. When using WinRM gem, one may often want to use :negotiate as the transport protocol for authentication. This transport will negotiate using different security mechanisms depends on the setting. These mechanisms include Kerberos, NTLM, Basic e...

4,355 0       RUBY WINRM INIT_AUTH PROXY


  Fix issue "cannot load such file -- bcrypt_ext (LoadError)"

bcrypt() is a sophisticated and secure hash algorithm designed by The OpenBSD project for hashing passwords. The bcrypt Ruby gem provides a simple wrapper for safely handling passwords.However, sometimes the rails application would fail to start after installing the bcrypt gem on Windows. The error would look similar to below.The issue is that it fails to load the bcrypt_ext which is the native built extension, the reason may be the library is wrongly built. To fix this issue, below steps can be followed. Open a command consolecd to the gem directory C:\RailsInstaller\Ruby2.2.0\...

8,577 1       RUBY SOLUTION RUBY ON RAILS BCRYPT LOAD ERROR


  How to write your own DSL in Ruby

DSL(Domain Specific Language) is a language defined to fulfill some domain specific requirements to ease people's work. It can be used to define attributes and actions of a domain easily and cleanly. And it is often created based on some common observations or micro patterns of some domain.In Ruby world, there are quite a few places people can find DSL. For example, Ruby itself, Chef recipes.To create a class in Ruby, the traditional OOP way would look like.class User @name = nil @email = nil def name @name end def name=(val) @name = val end def email @email end def email=(va...

7,485 0       TUTORIAL RUBY DSL