#
# Cookbook:: kosmos_zerotier
# Recipe:: default
#

zerotier_controller = search(:node, "role:zerotier_controller").first

controller_url = "http://#{zerotier_controller["knife_zero"]["host"]}:#{node['kosmos_zerotier']['server_port']}"

credentials = data_bag_item("credentials", "zerotier")

zerotier_network credentials["network_id"] do
  node_name node['fqdn']
  auth_token credentials["auth_token"]
  central_url controller_url
end
