Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect host operating system distro in chef-solo deploy bash script

When deploying a chef-solo setup you need to switch between using sudo or not eg:

    bash install.sh  

and

    sudo bash install.sh

Depending on the distro on the host server. How can this be automated?

like image 217
offwhite Avatar asked Mar 27 '13 14:03

offwhite


1 Answers

ohai already populates these attributes and are readily available in your recipe for example,

"platform": "centos",
"platform_version": "6.4",
"platform_family": "rhel",

you can reference to these as

 if node[:platform_family].include?("rhel")
    ...
 end

To see what other attributes ohai sets, just type

 ohai

on the command line.

like image 65
Litmus Avatar answered Oct 22 '22 16:10

Litmus