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

13,285

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.

Share:
13,285
offwhite
Author by

offwhite

Developer. idiot.

Updated on July 22, 2022

Comments

  • offwhite
    offwhite almost 2 years

    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?