8

Given an array of similar hosts, what are some of the advantages and disadvantages of zero padding or not?

Zero Padding

   www-01
   www-02
   ...
   www-11
   www-12

No Padding

   www-1
   www-2
   ...
   www-11
   www-12

I've seen both in practice and have heard reasons for/against each. The only snippet I've come across referencing zero padding is a small note in the Debian addclients manpage, but no reasoning: "Padding hostnames with zeros is not recommended." Does anyone know what background or justification might be behind this recommendation?

Pros

  • Simple alphanumeric sorting
  • Fixed width

Cons

  • Breaks down after the maximum padded id (99, 999, ...)
  • Adds slight complexity to any comparison/validation (^\w+-\d{<id_length>}$ vs ^\w+-\d+$)
Shane Madden
  • 114,520
  • 13
  • 181
  • 251
inno
  • 113
  • 5
  • 5
    This is pure opinion. – John Jun 18 '14 at 17:44
  • 3
    This is purely opinion-based, as asked, but I think it's a good question, nonetheless... perhaps if you change it to ask about the advantages and disadvantages of each approach (and maybe why Debian's docs advise against 0-padding), it would stay open, and allow some useful insight/answers. – HopelessN00b Jun 18 '14 at 17:46
  • 3
    I think this is a subjective question, however this is an ongoing discussion in meta. The good thing is that this OP, being new, did at least *some* research on the matter before coming here, and the question *is* relevant to professional system administration. – MDMoore313 Jun 18 '14 at 17:56

1 Answers1

5

FWIW, we pad for consistency. That way we know that $hostname always has $x digits, so it saves a step. And saving 1 step on 3,000 machines goes a long way (about 1.5 miles, to be exact).

Of course, let's look at both sides. The Pros? For me it was discussed above. Host name consistency, and some people (myself included) enjoy looking at rows upon rows of host names that are all the same length, since I'm in charge of configuration here and all those machines with the exact same name are the exact same length in my spreadsheet and have the exact same configuration in real life. Ahh, what a relief.

The cons? The only one I can think of is that you make the padding too small, for instance padding 2 zeros and you wind up with over 100 hosts. What do you do? Forget about it? Rename the first 99 hosts? Making the padding too large really has no harm I can see, other than being able to use that space for something else (site code, workstation code, etc.).

Yes, in the end it's entirely up to you, but I think the votes on this answer will give the general community consensus, up or down.

MDMoore313
  • 5,581
  • 6
  • 36
  • 75