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,983
  • 16
  • 53
  • 91

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
  • 244,070
  • 43
  • 506
  • 972
johnshen64
  • 5,865
  • 24
  • 17