Skip to content
Snippets Groups Projects
motd.erb 1.48 KiB
Newer Older
Adam Lewenberg's avatar
Adam Lewenberg committed
<%  os = lsbdistdescription.gsub(/Debian GNU\/Linux/, "Debian")
    os.gsub!(/Red Hat Enterprise Linux/i, 'RHEL')
    os.gsub!(/RHEL (\w+) release (\d+) \(.* (\d+)\)/i, 'RHEL \1 \2u\3')
    os.gsub!(/RHEL (\w+) release ([\d\.]+) \(.*\)/i, 'RHEL \1 \2')

    processor = processor0.strip.gsub(/\s+/, " ")
    processor = processor.strip.gsub(/\(R\)|\(TM\)/i, '')
    processor = processor.strip.gsub(/(\w+-Core|Processor|CPU) /i, '')
    processor = processor.strip.gsub(/(Intel|AMD) /i, '')

    host = fqdn.downcase

    product = productname rescue nil
    if product.nil?
      product = "unknown"
    else
      product.strip!
      product.gsub!(/VMware Virtual Platform/i, 'vmware')
      product.gsub!(/ Server/i, '')
      product.gsub!(/SUN BLADE /i, 'SB ')
      product.gsub!(/Precision WorkStation /i, '')
      product.gsub!(/ MODULE/i, '')
    end
    sn = serialnumber rescue nil
    if virtual == 'physical' and (! sn.nil?)
      product += ", " + serialnumber
    end

    memory = memorysize
    if memory.match(/\./)
      memory.sub!(/0+ /, ' ')
      memory.sub!(/\. /, ' ')
    end
    memory.gsub!(/\s+/, '')

    swap = swapsize
    if swap.match(/\./)
      swap.sub!(/0+ /, ' ')
      swap.sub!(/\. /, ' ')
    end
    swap.gsub!(/\s+/, '')
-%>
<%= host %> - <%= os %>, <%= architecture %>
<%= processorcount %>-core <%= processor %> (<%= product %>); <%= memory %> RAM, <%= swap %> swap
Puppet environment: <%= environment %>; kernel <%= kernelrelease %> (<%= hardwaremodel %>)
<%= text -%>