]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/motd/templates/motd.erb
make motd a little nicer
[dsa-puppet.git] / modules / motd / templates / motd.erb
1
2 This device is for authorized users only.  All traffic on this device
3 is monitored and will be used as evidence for prosecutions.  By using
4 this machine you agree to abide by the Debian Machines Usage Policies
5 <URL:http://www.debian.org/devel/dmup>.
6
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8
9 <%=
10 def wrap(s, width=78)
11       s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n")
12 end
13
14 def markup(l)
15   l = l.gsub(/\[\[(.*?)\|(.*?)\]\]/, '\2')
16   l = l.gsub(/\[\[(\*|-)?(.*?)\]\]/, '\2')
17   return l
18 end
19
20 purp = ''
21 if scope.lookupvar('site::nodeinfo').has_key?('nameinfo')
22   purp += wrap(scope.lookupvar('site::nodeinfo')['nameinfo']) + "\n\n"
23 end
24
25 ninfo = scope.lookupvar('site::nodeinfo')
26
27 purp += 'Welcome to ' + fqdn
28 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('purpose'))
29   p = scope.lookupvar('site::nodeinfo')['ldap']['purpose'].clone()
30   extra = ''
31
32   if p.delete('buildd')
33     purp += ", the Debian "
34     if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('architecture')
35       purp += scope.lookupvar('site::nodeinfo')['ldap']['architecture'][0]
36     end
37     purp += " build daemon"
38   end
39
40   if p.delete('porterbox')
41     purp += ", the Debian "
42     if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('architecture')
43       purp += scope.lookupvar('site::nodeinfo')['ldap']['architecture'][0]
44     end
45     purp += " porterbox"
46     extra += "\n"
47     extra += "See 'dchroot -l' or 'schroot -l' for a list of available chroots.\n"
48     if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('admin')
49       extra += "Please contact #{ninfo['ldap']['admin'][0]} for install requests,\n"
50       extra += "following the recommendations in <URL:http://dsa.debian.org/doc/install-req/>.\n"
51     end
52   end
53
54   if p.size() > 0
55     purp += ", used for the following services:\n"
56     scope.lookupvar('site::nodeinfo')['ldap']['purpose'].sort.each do |l|
57       l = markup(l)
58       purp += "\t" + l + "\n"
59     end
60   else
61     purp += ".\n"
62   end
63
64   purp += extra
65 else
66   purp += ".\n"
67 end
68
69 purp += "\n"
70
71 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('physicalHost'))
72   if ninfo['ldap']['physicalHost'][0] =~ /ganeti/
73     phys_host = 'cluster'
74   else
75     phys_host = 'physical host'
76   end
77   purp += wrap("This virtual server runs on the #{phys_host} #{ninfo['ldap']['physicalHost'][0]}, " +
78                "which is hosted at #{ninfo['hoster']['longname']}."
79                )
80 elsif scope.lookupvar('site::nodeinfo')['hoster']['name']
81   purp += wrap("This server is hosted at #{ninfo['hoster']['longname']}.")
82 end
83
84
85 vms = []
86 scope.lookupvar('site::allnodeinfo').keys.sort.each do |node|
87   if scope.lookupvar('site::allnodeinfo')[node]['physicalHost'] and scope.lookupvar('site::allnodeinfo')[node]['physicalHost'].include?(fqdn)
88     vms << node
89   end
90 end
91 unless vms.empty?
92   purp += "\nThe following virtual machines run on this system:\n"
93   vms.each do |node|
94     purp += "\t- #{node}"
95     if scope.lookupvar('site::allnodeinfo')[node]['purpose']
96       purp += ":\n"
97       scope.lookupvar('site::allnodeinfo')[node]['purpose'].sort.each do |l|
98         l = markup(l)
99         purp += "\t    " + l + "\n"
100       end
101     else
102       purp += "\n"
103     end
104   end
105 end
106
107
108 if scope.lookupvar('::cluster').to_s != 'undefined'
109   purp += "\nThis server is a node in ganeti cluster: "
110   purp += scope.lookupvar('::cluster').to_s + ".\n"
111   nodes = scope.lookupvar('::cluster_nodes').to_s.split.sort
112   nodes.each do |node|
113     purp += "\t" + node + "\n"
114   end
115   nodes.reject{|node| node.eql?(fqdn)}.each do |node|
116     purp += "\t" + node + "\n"
117     scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'].each do |ip|
118       purp += "\t\t" + ip + "\n"
119     end
120   end
121 end
122
123
124 if scope.lookupvar('site::nodeinfo').has_key?('footer')
125   purp += "\n" + wrap(scope.lookupvar('site::nodeinfo')['footer']) + "\n"
126 end
127
128 purp
129 -%>
130
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132
133 <%
134 # vim:set et:
135 # vim:set sts=2 ts=2:
136 # vim:set shiftwidth=2:
137 -%>