]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/ganeti2/templates/instance-debootstrap/hooks/00-dsa-configure-networking.erb
add ganeti3 cluster
[dsa-puppet.git] / modules / ganeti2 / templates / instance-debootstrap / hooks / 00-dsa-configure-networking.erb
1 #!/bin/bash
2
3 set -e
4
5 if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
6   echo "Missing target directory"
7   exit 1
8 fi
9
10 if [ ! -d "$TARGET/etc/network" ]; then
11   echo "Missing target network directory"
12   exit 1
13 fi
14
15 if [ -z "$NIC_COUNT" ]; then
16   echo "Missing NIC COUNT"
17   exit 1
18 fi
19
20 rm -f $TARGET/etc/udev/rules.d/70-persistent-net.rules
21
22 touch $TARGET/etc/udev/rules.d/75-cd-aliases-generator.rules
23 touch $TARGET/etc/udev/rules.d/75-persistent-net-generator.rules
24
25
26 ###########################################
27 fqdn=$(cat $TARGET/etc/hostname)
28 echo ${fqdn%%.*} > $TARGET/etc/hostname
29
30 ###########################################
31 if [ "$NIC_COUNT" -ge 1 ]; then
32   cat > $TARGET/etc/network/interfaces << EOF
33 # /etc/network/interfaces
34
35 auto lo
36 iface lo inet loopback
37
38 EOF
39 fi
40
41
42 ###########################################
43 ###########################################
44 <% if scope.lookupvar('::cluster').to_s == 'ganeti2.debian.org' -%>
45
46 ###########################################
47 if [ "$NIC_COUNT" -ge 1 ]; then
48   cat >> $TARGET/etc/network/interfaces << EOF
49 auto eth0
50 iface eth0 inet static
51   address ${NIC_0_IP}
52   netmask 255.255.255.0
53   gateway 206.12.19.254
54
55   pre-up /sbin/sysctl -w net.ipv6.conf.\$IFACE.accept_ra=0 || true
56   up   ip addr add 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS/64 dev \$IFACE
57   up   ip r add default via 2607:f8f0:610:4000::1 src 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS dev \$IFACE
58   down ip r del default via 2607:f8f0:610:4000::1 src 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS dev \$IFACE
59   down ip addr del 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS/64 dev \$IFACE
60 EOF
61
62 fi
63
64 ###########################################
65 cat > $TARGET/etc/resolv.conf <<EOF
66 # /etc/resolv.conf
67 search debprivate-ubc.debian.org debian.org
68 nameserver 206.12.19.20
69 nameserver 206.12.19.21
70 EOF
71
72 ###########################################
73 ###########################################
74 <% elsif scope.lookupvar('::cluster').to_s == 'ganeti-osuosl.debian.org' -%>
75 #
76 ###########################################
77 if [ "$NIC_COUNT" -ge 1 ]; then
78   cat >> $TARGET/etc/network/interfaces << EOF
79 auto eth0
80 iface eth0 inet static
81   address ${NIC_0_IP}
82   netmask 255.255.255.128
83   gateway 140.211.166.1
84
85   pre-up /sbin/sysctl -w net.ipv6.conf.\$IFACE.accept_ra=0 || true
86 EOF
87
88 fi
89
90 ###########################################
91 cat > $TARGET/etc/resolv.conf <<EOF
92 # /etc/resolv.conf
93 search debian.org
94 nameserver 140.211.166.130
95 nameserver 140.211.166.131
96 EOF
97
98 <% elsif scope.lookupvar('::cluster').to_s == 'ganeti3.debian.org' -%>
99 #
100 ###########################################
101 if [ "$NIC_COUNT" -ge 1 ]; then
102   cat >> $TARGET/etc/network/interfaces << EOF
103 auto eth0
104 iface eth0 inet static
105   address ${NIC_0_IP}
106   netmask 255.255.255.192
107   gateway 82.195.75.126
108
109   pre-up /sbin/sysctl -w net.ipv6.conf.\$IFACE.accept_ra=0 || true
110 EOF
111
112 fi
113
114 ###########################################
115 cat > $TARGET/etc/resolv.conf <<EOF
116 # /etc/resolv.conf
117 search debian.org
118 nameserver 82.195.75.81
119 nameserver 82.195.66.239
120 nameserver 217.198.242.225
121 EOF
122
123 <% else -%>
124
125 # No config for cluster <%= scope.lookupvar('::cluster').to_s %>
126 cp /etc/resolv.conf $TARGET/etc/resolv.conf
127
128 <% end -%>
129
130
131
132
133 ###########################################
134 if [ "$NIC_COUNT" -ge 2 ]; then
135   cat >> $TARGET/etc/network/interfaces << EOF
136
137 auto eth1
138 iface eth1 inet static
139   address ${NIC_1_IP}
140   netmask 255.255.255.0
141 EOF
142
143 fi
144
145 ###########################################
146 # clean up etc/hosts
147 cat > $TARGET/etc/hosts << EOF
148 127.0.0.1       localhost
149 ${NIC_0_IP} ${fqdn} ${fqdn%%.*}
150
151 # The following lines are desirable for IPv6 capable hosts
152 ::1     ip6-localhost ip6-loopback
153 fe00::0 ip6-localnet
154 ff00::0 ip6-mcastprefix
155 ff02::1 ip6-allnodes
156 ff02::2 ip6-allrouters
157 EOF
158
159 exit 0
160
161 # vim:set syn=sh: