0

We are using Puppet to generate our /etc/motd file. Unfortunately the hostnames do not always have the same length.

This creates a /etc/motd with sometimes a space too much or too little after the hostname.

 #############################################
 ##  This server is managed from Amsterdam  ##
 #############################################
 #############################################
 ##               web-tst-01                 ##
 #############################################

What can be done so that the number of spaces is dynamically changed based on the length of the hostname?

ujjain
  • 3,963
  • 15
  • 50
  • 88

1 Answers1

3
  1. use an erb template to generate motd if you are not yet doing it.
  2. generate the host line with ruby code, assuming hostname has your hostname

    <% (hostname.center 40, " ").center 44, '#' %>
    
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
johnshen64
  • 5,747
  • 23
  • 17