From b85eb13742dbf8e383d9b0928ad2d0c94004c3b0 Mon Sep 17 00:00:00 2001 From: vimesa Date: Thu, 25 Jan 2024 15:05:32 +0000 Subject: [PATCH 1/4] Add motd.erb --- resources/recipes/configure.rb | 21 ++++++++++++--------- resources/templates/default/motd.erb | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 resources/templates/default/motd.erb diff --git a/resources/recipes/configure.rb b/resources/recipes/configure.rb index 5a72917..8f0c371 100644 --- a/resources/recipes/configure.rb +++ b/resources/recipes/configure.rb @@ -127,14 +127,17 @@ # end # end -# template "/etc/motd" do -# source "motd.erb" -# owner "root" -# group "root" -# mode 0644 -# retries 2 -# variables(:manager_info => ( virtual_ips["erchef"].nil? ? "erchef.#{node["redBorder"]["cdomain"]}" : virtual_ips["erchef"].to_s ) ) -# end +manager =`grep "cloud_address" /etc/redborder/rb_init_conf.yml | cut -d' ' -f2` + +template "/etc/motd" do + source "motd.erb" + owner "root" + group "root" + mode 0644 + retries 2 + # variables(:manager_info => ( virtual_ips["erchef"].nil? ? "erchef.#{node["redBorder"]["cdomain"]}" : virtual_ips["erchef"].to_s ) ) + variables(:manager_info => node["redborder"]["cdomain"], :manager => manager ) +end # CLI Banner configuration template "/etc/cli_banner" do @@ -501,4 +504,4 @@ action :nothing end.run_action(:run) end - + \ No newline at end of file diff --git a/resources/templates/default/motd.erb b/resources/templates/default/motd.erb new file mode 100644 index 0000000..19ec534 --- /dev/null +++ b/resources/templates/default/motd.erb @@ -0,0 +1,17 @@ + + Welcome to redborder-ng IPS [<%= node["hostname"] %>] (<%= node['platform'] %> - <%= node['platform_version'] %>): +<% if !node["redborder"].nil? and !node["redborder"]["rpms"].nil? %> +<% node["redborder"]["rpms"].each do |k, v| %> + * <%= "redborder-%-12s" % [ k ] %> => <%= v %> +<% end %> +<% end %> + + Manager IP: <%= @manager.chomp %> + Domain: <%= @manager_info %> + CPUs: <%= node["cpu"]["total"] unless node["cpu"].nil? %> + Memory: <%= "%.2f GB" % [ node["memory"]["total"].to_f/(1000*1000) ] unless node["memory"].nil? %> + Host: <%= node['ipaddress'] %> (<%= node['macaddress'].nil? ? "" : node['macaddress'] %>) + Segments: <%= node["redborder"]["segments"].keys.size if (node["redborder"] and node["redborder"]["segments"] ) %> + Snort Groups: <%= node["redborder"]["snort"]["groups"].keys.size if (node["redborder"] and node["redborder"]["snort"]) %> + Installed on: <%= node["redborder"]["install_date"] if node["redborder"] %> + Last check: <%= Time.at(node[:ohai_time]).strftime('%a %b %d %H:%M:%S %Z %Y') %> From 2ae73d62f3fa3b528d14cfeb63a97826641ca18d Mon Sep 17 00:00:00 2001 From: vimesa Date: Mon, 29 Jan 2024 13:57:28 +0000 Subject: [PATCH 2/4] Add motd --- resources/recipes/configure.rb | 2 +- resources/templates/default/motd.erb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/recipes/configure.rb b/resources/recipes/configure.rb index 8f0c371..95b7ff0 100644 --- a/resources/recipes/configure.rb +++ b/resources/recipes/configure.rb @@ -127,6 +127,7 @@ # end # end +# Motd manager =`grep "cloud_address" /etc/redborder/rb_init_conf.yml | cut -d' ' -f2` template "/etc/motd" do @@ -135,7 +136,6 @@ group "root" mode 0644 retries 2 - # variables(:manager_info => ( virtual_ips["erchef"].nil? ? "erchef.#{node["redBorder"]["cdomain"]}" : virtual_ips["erchef"].to_s ) ) variables(:manager_info => node["redborder"]["cdomain"], :manager => manager ) end diff --git a/resources/templates/default/motd.erb b/resources/templates/default/motd.erb index 19ec534..c102065 100644 --- a/resources/templates/default/motd.erb +++ b/resources/templates/default/motd.erb @@ -1,9 +1,15 @@ Welcome to redborder-ng IPS [<%= node["hostname"] %>] (<%= node['platform'] %> - <%= node['platform_version'] %>): + Kernel: <%= node['os_version'].gsub("el9", "") %> <% if !node["redborder"].nil? and !node["redborder"]["rpms"].nil? %> <% node["redborder"]["rpms"].each do |k, v| %> * <%= "redborder-%-12s" % [ k ] %> => <%= v %> <% end %> +<% end %> +<% node["redborder"].each_pair do |key, value| %> + <% if key == "barnyard2" || key == "snort" %> + * <%= "%-22s" % [key + " version"] %> => <%= value["version"] %> + <% end %> <% end %> Manager IP: <%= @manager.chomp %> From 76e2ef05fcd80570aedafdc3fad19d6177916dcb Mon Sep 17 00:00:00 2001 From: vimesa Date: Mon, 29 Jan 2024 13:59:57 +0000 Subject: [PATCH 3/4] Modify motd --- resources/templates/default/motd.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/default/motd.erb b/resources/templates/default/motd.erb index c102065..992ea43 100644 --- a/resources/templates/default/motd.erb +++ b/resources/templates/default/motd.erb @@ -8,7 +8,7 @@ <% end %> <% node["redborder"].each_pair do |key, value| %> <% if key == "barnyard2" || key == "snort" %> - * <%= "%-22s" % [key + " version"] %> => <%= value["version"] %> + * <%= "%-22s" % [key] %> => <%= value["version"] %> <% end %> <% end %> From 361cdb61f555cb8afebda2d206a8449eb38f4197 Mon Sep 17 00:00:00 2001 From: vimesa Date: Tue, 30 Jan 2024 07:35:31 +0000 Subject: [PATCH 4/4] Modify motd --- resources/templates/default/motd.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/templates/default/motd.erb b/resources/templates/default/motd.erb index 992ea43..cbfc9a3 100644 --- a/resources/templates/default/motd.erb +++ b/resources/templates/default/motd.erb @@ -1,6 +1,7 @@ Welcome to redborder-ng IPS [<%= node["hostname"] %>] (<%= node['platform'] %> - <%= node['platform_version'] %>): Kernel: <%= node['os_version'].gsub("el9", "") %> + <% if !node["redborder"].nil? and !node["redborder"]["rpms"].nil? %> <% node["redborder"]["rpms"].each do |k, v| %> * <%= "redborder-%-12s" % [ k ] %> => <%= v %>