/
templates.go
115 lines (97 loc) · 2.7 KB
/
templates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package main
import "text/template"
var (
birdConfTemplate = template.Must(template.New("bird.conf").Parse(`# bird configurations for boot servers
log stderr all;
protocol device {
scan time 60;
}
protocol direct singles {
ipv4;
interface "node0", "bastion";
}
protocol bfd {
interface "*" {
min rx interval 100 ms;
min tx interval 100 ms;
};
}
protocol kernel {
merge paths;
ipv4 {
export filter {
if source = RTS_DEVICE then reject;
accept;
};
};
}
ipv4 table dummytab;
protocol static dummystatic {
ipv4 { table dummytab; };
route 0.0.0.0/0 via "lo";
}
template bgp tor {
local as {{ .ASN }};
direct;
bfd;
ipv4 {
# Accept routes regardless of its NEXT_HOP.
igp table dummytab;
gateway recursive;
import filter {
# If this route came from iBGP peers,
if bgp_next_hop.mask({{ .Mask }}) = from.mask({{ .Mask }}) then {
# use the NEXT_HOP as the gateway address.
gw = bgp_next_hop;
accept;
}
# Otherwise, use the router address as the gateway address.
# This is virtually equal to "next hop self" on receiver side.
gw = from;
accept;
};
export all;
};
}
protocol bgp tor1 from tor {
neighbor {{ .ToR1 }} as {{ .ASN }};
}
protocol bgp tor2 from tor {
neighbor {{ .ToR2 }} as {{ .ASN }};
}
`))
chronyConfTemplate = template.Must(template.New("chrony.conf").Parse(`# Welcome to the chrony configuration file. See chrony.conf(5) for more
# information about usuable directives.
{{ range . }}
server {{ . }} iburst
{{- end }}
# This directive specify the location of the file containing ID/key pairs for
# NTP authentication.
keyfile /etc/chrony/chrony.keys
# This directive specify the file into which chronyd will store the rate
# information.
driftfile /var/lib/chrony/chrony.drift
# Uncomment the following line to turn logging on.
#log tracking measurements statistics
# Log files location.
logdir /var/log/chrony
# Stop bad estimates upsetting machine clock.
maxupdateskew 100.0
# This directive enables kernel synchronisation (every 11 minutes) of the
# real-time clock. Note that it can’t be used along with the 'rtcfile' directive.
rtcsync
# Step the system clock instead of slewing it if the adjustment is larger than
# 0.1 seconds, but only in the first three clock updates.
makestep 0.1 3
# Allow NTP client access from local network.
allow 10.0.0.0/8
# Ignore leap second; adjust by slewing
leapsecmode slew
maxslewrate 1000
smoothtime 400 0.001 leaponly
# mlockall
lock_all
# set highest scheduling priority
sched_priority 99
`))
)