]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/motd/templates/motd.erb
4dc5ac5a597703d47f976a75e81523eee5bd4360
[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   purp += wrap("This virtual server runs on the physical host #{ninfo['ldap']['physicalHost'][0]}, " +
73                "which is hosted at #{ninfo['hoster']['longname']}."
74                )
75 elsif scope.lookupvar('site::nodeinfo')['hoster']['name']
76   purp += wrap("This server is hosted at #{ninfo['hoster']['longname']}.")
77 end
78
79
80 vms = []
81 scope.lookupvar('site::allnodeinfo').keys.sort.each do |node|
82   if scope.lookupvar('site::allnodeinfo')[node]['physicalHost'] and scope.lookupvar('site::allnodeinfo')[node]['physicalHost'].include?(fqdn)
83     vms << node
84   end
85 end
86 unless vms.empty?
87   purp += "\nThe following virtual machines run on this system:\n"
88   vms.each do |node|
89     purp += "\t- #{node}"
90     if scope.lookupvar('site::allnodeinfo')[node]['purpose']
91       purp += ":\n"
92       scope.lookupvar('site::allnodeinfo')[node]['purpose'].sort.each do |l|
93         l = markup(l)
94         purp += "\t    " + l + "\n"
95       end
96     else
97       purp += "\n"
98     end
99   end
100 end
101
102
103 if scope.lookupvar('::cluster')
104   purp += "\nThis server is a node in ganeti cluster: "
105   purp += scope.lookupvar('::cluster') + ".\n"
106   Puppet::Parser::Functions.function('hiera_array')
107   scope.function_hiera_array('nodes').each do |node|
108     purp += "\t" + node + "\n"
109   end
110   scope.lookupvar('::cluster_nodes').each do |node|
111     purp += "\t" + node + "\n"
112   end
113 end
114
115
116 if scope.lookupvar('site::nodeinfo').has_key?('footer')
117   purp += "\n" + wrap(scope.lookupvar('site::nodeinfo')['footer']) + "\n"
118 end
119
120 purp
121 -%>
122
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124
125 <%
126 # vim:set et:
127 # vim:set sts=2 ts=2:
128 # vim:set shiftwidth=2:
129 -%>