How can I find a disc in a chef's recipe?

While the chef's recipe is running, I want to determine if there is enough free disk space to complete the operation.

What is the best way to do this?

+4
source share
1 answer

Ohai detects certain a node properties every time it starts. These properties are captured as automatic attributes and are available to you as node attributes.

The node ['filesystem'] attribute contains information about each of the devices on your system. To get the available space in kb for a specific device:

node['filesystem']['/dev/xvda1']['kb_available'] 

The following is an example of the Ohai JSON file system attribute:

  "filesystem": { "/dev/xvda1": { "kb_size": "521882300", "kb_used": "119914572", "kb_available": "375474240", "percent_used": "25%", "mount": "/", "fs_type": "ext4", "mount_options": [ "rw" ], "uuid": "248b8180-f75f-48fc-a8be-e3ff3506c4d6" }, "tmpfs": { "kb_size": "1987292", "kb_used": "0", "kb_available": "1987292", "percent_used": "0%", "mount": "/dev/shm", "fs_type": "tmpfs", "mount_options": [ "rw", "rootcontext=\"system_u:object_r:tmpfs_t:s0\"" ] } } 
+11
source

All Articles