From 1e0eeceaa9ad8ec7b4254adee37cdb770b598cbb Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Wed, 28 Oct 2026 22:59:58 +0000 Subject: [PATCH] oxidized: add custom apcats model. More verbose logging --- cookbooks/oxidized/files/default/apcats.rb | 8 ++++++++ cookbooks/oxidized/recipes/default.rb | 15 +++++++++++++++ cookbooks/oxidized/templates/default/config.erb | 8 ++++++-- test/integration/oxidized/inspec/oxidized_spec.rb | 14 ++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 cookbooks/oxidized/files/default/apcats.rb diff --git a/cookbooks/oxidized/files/default/apcats.rb b/cookbooks/oxidized/files/default/apcats.rb new file mode 100644 index 000000000..9d691510f --- /dev/null +++ b/cookbooks/oxidized/files/default/apcats.rb @@ -0,0 +1,8 @@ +require "oxidized/model/apcaos" + +class ApcAts < ApcAos + inputs [:ssh, :scp] + + cmd "upsabout", :clear => true, :if => -> { false } + cmd "detstatus -ss", :clear => true, :if => -> { false } +end diff --git a/cookbooks/oxidized/recipes/default.rb b/cookbooks/oxidized/recipes/default.rb index d25a8b79a..f4a01789e 100644 --- a/cookbooks/oxidized/recipes/default.rb +++ b/cookbooks/oxidized/recipes/default.rb @@ -32,6 +32,7 @@ package %w[ libyaml-dev logrotate libzstd-dev + libgpg-error-dev ] keys = data_bag_item("oxidized", "keys") @@ -57,6 +58,20 @@ directory "/etc/oxidized" do mode "755" end +directory "/etc/oxidized/model" do + owner "root" + group "root" + mode "755" +end + +cookbook_file "/etc/oxidized/model/apcats.rb" do + source "apcats.rb" + owner "root" + group "root" + mode "644" + notifies :restart, "service[oxidized]" +end + template "/etc/oxidized/config" do source "config.erb" owner "oxidized" diff --git a/cookbooks/oxidized/templates/default/config.erb b/cookbooks/oxidized/templates/default/config.erb index 7de50ff6c..9c61b2aa9 100644 --- a/cookbooks/oxidized/templates/default/config.erb +++ b/cookbooks/oxidized/templates/default/config.erb @@ -1,6 +1,9 @@ --- # DO NOT EDIT - This file is being maintained by Chef +run_once: false +retries: 3 timeout: 60 +resolve_dns: false vars: remove_secret: true pid: "/run/oxidized/oxidized.pid" @@ -36,9 +39,10 @@ model_map: juniper: junos apc: apcaos logger: + level: :trace appenders: - type: stdout - level: :trace + level: :info - type: file - level: :warn + level: :trace file: /var/log/oxidized/oxidized.log diff --git a/test/integration/oxidized/inspec/oxidized_spec.rb b/test/integration/oxidized/inspec/oxidized_spec.rb index df6aaab9e..5124ac902 100644 --- a/test/integration/oxidized/inspec/oxidized_spec.rb +++ b/test/integration/oxidized/inspec/oxidized_spec.rb @@ -1,3 +1,17 @@ +describe directory("/etc/oxidized/model") do + it { should exist } + its("owner") { should eq "root" } + its("group") { should eq "root" } + its("mode") { should cmp "0755" } +end + +describe file("/etc/oxidized/model/apcats.rb") do + it { should be_file } + its("owner") { should eq "root" } + its("group") { should eq "root" } + its("mode") { should cmp "0644" } +end + describe service("oxidized") do it { should be_enabled } it { should be_running } -- 2.47.3