Skip to content

Commit f087627

Browse files
committed
IPv6: ntp.conf requires netmask in non CIDR format
The ntp.conf used in crowbar wont work with IPv6 as the netmask in the ntp conf file need to be in the full form not CIDR. This patch adds a new method, cidr_to_subnet to the Barclamp library's Network class. Which is then used to send the correct string to the ntp.conf.erb template. Allowing the crowbar nodes being booted via the sleshammer discovery image to sync with the admin node.
1 parent bda4ac8 commit f087627

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

chef/cookbooks/barclamp/libraries/barclamp_library.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@ def interface_list
132132
@interface_list
133133
end
134134

135+
def cidr_to_netmask
136+
if @ip_version == "6"
137+
range = 128
138+
else
139+
range = 32
140+
end
141+
142+
cidr = Integer(@netmask) rescue nil
143+
if cidr && !(1..range).cover?(cidr)
144+
Chef::Log.error("Invalid CIDR netmask '#{cidr}' > '#{range}'")
145+
return @netmask
146+
end
147+
148+
if cidr
149+
if @ip_version == "6"
150+
IPAddr.new('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff').mask(cidr).to_s
151+
else
152+
IPAddr.new('255.255.255.255').mask(cidr).to_s
153+
end
154+
else
155+
@netmask
156+
end
157+
end
158+
135159
protected
136160

137161
def resolve_interface_info

chef/cookbooks/ntp/recipes/default.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
variables(ntp_servers: ntp_servers,
8080
admin_interface: local_admin_address,
8181
admin_subnet: admin_net.subnet,
82-
admin_netmask: admin_net.netmask,
82+
admin_netmask: admin_net.cidr_to_netmask(),
8383
is_server: is_server,
8484
listen_interfaces: listen_network_addresses || [],
8585
fudgevalue: 10,

0 commit comments

Comments
 (0)