Testing for RHEL7/Cent7/Amzn2 vs legacy

Im looking to test for current versions of RedHat, CentOS and Amazon vs. legacy versions. Is there a common node attribute I can test for (since they share the same kernel) and not have to write multiple if statements for each? something like...

case node['some common attribute']
when >= 'RHEL7/Cent7/Amzn2'
do RHEL7/Cent7/Amzn2 stuff
end
when < 'RHEL7/Cen7/Amzn2'
do RHEL5-6/Cent5-6/Amzn1 stuff
end
end

You probably want something like this:

if ( platform_family?('rhel') && node['platform_version'].to_i >= 7 ) || ( platform?('amazon') && node['platform_version'].to_i < 2013 )
  # modern
else
  # legacy
end

You can also gate things based on the init system which is pretty handy for detecting legacy systems:

if node['init_package'] == 'systemd'
  # modern
else 
  # legacy
end

-Tim

You should check out Chef Sugar. It will give you helpers like

amazon_linux?

centos?
```ubuntu_before_lucid?``
`

`ubuntu_before_or_at_maverick?```

https://github.com/sethvargo/chef-sugar

thanks, exactly what I needed