Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > b50d8ee6d7871fcc13c0677a9364ed59 > files > 208

bcfg2-doc-1.3.0-1.fc17.noarch.rpm

.. -*- mode: rst -*-

hosts
=====

This is an example of creating ``/etc/hosts`` based on metadata.hostname::

    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1       localhost.localdomain localhost
    ::1             localhost6.localdomain6 localhost6
    {% python
    import socket
    import re
    ip = socket.gethostbyname(metadata.hostname)

    shortname = re.split("\.", metadata.hostname)
    %}\
    ${ip} ${metadata.hostname} ${shortname[0]}