Restrict ssh to mirrors
[mirror/dsa-puppet.git] / modules / ferm / templates / me.conf.erb
1 ##
2 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
3 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
4 ##
5
6 <%=
7 nodeinfo = scope.lookupvar('site::nodeinfo')
8 out = []
9
10 restricted_purposes = ['kvm host', 'central syslog server', 'puppet master', 'jumphost', 'buildd', 'static-mirror', 'anycast mirror']
11 restrict_ssh = %w{tchaikovsky draghi adayevskaya}
12
13 if (nodeinfo['ldap'].has_key?('purpose')) then
14         nodeinfo['ldap']['purpose'].each do |purp|
15                 if restricted_purposes.include?(purp) then
16                         restrict_ssh << @hostname
17                 end
18         end
19 end
20
21 ssh4allowed = []
22 ssh6allowed = []
23
24 should_restrict = restrict_ssh.include?(@hostname)
25 %w{dns_primary dns_geo}.each do |role_restrict|
26         if scope.function_has_role([role_restrict]) then
27                 should_restrict = true
28         end
29 end
30
31
32 if restrict_ssh.include?(@hostname) then
33         ssh4allowed << %w{$DSA_IPS    $HOST_NAGIOS_V4 $HOST_MUNIN_V4 $HOST_DB_V4}
34         ssh6allowed << %w{$DSA_V6_IPS $HOST_NAGIOS_V6 $HOST_MUNIN_V6 $HOST_DB_V6}
35
36         if %w{draghi}.include?(@hostname) then
37                 ssh4allowed << '$HOST_DEBIAN_V4'
38                 ssh6allowed << '$HOST_DEBIAN_V6'
39         end
40
41         if %w{adayevskaya}.include?(@hostname) then
42                 out << '@def $MFL_LOCAL = ( 130.83.226.60 );' # Michael Fladerer
43                 ssh4allowed << '$MFL_LOCAL'
44                 ssh4allowed << %w{$HOST_DEBIAN_V4}
45                 ssh6allowed << %w{$HOST_DEBIAN_V6}
46         end
47         if scope.function_has_role(['dns_primary']) then
48                 ssh4allowed << "5.153.231.5" # adayevskaya
49                 ssh6allowed << "2001:41c8:1000:21::21:5" # adayevskaya
50                 #ssh4allowed << "$HOST_DNS_GEO_V4"
51                 #ssh6allowed << "$HOST_DNS_GEO_V6"
52         end
53
54         if scope.function_has_role(['static_master']) then
55                 ssh4allowed << '$HOST_STATIC_V4'
56                 ssh6allowed << '$HOST_STATIC_V6'
57         elsif scope.function_has_role(['static_source']) or
58               scope.function_has_role(['static_mirror']) then
59                 ssh4allowed << '$HOST_STATICMASTER_V4'
60                 ssh6allowed << '$HOST_STATICMASTER_V6'
61         end
62         if scope.function_has_role(['debian_mirror']) or
63            scope.function_has_role(['security_mirror']) or
64            scope.function_has_role(['historical_mirror']) or
65            scope.function_has_role(['syncproxy']) then
66                 ssh4allowed << '$HOST_MIRRORMASTER_V4'
67                 ssh6allowed << '$HOST_MIRRORMASTER_V6'
68         end
69         if scope.function_has_role(['debian_mirror']) or
70            scope.function_has_role(['syncproxy']) then
71                 ssh4allowed << '$HOST_SYNCPROXY_V4'
72                 ssh6allowed << '$HOST_SYNCPROXY_V6'
73         end
74         if scope.function_has_role(['security_mirror']) or
75            scope.function_has_role(['syncproxy']) then
76                 ssh4allowed << '$HOST_SECMASTER_V4'
77                 ssh6allowed << '$HOST_SECMASTER_V6'
78         end
79         if scope.function_has_role(['historical_mirror']) then
80                 ssh4allowed << '$HOST_ARCHIVEMASTER_V4'
81                 ssh6allowed << '$HOST_ARCHIVEMASTER_V6'
82         end
83         if scope.function_has_role(['syncproxy']) then
84                 ssh4allowed << '$HOST_FTPMASTER_V4'
85                 ssh6allowed << '$HOST_FTPMASTER_V6'
86                 ssh4allowed << '$HOST_PORTSMASTER_V4'
87                 ssh6allowed << '$HOST_PORTSMASTER_V6'
88         end
89 end
90 ssh4allowed.length == 0 and ssh4allowed << '0.0.0.0/0'
91 ssh6allowed.length == 0 and ssh6allowed << '::/0'
92
93 out << "@def $SSH_SOURCES    = (#{ssh4allowed.join(' ')});"
94 out << "@def $SSH_V6_SOURCES = (#{ssh6allowed.join(' ')});"
95
96
97
98
99 smtp4allowed = []
100 smtp6allowed = []
101
102 if not nodeinfo['smarthost'].empty?
103   smtp4allowed << %w{$HOST_MAILRELAY_V4 $HOST_NAGIOS_V4}
104   smtp6allowed << %w{$HOST_MAILRELAY_V6 $HOST_NAGIOS_V6}
105 end
106
107 smtp4allowed.length == 0 and smtp4allowed << '0.0.0.0/0'
108 smtp6allowed.length == 0 and smtp6allowed << '::/0'
109
110 out << "@def $SMTP_SOURCES    = (#{smtp4allowed.join(' ')});"
111 out << "@def $SMTP_V6_SOURCES = (#{smtp6allowed.join(' ')});"
112
113 out.join("\n")
114 %>