DEV Community


Posted on • Originally published at

Stream command output from a Chef recipe

In this article I will show you how to see, in real-time, a command output from a Chef recipe.

Executing a command, the chef way

As a command example, as I'm working with it right now, let's take the Kubernetes installation tool: kubeadm.

This app tells you what he is doing in its output.

I first did this:

While this runs the command successfully, all the command's output is invisible:

* execute[kubeadm init] action run
           - execute     kubeadm init     --token=vfopfv.fgum14jkv3ldssu8     --pod-network-cidr=     --service-cidr=     --service-dns-domain=cluster.local     --apiserver-advertise-address=

Enter fullscreen mode Exit fullscreen mode

Executing a command, the Ruby way

Let's now make this real-time :

Now you get the command output in real time:

         * ruby_block[kubeadm init] action run[init] Using Kubernetes version: v1.15.1
       [preflight] Running pre-flight checks
       [preflight] Pulling images required for setting up a Kubernetes cluster
       [preflight] This might take a minute or two, depending on the speed of your internet connection
Enter fullscreen mode Exit fullscreen mode


Top comments (0)