From 065eac06b1b509bf834c611754612c756afdd98b Mon Sep 17 00:00:00 2001 From: Greg Karekinian Date: Sat, 11 Jul 2026 17:29:31 +0200 Subject: [PATCH] Add a recipe to install the zerotier ohai plugin The attributes are saved as "automatic" attributes and look like this: "zerotier": { "version": "1.16.2", "node_id": "NODEID", "networks": { "NETWORKID": { "network_name": "networkname", "mac": "ff:ff:ff:ff:ff:ff", "status": "OK", "type": "PRIVATE", "interface": "abcdefg", "addresses": [ "10.1.1.255/24" ] } } } Refs #263 --- site-cookbooks/kosmos_zerotier/metadata.rb | 3 ++- .../kosmos_zerotier/recipes/ohai_plugin.rb | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 site-cookbooks/kosmos_zerotier/recipes/ohai_plugin.rb diff --git a/site-cookbooks/kosmos_zerotier/metadata.rb b/site-cookbooks/kosmos_zerotier/metadata.rb index a67848b..3a193bd 100644 --- a/site-cookbooks/kosmos_zerotier/metadata.rb +++ b/site-cookbooks/kosmos_zerotier/metadata.rb @@ -4,7 +4,8 @@ maintainer_email 'mail@kosmos.org' license 'MIT' description 'Installs/Configures zerotier' long_description 'Installs/Configures zerotier' -version '0.1.0' +version '0.2.0' chef_version '>= 14.0' depends 'kosmos-base' +depends 'zerotier' diff --git a/site-cookbooks/kosmos_zerotier/recipes/ohai_plugin.rb b/site-cookbooks/kosmos_zerotier/recipes/ohai_plugin.rb new file mode 100644 index 0000000..4c89447 --- /dev/null +++ b/site-cookbooks/kosmos_zerotier/recipes/ohai_plugin.rb @@ -0,0 +1,21 @@ +# +# Cookbook:: kosmos_zerotier +# Recipe:: ohai_plugin +# + +include_recipe "zerotier::ohai_plugin" + +ohai "reload_zerotier" do + action :reload + plugin "zerotier" + notifies :run, "ruby_block[save_chef_zero_node]", :delayed +end + +# Force save the node back to disk in Chef Zero +ruby_block "save_chef_zero_node" do + block do + node.save + Chef::Log.info("Node #{node.name} saved to disk with ZeroTier data") + end + action :nothing +end