Merge pull request 'feat: add country/region/environment to motd' (#134) from neoloc/motd_facts into develop

Reviewed-on: unkinben/puppet-prod#134
This commit is contained in:
Ben Vincent 2024-03-10 14:19:09 +09:30
commit fd5dbb7813
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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 %>