]> git.openstreetmap.org Git - chef.git/blob - cookbooks/networking/templates/default/network.erb
Use ruby cookbook to install ruby for prometheus
[chef.git] / cookbooks / networking / templates / default / network.erb
1 [Match]
2 Name=<%= @interface[:interface] %>
3
4 [Network]
5 <% if @interface.dig(:inet6, :dhcp) -%>
6 DHCP=ipv6
7 <% end -%>
8 <% if @interface[:inet] -%>
9 Address=<%= @interface[:inet][:address] %>/<%== @interface[:inet][:prefix] %>
10 <% end -%>
11 <% if @interface[:inet6] -%>
12 Address=<%= @interface[:inet6][:address] %>/<%== @interface[:inet6][:prefix] %>
13 <% end -%>
14 IPv6AcceptRA=no
15 <% Array(@interface[:vlans]).sort.uniq.each do |vlan| -%>
16 VLAN=<%= @interface[:interface] %>.<%= vlan %>
17 <% end -%>
18 <% if @interface[:interface] =~ /^bond\d+$/ && node[:packages][:systemd][:version].to_i < 254 -%>
19
20 [Link]
21 RequiredFamilyForOnline=ipv4
22 RequiredForOnline=degraded-carrier
23 <% end -%>
24 <% if @interface.dig(:inet6, :dhcp) -%>
25
26 [DHCPv6]
27 <% if @interface[:inet6][:dhcp][:duidtype] -%>
28 DUIDType=<%= @interface[:inet6][:dhcp][:duidtype] %>
29 <% end -%>
30 <% if @interface[:inet6][:dhcp][:duidrawdata] -%>
31 DUIDRawData=<%= @interface[:inet6][:dhcp][:duidrawdata] %>
32 <% end -%>
33 WithoutRA=solicit
34 <% end -%>
35 <% if @interface.dig(:inet, :gateway) && @interface[:inet][:gateway] != @interface[:inet][:address] -%>
36
37 [Route]
38 Gateway=<%= @interface[:inet][:gateway] %>
39 GatewayOnLink=true
40 <% if @interface[:metric] -%>
41 Metric=<%= @interface[:metric] %>
42 <% end -%>
43 <% if @interface[:source_route_table] -%>
44
45 [Route]
46 Gateway=<%= @interface[:inet][:gateway] %>
47 GatewayOnLink=true
48 <% if @interface[:metric] -%>
49 Metric=<%= @interface[:metric] %>
50 <% end -%>
51 Table=<%= @interface[:source_route_table] %>
52
53 [RoutingPolicyRule]
54 From=<%= @interface[:inet][:address] %>
55 Table=<%= @interface[:source_route_table] %>
56 <% end -%>
57 <% end -%>
58 <% if @interface.dig(:inet6, :gateway) && @interface[:inet6][:gateway] != @interface[:inet6][:address] -%>
59
60 [Route]
61 Gateway=<%= @interface[:inet6][:gateway] %>
62 GatewayOnLink=true
63 <% if @interface[:metric] -%>
64 Metric=<%= @interface[:metric] %>
65 <% end -%>
66 <% if @interface[:source_route_table] -%>
67
68 [Route]
69 Gateway=<%= @interface[:inet6][:gateway] %>
70 GatewayOnLink=true
71 <% if @interface[:metric] -%>
72 Metric=<%= @interface[:metric] %>
73 <% end -%>
74 Table=<%= @interface[:source_route_table] %>
75
76 [RoutingPolicyRule]
77 From=<%= @interface[:inet6][:address] %>
78 Table=<%= @interface[:source_route_table] %>
79 <% end -%>
80 <% end -%>
81 <% Hash(@interface.dig(:inet, :routes)).sort.each do |destination, details| -%>
82 <% unless details[:via] == @interface[:inet][:address] -%>
83
84 [Route]
85 <% if details[:via] -%>
86 Gateway=<%= details[:via] %>
87 <% end -%>
88 Destination=<%= destination %>
89 <% if details[:metric] -%>
90 Metric=<%= details[:metric] %>
91 <% end -%>
92 <% if details[:type] -%>
93 Type=<%= details[:type] %>
94 <% end -%>
95 <% end -%>
96 <% end -%>
97 <% Hash(@interface.dig(:inet6, :routes)).sort.each do |destination, details| -%>
98 <% unless details[:via] == @interface[:inet6][:address] -%>
99
100 [Route]
101 <% if details[:via] -%>
102 Gateway=<%= details[:via] %>
103 <% end -%>
104 Destination=<%= destination %>
105 <% if details[:metric] -%>
106 Metric=<%= details[:metric] %>
107 <% end -%>
108 <% if details[:type] -%>
109 Type=<%= details[:type] %>
110 <% end -%>
111 <% end -%>
112 <% end -%>