From 428dc910bba9928613e3c64a7d9482d1f1ffe097 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sun, 10 Mar 2024 15:48:26 +1100 Subject: [PATCH] feat: add country/region/environment to motd --- site/profiles/manifests/base/motd.pp | 2 ++ site/profiles/templates/base/motd/motd.erb | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/site/profiles/manifests/base/motd.pp b/site/profiles/manifests/base/motd.pp index e1dd5ca..4799976 100644 --- a/site/profiles/manifests/base/motd.pp +++ b/site/profiles/manifests/base/motd.pp @@ -7,6 +7,8 @@ class profiles::base::motd ( String $nic = $facts['networking']['primary'], String $os_name = $facts['os']['name'], String $os_release = $facts['os']['release']['full'], + String $location = "${facts['country']}-${facts['region']}", + String $env = $facts['environment'], ) { # Use the regsubst function to remove the 'roles::' prefix from the role name diff --git a/site/profiles/templates/base/motd/motd.erb b/site/profiles/templates/base/motd/motd.erb index 7ca06df..6e2f7df 100644 --- a/site/profiles/templates/base/motd/motd.erb +++ b/site/profiles/templates/base/motd/motd.erb @@ -1,6 +1,6 @@ <% # calculate padding for the longest word -max_length = ['fqdn:', 'os:', 'role:', 'branch:', 'addr:', 'nic:'].max_by(&:length).length +max_length = ['fqdn:', 'os:', 'role:', 'branch:', 'addr:', 'nic:', 'location:', 'env:'].max_by(&:length).length # helper lambda to right-align text align = ->(word) { word.ljust(max_length) } %> @@ -10,4 +10,6 @@ align = ->(word) { word.ljust(max_length) } <%= align.call('branch:') %> <%= @enc_env %> <%= align.call('addr:') %> <%= @addr %> <%= align.call('nic:') %> <%= @nic %> +<%= align.call('location:') %> <%= @location %> +<%= align.call('env:') %> <%= @env %>