remove porterbox purpose when we add the porterbox blurb to the motd
[mirror/dsa-puppet.git] / modules / motd / templates / motd.erb
1 <%- if scope.call_function('versioncmp', [@lsbmajdistrelease, '8']) <= 0 -%>
2 #!/bin/bash
3
4 cat <<EOD
5 <%- end -%>
6
7 This device is for authorized users only.  All traffic on this device
8 is monitored and will be used as evidence for prosecutions.  By using
9 this machine you agree to abide by the Debian Machines Usage Policies
10 <URL:https://www.debian.org/devel/dmup>.
11
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13
14 <%=
15 def wrap(s, width=78)
16   #s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n ")
17   s.split("\n").map{ |x|
18     if (x.length > width) then
19       #x.gsub!(/(.{1,#{width}}) +(?=\S)/, "\\1\n ")
20       x.gsub!(/(.{1,#{width}})( +|\Z)/, "\\1\n ")
21     end
22     x
23   }.join("\n")+"\n"
24 end
25
26 def markup(l)
27   l = l.gsub(/\[\[(.*?)\|(.*?)\]\]/, '\2')
28   l = l.gsub(/\[\[(\*|-)?(.*?)\]\]/, '\2')
29   return l
30 end
31
32 if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('architecture')
33   arch = scope.lookupvar('site::nodeinfo')['ldap']['architecture'][0]
34 else
35   arch = 'unknown'
36 end
37
38 purp = ''
39 if scope.lookupvar('site::nodeinfo').has_key?('nameinfo')
40   purp += " " + wrap(scope.lookupvar('site::nodeinfo')['nameinfo']) + "\n"
41 end
42
43 ninfo = scope.lookupvar('site::nodeinfo')
44
45 extra = 'Welcome to ' + @fqdn
46 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('purpose'))
47   p = scope.lookupvar('site::nodeinfo')['ldap']['purpose'].clone()
48   entries = ""
49
50   if p.delete('buildd')
51     entries += ", the Debian #{arch} build daemon"
52   end
53   if classes.include?("roles::porterbox")
54     entries += ", the Debian #{arch} porterbox"
55     p.delete('porterbox')
56   end
57
58   if p.size() > 0
59     entries += (entries == "") ? ", " : ".  Also"
60     entries +="used for the following services:\n"
61     scope.lookupvar('site::nodeinfo')['ldap']['purpose'].sort.each do |l|
62       l = markup(l)
63       entries += "\t#{l}\n"
64     end
65   else
66     entries += ".\n"
67   end
68   extra += entries
69 else
70   extra += "."
71 end
72 purp += " " + wrap(extra) + "\n"
73
74 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('physicalHost'))
75   if ninfo['ldap']['physicalHost'][0] =~ /ganeti/
76     phys_host = 'cluster'
77   else
78     phys_host = 'physical host'
79   end
80   purp += wrap(" This virtual server runs on the #{phys_host} #{ninfo['ldap']['physicalHost'][0]}, " +
81                "which is hosted at #{ninfo['hoster']['longname']}."
82                )
83 elsif scope.lookupvar('site::nodeinfo')['hoster']['name']
84   purp += wrap(" This server is hosted at #{ninfo['hoster']['longname']}.")
85 end
86
87
88 vms = []
89 scope.lookupvar('site::allnodeinfo').keys.sort.each do |node|
90   if scope.lookupvar('site::allnodeinfo')[node]['physicalHost'] and scope.lookupvar('site::allnodeinfo')[node]['physicalHost'].include?(@fqdn)
91     vms << node
92   end
93 end
94 unless vms.empty?
95   purp += "\nThe following virtual machines run on this system:\n"
96   vms.each do |node|
97     purp += "\t- #{node}"
98     if scope.lookupvar('site::allnodeinfo')[node]['purpose']
99       purp += ":\n"
100       scope.lookupvar('site::allnodeinfo')[node]['purpose'].sort.each do |l|
101         l = markup(l)
102         purp += "\t    " + l + "\n"
103       end
104     else
105       purp += "\n"
106     end
107   end
108 end
109
110
111 if scope.lookupvar('::cluster')
112   purp += "\n This server is a node in ganeti cluster: "
113   purp += scope.lookupvar('::cluster').to_s + ":\n"
114   purp += "\t" + scope.lookupvar('::cluster_nodes').split.sort.map{ |x| x.split('.')[0] }.join(", ") + ".\n"
115
116   purp += ""
117   purp += "\tCurrently the master node is $(cat /var/lib/ganeti/ssconf_master_node).\n"
118   #nodes = scope.lookupvar('::cluster_nodes').sort
119   #nodes.each do |node|
120   #  purp += "\t" + node + "\n"
121   #end
122   #nodes.reject{|node| node.eql?(fqdn)}.each do |node|
123   #  purp += "\t" + node + "\n"
124   #  scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'].each do |ip|
125   #    purp += "\t\t" + ip + "\n"
126   #  end
127   #end
128 end
129
130
131 if classes.include?("roles::porterbox")
132   purp += "\n " + wrap("Disk space on porter boxes is often limited.  Please respect your fellow porters by cleaning up after yourself and deleting schroots and source/build trees in your ~ as soon as feasible.  DSA reserves the right to recover disk space as necessary.  See <URL:https://dsa.debian.org/doc/schroot/> for a brief tutorial on using schroot.  There may be chroots for architectures other than #{arch} available, please list available chroots to check.")
133 end
134
135 if ninfo['not-bacula-client'] then
136   purp += "\n " + wrap("Note that this host is _NOT_ being backed up.  If you care about your data, run your own backups.")
137 end
138
139 if scope.lookupvar('site::nodeinfo').has_key?('footer')
140   purp += "\n" + wrap(scope.lookupvar('site::nodeinfo')['footer'])
141 end
142
143 purp
144 -%>
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146
147 <%- if scope.call_function('versioncmp', [@lsbmajdistrelease, '8']) <= 0 -%>
148 EOD
149 <%- end -%>
150 <%
151 # vim:set et:
152 # vim:set sts=2 ts=2:
153 # vim:set shiftwidth=2:
154 -%>