Skip to content

Commit

Permalink
DRY and rework the platform detection for install.rb
Browse files Browse the repository at this point in the history
Use platform_family not platform in order to get all the derivative platforms like Scientific Linux
Support Amazon Linux 2 which is 99.9% RHEL 7 now
Always releasever on Fedora to point to the correct repo dir even though they're all there for Fedora (that is beautiful btw)

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed Sep 17, 2020
1 parent f09fa08 commit fc50b71
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions recipes/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,46 @@
#
# Copyright:: 2017, ZeroTier, Inc., All Rights Reserved.

case node['platform']
when 'debian', 'ubuntu'
apt_repository 'zerotier' do
uri "http://download.zerotier.com/debian/#{node['lsb']['codename']}"
components ['main']
key 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg'
trusted true
end
when 'rhel', 'centos'
yum_repository 'zerotier' do
description "ZeroTier Repo"
baseurl 'https://download.zerotier.com/redhat/el/$releasever'
gpgkey 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg'
end
when 'amazon'
yum_repository 'zerotier' do
description 'ZeroTier Repo'
baseurl 'https://download.zerotier.com/redhat/amzn1/'
gpgkey 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg'
end
when 'fedora'
yum_repository 'zerotier' do
description 'ZeroTier Repo'
baseurl 'https://download.zerotier.com/redhat/fc/22'
gpgkey 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg'
end
case node['platform_family']
when 'debian'
apt_repository 'zerotier' do
uri "http://download.zerotier.com/debian/#{node['lsb']['codename']}"
components ['main']
key 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg'
trusted true
end
when 'rhel', 'amazon', 'fedora'
base_url = case node['platform']
when 'amazon'
if node['platform_version'].to_i >= 2010 # legacy Amazon Linux 201x releases
'https://download.zerotier.com/redhat/amzn1/'
else
'https://download.zerotier.com/redhat/el/7'
end
when 'fedora'
'https://download.zerotier.com/redhat/fc/$releasever'
else
'https://download.zerotier.com/redhat/el/$releasever'
end

yum_repository 'zerotier' do
description 'ZeroTier Repo'
baseurl base_url
gpgkey 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg'
end
else
Chef::Log.fatal("Platform '#{node['platform']}' is not yet supported by this recipe")
Chef::Log.fatal("Platform Family '#{node['platform_family']}' is not yet supported by this recipe")
end

package 'zerotier-one' do
if node['zerotier']['version']
version node['zerotier']['install_version']
end
if node['zerotier']['version']
version node['zerotier']['install_version']
end
end

service 'zerotier-one' do
action [:enable, :start]
supports :status => true, :restart => true, :start => true,:stop => true
action [:enable, :start]
supports status: true, restart: true, start: true, stop: true
end

include_recipe 'zerotier::ohai_plugin'

0 comments on commit fc50b71

Please sign in to comment.