Update hostsfile and add zerotier cookbook
This commit is contained in:
7
cookbooks/zerotier/recipes/default.rb
Normal file
7
cookbooks/zerotier/recipes/default.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# Cookbook:: zerotier
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2017, ZeroTier, Inc., All Rights Reserved.
|
||||
|
||||
include_recipe 'zerotier::install'
|
||||
48
cookbooks/zerotier/recipes/install.rb
Normal file
48
cookbooks/zerotier/recipes/install.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# Cookbook:: zerotier
|
||||
# Recipe:: install
|
||||
#
|
||||
# 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
|
||||
else
|
||||
Chef::Log.fatal("Platform '#{node['platform']}' is not yet supported by this recipe")
|
||||
end
|
||||
|
||||
package 'zerotier-one' do
|
||||
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
|
||||
end
|
||||
|
||||
include_recipe 'zerotier::ohai_plugin'
|
||||
23
cookbooks/zerotier/recipes/join_networks.rb
Normal file
23
cookbooks/zerotier/recipes/join_networks.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# Cookbook:: zerotier
|
||||
# Recipe:: join_networks
|
||||
#
|
||||
# Copyright:: 2017, ZeroTier, Inc., All Rights Reserved.
|
||||
|
||||
include_recipe 'zerotier::ohai_plugin'
|
||||
|
||||
node['zerotier']['public_autojoin'].each do |nwid|
|
||||
zerotier_network nwid do
|
||||
action :join
|
||||
end
|
||||
end
|
||||
|
||||
node['zerotier']['private_autojoin'].each do |network|
|
||||
zerotier_network network['network_id'] do
|
||||
only_if { network.key?("auth_token") }
|
||||
action :join
|
||||
auth_token network['auth_token']
|
||||
central_url network.key?("central_url") ? network[:central_url] : "https://my.zerotier.com"
|
||||
node_name node['fqdn']
|
||||
end
|
||||
end
|
||||
15
cookbooks/zerotier/recipes/ohai_plugin.rb
Normal file
15
cookbooks/zerotier/recipes/ohai_plugin.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# Cookbook:: zerotier
|
||||
# Recipe:: ohai_plugin
|
||||
#
|
||||
# Copyright:: 2017, ZeroTier, Inc., All Rights Reserved.
|
||||
|
||||
ohai_plugin 'zerotier_ohai' do
|
||||
compile_time false
|
||||
resource :template
|
||||
variables ({
|
||||
:zerotier_binary => node['zerotier']['binary'],
|
||||
:control_port => node['zerotier']['control_port'],
|
||||
:data_dir => node['zerotier']['data_dir']
|
||||
})
|
||||
end
|
||||
Reference in New Issue
Block a user