summaryrefslogtreecommitdiffstats
path: root/doc/server/plugins/generators/examples/genshi/hosts.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/server/plugins/generators/examples/genshi/hosts.txt')
-rw-r--r--doc/server/plugins/generators/examples/genshi/hosts.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/server/plugins/generators/examples/genshi/hosts.txt b/doc/server/plugins/generators/examples/genshi/hosts.txt
new file mode 100644
index 000000000..144816e65
--- /dev/null
+++ b/doc/server/plugins/generators/examples/genshi/hosts.txt
@@ -0,0 +1,19 @@
+.. -*- 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]}