diff --git a/chef/cookbooks/barclamp/libraries/barclamp_library.rb b/chef/cookbooks/barclamp/libraries/barclamp_library.rb index 06927cee8d..acc2f33888 100644 --- a/chef/cookbooks/barclamp/libraries/barclamp_library.rb +++ b/chef/cookbooks/barclamp/libraries/barclamp_library.rb @@ -92,6 +92,8 @@ class Network attr_reader :vlan, :use_vlan attr_reader :add_bridge, :add_ovs_bridge, :bridge_name attr_reader :conduit + attr_reader :ip_version + attr_reader :address_wrapped def initialize(node, net, data) @node = node @@ -112,6 +114,15 @@ def initialize(node, net, data) # let's resolve this only if needed @interface = nil @interface_list = nil + + require "ipaddr" + if IPAddr.new(@subnet).ipv6? + @ip_version = "6" + @address_wrapped = "[#{@address}]" + else + @ip_version = "4" + @address_wrapped = @address + end end def interface diff --git a/chef/cookbooks/dhcp/attributes/default.rb b/chef/cookbooks/dhcp/attributes/default.rb index d2ce1c50df..b657f21933 100644 --- a/chef/cookbooks/dhcp/attributes/default.rb +++ b/chef/cookbooks/dhcp/attributes/default.rb @@ -1,6 +1,6 @@ default[:dhcp][:interfaces] = ["eth0"] -default[:dhcp][:options] = [ +default[:dhcp][:options][:v4] = [ "ddns-update-style none", "allow booting", "option option-128 code 128 = string", @@ -10,4 +10,16 @@ "option dhcp-client-debug code 226 = unsigned integer 16", "option dhcp-client-debug 0" ] +default[:dhcp][:options][:v6] = [ + "ddns-update-style none", + "allow booting", + "option option-128 code 128 = string", + "option option-129 code 129 = text", + "option dhcp-client-state code 225 = unsigned integer 16", + "option dhcp-client-state 0", + "option dhcp-client-debug code 226 = unsigned integer 16", + "option dhcp-client-debug 0", + "option dhcp6.bootfile-url code 59 = string", + "option dhcp6.client-arch-type code 61 = array of unsigned integer 16" +] diff --git a/chef/cookbooks/dhcp/libraries/helpers.rb b/chef/cookbooks/dhcp/libraries/helpers.rb new file mode 100644 index 0000000000..522e479dec --- /dev/null +++ b/chef/cookbooks/dhcp/libraries/helpers.rb @@ -0,0 +1,9 @@ +module DhcpHelper + def self.config_filename(base, ip_version, extension = ".conf") + if ip_version == "4" + "#{base}#{extension}" + else + "#{base}#{ip_version}#{extension}" + end + end +end diff --git a/chef/cookbooks/dhcp/providers/host.rb b/chef/cookbooks/dhcp/providers/host.rb index 6a590d6206..b1d6247695 100644 --- a/chef/cookbooks/dhcp/providers/host.rb +++ b/chef/cookbooks/dhcp/providers/host.rb @@ -24,7 +24,9 @@ hostname: new_resource.hostname, macaddress: new_resource.macaddress, ipaddress: new_resource.ipaddress, - options: new_resource.options + options: new_resource.options, + prefix: new_resource.prefix, + ip_version: new_resource.ip_version ) owner "root" group "root" @@ -35,7 +37,7 @@ end utils_line "include \"#{filename}\";" do action :add - file "/etc/dhcp3/hosts.d/host_list.conf" + file "/etc/dhcp3/hosts.d/#{DhcpHelper.config_filename("host_list", new_resource.ip_version)}" if node[:provisioner][:enable_pxe] notifies :restart, resources(service: "dhcp3-server"), :delayed end @@ -54,11 +56,13 @@ end new_resource.updated_by_last_action(true) end - utils_line "include \"#{filename}\";" do - action :remove - file "/etc/dhcp3/hosts.d/host_list.conf" - if node[:provisioner][:enable_pxe] - notifies :restart, resources(service: "dhcp3-server"), :delayed + ["host_list.conf", "host_list6.conf"].each do |host_list| + utils_line "include \"#{filename}\";" do + action :remove + file "/etc/dhcp3/hosts.d/#{host_list}" + if node[:provisioner][:enable_pxe] + notifies :restart, resources(service: "dhcp3-server"), :delayed + end end end end diff --git a/chef/cookbooks/dhcp/providers/subnet.rb b/chef/cookbooks/dhcp/providers/subnet.rb index f98823f437..f99df276cc 100644 --- a/chef/cookbooks/dhcp/providers/subnet.rb +++ b/chef/cookbooks/dhcp/providers/subnet.rb @@ -14,10 +14,11 @@ # action :add do + subnet_template = DhcpHelper.config_filename("subnet", new_resource.ip_version, ".conf.erb") filename = "/etc/dhcp3/subnets.d/#{new_resource.subnet}.conf" template filename do cookbook "dhcp" - source "subnet.conf.erb" + source subnet_template variables( network: new_resource.network, options: new_resource.options, @@ -31,9 +32,10 @@ notifies :restart, resources(service: "dhcp3-server"), :delayed end end + subnet_file = DhcpHelper.config_filename("subnet_list", new_resource.ip_version) utils_line "include \"#{filename}\";" do action :add - file "/etc/dhcp3/subnets.d/subnet_list.conf" + file "/etc/dhcp3/subnets.d/#{subnet_file}" if node[:provisioner][:enable_pxe] notifies :restart, resources(service: "dhcp3-server"), :delayed end @@ -52,11 +54,13 @@ end new_resource.updated_by_last_action(true) end - utils_line "include \"#{filename}\";" do - action :remove - file "/etc/dhcp3/subnets.d/subnet_list.conf" - if node[:provisioner][:enable_pxe] - notifies :restart, resources(service: "dhcp3-server"), :delayed + ["subnet_list.conf", "subnet_list6.conf"].each do |subnet_list| + utils_line "include \"#{filename}\";" do + action :remove + file "/etc/dhcp3/subnets.d/#{subnet_list}" + if node[:provisioner][:enable_pxe] + notifies :restart, resources(service: "dhcp3-server"), :delayed + end end end end diff --git a/chef/cookbooks/dhcp/recipes/default.rb b/chef/cookbooks/dhcp/recipes/default.rb index 616fa3f2e5..04d4ca259c 100644 --- a/chef/cookbooks/dhcp/recipes/default.rb +++ b/chef/cookbooks/dhcp/recipes/default.rb @@ -33,17 +33,25 @@ directory "/etc/dhcp3/subnets.d" directory "/etc/dhcp3/hosts.d" -file "/etc/dhcp3/groups.d/group_list.conf" do +# This needs to be evaled. +admin_network = Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin") +address = admin_network.address +intfs = [admin_network.interface] + +group_list = DhcpHelper.config_filename("group_list", admin_network.ip_version) +file "/etc/dhcp3/groups.d/#{group_list}" do owner "root" group "root" mode 0644 end -file "/etc/dhcp3/subnets.d/subnet_list.conf" do +subnet_list = DhcpHelper.config_filename("subnet_list", admin_network.ip_version) +file "/etc/dhcp3/subnets.d/#{subnet_list}" do owner "root" group "root" mode 0644 end -file "/etc/dhcp3/hosts.d/host_list.conf" do +host_list = DhcpHelper.config_filename("host_list", admin_network.ip_version) +file "/etc/dhcp3/hosts.d/#{host_list}" do owner "root" group "root" mode 0644 @@ -59,22 +67,20 @@ not_if "test -f /etc/dhcp3/omapi.key" end -# This needs to be evaled. -intfs = [Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").interface] -address = Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address -d_opts = node[:dhcp][:options] +d_opts = node[:dhcp][:options]["v#{admin_network.ip_version}"] +dhcpd_conf = DhcpHelper.config_filename("dhcpd", admin_network.ip_version) case node[:platform_family] when "debian" case node[:lsb][:codename] when "natty","oneiric","precise" - template "/etc/dhcp/dhcpd.conf" do + template "/etc/dhcp/#{dhcpd_conf}" do owner "root" group "root" mode 0644 source "dhcpd.conf.erb" - variables(options: d_opts) + variables(options: d_opts, ip_version: admin_network.ip_version) if node[:provisioner][:enable_pxe] notifies :restart, "service[dhcp3-server]" end @@ -90,12 +96,12 @@ end end else - template "/etc/dhcp3/dhcpd.conf" do + template "/etc/dhcp3/#{dhcpd_conf}" do owner "root" group "root" mode 0644 source "dhcpd.conf.erb" - variables(options: d_opts) + variables(options: d_opts, ip_version: admin_network.ip_version) if node[:provisioner][:enable_pxe] notifies :restart, "service[dhcp3-server]" end @@ -115,9 +121,9 @@ dhcp_config_file = case when node[:platform_version].to_f >= 6 - "/etc/dhcp/dhcpd.conf" + "/etc/dhcp/#{dhcpd_conf}" else - "/etc/dhcpd.conf" + "/etc/#{dhcpd_conf}" end template dhcp_config_file do @@ -125,7 +131,7 @@ group "root" mode 0644 source "dhcpd.conf.erb" - variables(options: d_opts) + variables(options: d_opts, ip_version: admin_network.ip_version) if node[:provisioner][:enable_pxe] notifies :restart, "service[dhcp3-server]" end @@ -143,12 +149,12 @@ end when "suse" - template "/etc/dhcpd.conf" do + template "/etc/#{dhcpd_conf}" do owner "root" group "root" mode 0644 source "dhcpd.conf.erb" - variables(options: d_opts) + variables(options: d_opts, ip_version: admin_network.ip_version) if node[:provisioner][:enable_pxe] notifies :restart, "service[dhcp3-server]" end @@ -168,7 +174,7 @@ service "dhcp3-server" do if %w(suse rhel).include?(node[:platform_family]) - service_name "dhcpd" + service_name DhcpHelper.config_filename("dhcpd", admin_network.ip_version, "") elsif node[:platform] == "ubuntu" case node[:lsb][:codename] when "maverick" diff --git a/chef/cookbooks/dhcp/resources/host.rb b/chef/cookbooks/dhcp/resources/host.rb index 0ef4f62f49..aa47107510 100644 --- a/chef/cookbooks/dhcp/resources/host.rb +++ b/chef/cookbooks/dhcp/resources/host.rb @@ -19,6 +19,8 @@ attribute :hostname, kind_of: String attribute :macaddress, kind_of: String attribute :ipaddress, kind_of: String +attribute :prefix, kind_of: String +attribute :ip_version, kind_of: String, default: "4" attribute :group, kind_of: String attribute :options, kind_of: Array, default: [] diff --git a/chef/cookbooks/dhcp/resources/subnet.rb b/chef/cookbooks/dhcp/resources/subnet.rb index 97f18a9bb7..a6b6cda0a8 100644 --- a/chef/cookbooks/dhcp/resources/subnet.rb +++ b/chef/cookbooks/dhcp/resources/subnet.rb @@ -20,4 +20,5 @@ attribute :pools, kind_of: Array, default: ["dhcp"] attribute :pool_options, kind_of: Hash, default: { "dhcp" => ["allow unknown-hosts"] } attribute :options, kind_of: Array, default: [] +attribute :ip_version, kind_of: String, default: "4" diff --git a/chef/cookbooks/dhcp/templates/default/dhcpd.conf.erb b/chef/cookbooks/dhcp/templates/default/dhcpd.conf.erb index 3bb3deb9bf..043c68b59d 100644 --- a/chef/cookbooks/dhcp/templates/default/dhcpd.conf.erb +++ b/chef/cookbooks/dhcp/templates/default/dhcpd.conf.erb @@ -21,6 +21,12 @@ log-facility local7; # Fix for https://bugzilla.opensuse.org/show_bug.cgi?id=961536 always-reply-rfc1048 true; +<% if @ip_version == "6" -%> +include "/etc/dhcp3/groups.d/group_list6.conf"; +include "/etc/dhcp3/subnets.d/subnet_list6.conf"; +include "/etc/dhcp3/hosts.d/host_list6.conf"; +<% else -%> include "/etc/dhcp3/groups.d/group_list.conf"; include "/etc/dhcp3/subnets.d/subnet_list.conf"; include "/etc/dhcp3/hosts.d/host_list.conf"; +<% end -%> diff --git a/chef/cookbooks/dhcp/templates/default/host.conf.erb b/chef/cookbooks/dhcp/templates/default/host.conf.erb index f2f6917860..8a09ec47ec 100644 --- a/chef/cookbooks/dhcp/templates/default/host.conf.erb +++ b/chef/cookbooks/dhcp/templates/default/host.conf.erb @@ -2,7 +2,12 @@ host <%= @name %> { option host-name "<%= @hostname %>"; hardware ethernet <%= @macaddress %>; <% if @ipaddress -%> +<% if @ip_version == "6" -%> + fixed-address6 <%= @ipaddress %>; + fixed-prefix6 <%= @prefix %>; +<% else -%> fixed-address <%= @ipaddress %>; +<% end -%> <% else -%> deny booting; <% end -%> diff --git a/chef/cookbooks/dhcp/templates/default/subnet6.conf.erb b/chef/cookbooks/dhcp/templates/default/subnet6.conf.erb new file mode 100644 index 0000000000..d8af240f5e --- /dev/null +++ b/chef/cookbooks/dhcp/templates/default/subnet6.conf.erb @@ -0,0 +1,19 @@ +# File managed by Crowbar +<% if node[:provisioner][:enable_pxe] -%> + +subnet6 <%= @network["subnet"] %>/<%= @network["netmask"]%> { + option subnet-mask <%= @network["netmask"] %>; +<% @options.each do |option| -%> + <%= option %>; +<% end -%> +<% @pools.each do |pool| -%> + pool6 { + range6 <%=@network["ranges"][pool]["start"]%> <%=@network["ranges"][pool]["end"]%>; + <% @pool_options[pool].each do |opt| -%> + <%=opt%><%=if opt[-1,1] != '}' then ';' else '' end%> + <% end if @pool_options[pool] -%> + } +<% end -%> +} + +<% end -%> diff --git a/chef/cookbooks/dhcp/templates/default/suse-sysconfig-dhcpd.erb b/chef/cookbooks/dhcp/templates/default/suse-sysconfig-dhcpd.erb index 34d3605af4..6d17f1d354 100644 --- a/chef/cookbooks/dhcp/templates/default/suse-sysconfig-dhcpd.erb +++ b/chef/cookbooks/dhcp/templates/default/suse-sysconfig-dhcpd.erb @@ -2,6 +2,7 @@ # Do not edit. <% unless @interfaces.empty? -%> DHCPD_INTERFACE="<%= @interfaces.collect! {|i| "#{i}" }.join(" ") %>" +DHCPD6_INTERFACE="<%= @interfaces.collect! {|i| "#{i}" }.join(" ") %>" <% end -%> DHCPD_IFUP_RESTART="" DHCPD_RUN_CHROOTED="no" diff --git a/chef/cookbooks/network/libraries/helpers.rb b/chef/cookbooks/network/libraries/helpers.rb new file mode 100644 index 0000000000..d94467878e --- /dev/null +++ b/chef/cookbooks/network/libraries/helpers.rb @@ -0,0 +1,12 @@ +module NetworkHelper + def self.wrap_ip(address) + require "ipaddr" + if IPAddr.new(address).ipv6? + "[#{address}]" + else + address.to_s + end + rescue + address.to_s + end +end diff --git a/chef/cookbooks/provisioner/recipes/base.rb b/chef/cookbooks/provisioner/recipes/base.rb index 19252b6ef6..09bd01bee4 100644 --- a/chef/cookbooks/provisioner/recipes/base.rb +++ b/chef/cookbooks/provisioner/recipes/base.rb @@ -349,7 +349,7 @@ crowbar_node = node_search_with_cache("roles:crowbar").first address = crowbar_node["crowbar"]["network"]["admin"]["address"] protocol = crowbar_node["crowbar"]["apache"]["ssl"] ? "https" : "http" -server = "#{protocol}://#{address}" +server = "#{protocol}://#{NetworkHelper.wrap_ip(address)}" password = crowbar_node["crowbar"]["users"]["crowbar"]["password"] verify_ssl = !crowbar_node["crowbar"]["apache"]["insecure"] diff --git a/chef/cookbooks/provisioner/recipes/dhcp_update.rb b/chef/cookbooks/provisioner/recipes/dhcp_update.rb index 3a6e01ca19..5349c1cba1 100644 --- a/chef/cookbooks/provisioner/recipes/dhcp_update.rb +++ b/chef/cookbooks/provisioner/recipes/dhcp_update.rb @@ -1,4 +1,6 @@ -admin_ip = Barclamp::Inventory.get_network_by_type(node, "admin").address +admin_net = Barclamp::Inventory.get_network_by_type(node, "admin") +admin_ip = admin_net.address +admin_ip_version = admin_net.ip_version dns_config = Barclamp::Config.load("core", "dns") dns_servers = dns_config["servers"] || [] @@ -8,16 +10,17 @@ admin_net = Barclamp::Inventory.get_network_definition(node, "admin") lease_time = node[:provisioner][:dhcp]["lease-time"] +admin6_uri = "tftp://[#{admin_ip}]/discovery" -pool_opts = { - "dhcp" => ["allow unknown-clients", - "default-lease-time #{lease_time}", - "max-lease-time #{lease_time}", - 'if exists dhcp-parameter-request-list { +ipv4_dhcp_opts = [ + "allow unknown-clients", + "default-lease-time #{lease_time}", + "max-lease-time #{lease_time}", + 'if exists dhcp-parameter-request-list { # Always send the PXELINUX options (specified in hexadecimal) option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list,d0,d1,d2,d3); }', - 'if option arch = 00:06 { + 'if option arch = 00:06 { filename = "discovery/ia32/efi/bootia32.efi"; } else if option arch = 00:07 { filename = "discovery/x86_64/efi/default/boot/bootx64.efi"; @@ -31,18 +34,56 @@ } else { filename = "discovery/x86_64/bios/pxelinux.0"; }', - "next-server #{admin_ip}"], + "next-server #{admin_ip}" +] + +ipv6_dhcp_opts = [ + "allow unknown-clients", + "default-lease-time #{lease_time}", + "max-lease-time #{lease_time}", + 'if exists dhcp-parameter-request-list { + # Always send the PXELINUX options (specified in hexadecimal) + option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list,d0,d1,d2,d3); + }', + "if option dhcp6.client-arch-type = 00:06 { + option dhcp6.bootfile-url \"#{admin6_uri}/ia32/efi/bootia32.efi\"; + } else if option dhcp6.client-arch-type = 00:07 { + option dhcp6.bootfile-url \"/#{admin6_uri}x86_64/efi/default/boot/bootx64.efi\"; + } else if option dhcp6.client-arch-type = 00:09 { + option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/efi/default/boot/bootx64.efi\"; + } else if option dhcp6.client-arch-type = 00:0b { + option dhcp6.bootfile-url \"#{admin6_uri}/aarch64/efi/default/boot/bootaa64.efi\"; + } else if option dhcp6.client-arch-type = 00:0e { + option dhcp6.bootfile-url \"#{admin6_uri}/discovery/ppc64le/bios/\"; + } else { + option dhcp6.bootfile-url \"#{admin6_uri}/x86_64/bios/pxelinux.0\"; + }" +] + +pool_opts = { "host" => ["deny unknown-clients"] } +if admin_ip_version == "6" + pool_opts["dhcp"] = ipv6_dhcp_opts + subnet_options = [ + "option domain-name \"#{domain_name}\"", + "option dhcp6.name-servers #{dns_servers.join(", ")}" + ] +else + pool_opts["dhcp"] = ipv4_dhcp_opts + subnet_options = [ + "server-identifier #{admin_ip}", + "option domain-name \"#{domain_name}\"", + "option domain-name-servers #{dns_servers.join(", ")}" + ] +end + dhcp_subnet admin_net["subnet"] do action :add network admin_net pools ["dhcp","host"] pool_options pool_opts - options [ - "server-identifier #{admin_ip}", - "option domain-name \"#{domain_name}\"", - "option domain-name-servers #{dns_servers.join(", ")}" - ] + options subnet_options + ip_version admin_ip_version end diff --git a/chef/cookbooks/provisioner/recipes/setup_base_images.rb b/chef/cookbooks/provisioner/recipes/setup_base_images.rb index 490b417067..7c4ebee2ba 100644 --- a/chef/cookbooks/provisioner/recipes/setup_base_images.rb +++ b/chef/cookbooks/provisioner/recipes/setup_base_images.rb @@ -22,7 +22,8 @@ admin_ip = admin_net.address domain_name = node[:dns].nil? ? node[:domain] : (node[:dns][:domain] || node[:domain]) web_port = node[:provisioner][:web_port] -provisioner_web="http://#{admin_ip}:#{web_port}" +provisioner_web = "http://#{admin_ip}:#{web_port}" unless admin_net.ip_version == "6" +provisioner_web = "http://[#{admin_ip}]:#{web_port}" if admin_net.ip_version == "6" append_line = node[:provisioner][:discovery][:append].dup # We'll modify it inline crowbar_node = node_search_with_cache("roles:crowbar").first @@ -298,12 +299,13 @@ notifies :reload, resources(service: "xinetd") end else + ip_addr = admin_net.ip_version == "6" ? "[#{admin_ip}]" : admin_ip template "/etc/systemd/system/tftp.service" do source "tftp.service.erb" owner "root" group "root" mode "0644" - variables(tftproot: tftproot, admin_ip: admin_ip) + variables(tftproot: tftproot, admin_ip: ip_addr) end service "tftp.service" do @@ -511,7 +513,8 @@ web_port: web_port, ntp_servers_ips: ntp_servers, platform: target_platform_distro, - target_platform_version: target_platform_version) + target_platform_version: target_platform_version, + ip_version: admin_net.ip_version) end repos = Provisioner::Repositories.get_repos(target_platform_distro, @@ -538,7 +541,8 @@ repos: repos, packages: packages, platform: target_platform_distro, - target_platform_version: target_platform_version) + target_platform_version: target_platform_version, + ip_version: admin_net.ip_version) end missing_files = !File.exist?("#{os_dir}/install/boot/#{arch}/common") diff --git a/chef/cookbooks/provisioner/recipes/update_nodes.rb b/chef/cookbooks/provisioner/recipes/update_nodes.rb index ae40ff805b..500cda79d0 100644 --- a/chef/cookbooks/provisioner/recipes/update_nodes.rb +++ b/chef/cookbooks/provisioner/recipes/update_nodes.rb @@ -149,6 +149,7 @@ def find_node_boot_mac_addresses(node, admin_data_net) admin_data_net = Chef::Recipe::Barclamp::Inventory.get_network_by_type(mnode, "admin") admin_mac_addresses = find_node_boot_mac_addresses(mnode, admin_data_net) admin_ip_address = admin_data_net.nil? ? mnode[:ipaddress] : admin_data_net.address + admin_prefix = admin_data_net.nil? ? "" : "#{admin_data_net.subnet}/#{admin_data_net.netmask}" #### # First deal with states that don't require PXE booting @@ -178,6 +179,8 @@ def find_node_boot_mac_addresses(node, admin_data_net) hostname mnode.name if admin_mac_addresses.include?(mac_list[i]) ipaddress admin_ip_address + prefix admin_prefix + ip_version admin_data_net.ip_version end macaddress mac_list[i] action :add @@ -244,6 +247,8 @@ def find_node_boot_mac_addresses(node, admin_data_net) }", "next-server #{admin_ip}" ] + prefix admin_prefix + ip_version admin_data_net.ip_version end action :add end diff --git a/chef/cookbooks/provisioner/templates/default/crowbar_join.suse.sh.erb b/chef/cookbooks/provisioner/templates/default/crowbar_join.suse.sh.erb index 1a232323a7..693a8bc69d 100644 --- a/chef/cookbooks/provisioner/templates/default/crowbar_join.suse.sh.erb +++ b/chef/cookbooks/provisioner/templates/default/crowbar_join.suse.sh.erb @@ -114,7 +114,11 @@ wait_for_hostname() { wait_for_admin_server() { # wait for admin server to become pingable tries_left=120 - while ! ping -q -c1 $IP > /dev/null; do + local ping="ping" + if (( $IPV6 > 0 )); then + ping="ping6" + fi + while ! $ping -q -c1 $IP > /dev/null; do tries_left=$(($tries_left-1)) if [ $tries_left -eq 0 ]; then return 1 @@ -163,9 +167,9 @@ do_setup() { # Make sure that the client knows how to talk to the server. local cfg=/etc/chef/client.rb if ! [ -f $cfg ] || \ - ! grep -q "^\s*chef_server_url\s*[\"\']http://$IP:4000[\"\']" $cfg; then + ! grep -q "^\s*chef_server_url\s*[\"\']http://$IP_WRAPPED:4000[\"\']" $cfg; then test -f $cfg && mv $cfg $cfg.bak - echo "chef_server_url \"http://$IP:4000\"" >$cfg + echo "chef_server_url \"http://$IP_WRAPPED:4000\"" >$cfg echo "zypper_check_gpg true" >> $cfg fi @@ -398,7 +402,17 @@ EXVAL=0 export HOME=/root IP="<%= @admin_ip %>" -HTTP_SERVER="<%= @admin_ip %>:<%= @web_port %>" +<% if @ip_version == "6" -%> +IPV6=1 +<% else -%> +IPV6=0 +<% end -%> +if (( $IPV6 > 0 )); then + IP_WRAPPED="[$IP]" +else + IP_WRAPPED="$IP" +fi +HTTP_SERVER="$IP_WRAPPED:<%= @web_port %>" NTP_SERVERS="<%= @ntp_servers_ips.join(" ") %>" VALID_NTP_SERVERS="" diff --git a/chef/cookbooks/provisioner/templates/default/tftp.erb b/chef/cookbooks/provisioner/templates/default/tftp.erb index ba53690d62..97c72cf718 100644 --- a/chef/cookbooks/provisioner/templates/default/tftp.erb +++ b/chef/cookbooks/provisioner/templates/default/tftp.erb @@ -8,7 +8,7 @@ service tftp socket_type = dgram protocol = udp wait = yes - flags = IPv4 + flags = IPv6 IPv4 user = root server = /usr/sbin/in.tftpd server_args = -m /etc/tftpd.conf -s <%=@tftproot%> diff --git a/chef/cookbooks/provisioner/templates/suse/crowbar_register.erb b/chef/cookbooks/provisioner/templates/suse/crowbar_register.erb index b538e7f78d..7bff7da392 100644 --- a/chef/cookbooks/provisioner/templates/suse/crowbar_register.erb +++ b/chef/cookbooks/provisioner/templates/suse/crowbar_register.erb @@ -122,7 +122,17 @@ add_user() { ADMIN_IP="<%= @admin_ip %>" ADMIN_BROADCAST="<%= @admin_broadcast %>" WEB_PORT="<%= @web_port %>" -HTTP_SERVER="http://${ADMIN_IP}:${WEB_PORT}" +<% if @ip_version == "6" -%> +IPV6=1 +<% else -%> +IPV6=0 +<% end -%> +if (( $IPV6 > 0 )); then + ADMIN_IP_WRAPPED="[ADMIN_IP]" +else + ADMIN_IP_WRAPPED="ADMIN_IP" +fi +HTTP_SERVER="http://${ADMIN_IP_WRAPPED}:${WEB_PORT}" CROWBAR_OS="<%= @os %>" CROWBAR_ARCH="<%= @arch %>" CROWBAR_KEY="<%= @crowbar_key %>" @@ -381,7 +391,7 @@ TMP_ATTRIBUTES=$(mktemp --suffix .json) echo "{ \"target_platform\": \"$CROWBAR_OS\", \"crowbar_wall\": { \"registering\": true } }" > "$TMP_ATTRIBUTES" crowbarctl node transition $HOSTNAME "discovering" -chef-client -S http://$ADMIN_IP:4000/ -N "$HOSTNAME" --json-attributes "$TMP_ATTRIBUTES" +chef-client -S http://$ADMIN_IP_WRAPPED:4000/ -N "$HOSTNAME" --json-attributes "$TMP_ATTRIBUTES" crowbarctl node transition $HOSTNAME "discovered" # TODO need to find way of knowing that chef run is over on server side sleep 30 @@ -393,7 +403,7 @@ echo '{ "crowbar_wall": { "registering": true } }' > "$TMP_ATTRIBUTES" rm -f /etc/chef/client.pem crowbarctl node transition $HOSTNAME "hardware-installing" -chef-client -S http://$ADMIN_IP:4000/ -N "$HOSTNAME" --json-attributes "$TMP_ATTRIBUTES" +chef-client -S http://$ADMIN_IP_WRAPPED:4000/ -N "$HOSTNAME" --json-attributes "$TMP_ATTRIBUTES" crowbarctl node transition $HOSTNAME "hardware-installed" #TODO #wait_for_pxe_state ".*_install"