diff --git a/01_install_requirements.sh b/01_install_requirements.sh index a9207d305..e0d6de281 100755 --- a/01_install_requirements.sh +++ b/01_install_requirements.sh @@ -17,7 +17,7 @@ if [ -z "${METAL3_DEV_ENV}" ]; then # TODO -- come up with a plan for continuously updating this # Note we only do this in the case where METAL3_DEV_ENV is # unset, to enable developer testing of local checkouts - git reset d31a9c11651c4baaeb82c3db4a30b613713f3dba --hard + git reset 553e12f0f6c5f1af6761d7b4799e77b5df607572 --hard popd fi diff --git a/02_configure_host.sh b/02_configure_host.sh index 3aa873472..cded05a63 100755 --- a/02_configure_host.sh +++ b/02_configure_host.sh @@ -3,6 +3,7 @@ set -xe source logging.sh source common.sh +source network.sh source utils.sh source ocp_install_env.sh diff --git a/03_build_installer.sh b/03_build_installer.sh index 070358242..0e9900a61 100755 --- a/03_build_installer.sh +++ b/03_build_installer.sh @@ -3,8 +3,9 @@ set -x set -e source logging.sh -source utils.sh source common.sh +source network.sh +source utils.sh source ocp_install_env.sh # Extract an updated client tools from the release image diff --git a/04_setup_ironic.sh b/04_setup_ironic.sh index 8bf9cae2f..58c53c1fe 100755 --- a/04_setup_ironic.sh +++ b/04_setup_ironic.sh @@ -4,6 +4,7 @@ set -euxo pipefail source logging.sh source common.sh +source network.sh source rhcos.sh source ocp_install_env.sh source utils.sh diff --git a/05_create_install_config.sh b/05_create_install_config.sh index 1cd932b11..8e42f929e 100755 --- a/05_create_install_config.sh +++ b/05_create_install_config.sh @@ -3,8 +3,9 @@ set -x set -e source logging.sh -source utils.sh source common.sh +source network.sh +source utils.sh source ocp_install_env.sh source rhcos.sh @@ -14,10 +15,10 @@ verify_pull_secret if [ "$MANAGE_BR_BRIDGE" == "y" ] ; then if [[ -z "${EXTERNAL_SUBNET_V4}" ]]; then API_VIP=$(dig -t AAAA +noall +answer "api.${CLUSTER_DOMAIN}" @$(network_ip ${BAREMETAL_NETWORK_NAME}) | awk '{print $NF}') - INGRESS_VIP=$(python -c "from ansible.plugins.filter import ipaddr; print(ipaddr.nthhost('"$EXTERNAL_SUBNET_V6"', 4))") + INGRESS_VIP=$(nth_ip $EXTERNAL_SUBNET_V6 4) else API_VIP=$(dig +noall +answer "api.${CLUSTER_DOMAIN}" @$(network_ip ${BAREMETAL_NETWORK_NAME}) | awk '{print $NF}') - INGRESS_VIP=$(python -c "from ansible.plugins.filter import ipaddr; print(ipaddr.nthhost('"$EXTERNAL_SUBNET_V4"', 4))") + INGRESS_VIP=$(nth_ip $EXTERNAL_SUBNET_V4 4) fi echo "address=/api.${CLUSTER_DOMAIN}/${API_VIP}" | sudo tee -a /etc/NetworkManager/dnsmasq.d/openshift-${CLUSTER_NAME}.conf echo "address=/.apps.${CLUSTER_DOMAIN}/${INGRESS_VIP}" | sudo tee -a /etc/NetworkManager/dnsmasq.d/openshift-${CLUSTER_NAME}.conf diff --git a/06_create_cluster.sh b/06_create_cluster.sh index 67883ea78..7f22dab2d 100755 --- a/06_create_cluster.sh +++ b/06_create_cluster.sh @@ -3,8 +3,9 @@ set -x set -e source logging.sh -source utils.sh source common.sh +source network.sh +source utils.sh source ocp_install_env.sh source rhcos.sh diff --git a/common.sh b/common.sh index 6fb373d63..5ff129286 100644 --- a/common.sh +++ b/common.sh @@ -48,6 +48,8 @@ source $CONFIG export CLUSTER_NAME=${CLUSTER_NAME:-ostest} +export PROVISIONING_NETWORK_PROFILE=${PROVISIONING_NETWORK_PROFILE:-"Managed"} + # Network interface names can only be 15 characters long, so # abbreviate provisioning and baremetal and add them as suffixes to # the cluster name. @@ -61,139 +63,19 @@ export SSH_PUB_KEY="${SSH_PUB_KEY:-$(cat $HOME/.ssh/id_rsa.pub)}" # mirror images for installation in restricted network export MIRROR_IMAGES=${MIRROR_IMAGES:-} -export IP_STACK=${IP_STACK:-"v6"} - -EXTERNAL_SUBNET=${EXTERNAL_SUBNET:-""} -EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-""} -EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-""} -if [[ -n "${EXTERNAL_SUBNET}" ]] && [[ -z "${EXTERNAL_SUBNET_V4}" ]] && [[ -z "${EXTERNAL_SUBNET_V6}" ]]; then - # Backwards compatibility. If the old var was specified, and neither of the new - # vars are set, automatically adapt it to the right new var. - if [[ "${EXTERNAL_SUBNET}" =~ .*:.* ]]; then - export EXTERNAL_SUBNET_V6="${EXTERNAL_SUBNET}" - else - export EXTERNAL_SUBNET_V4="${EXTERNAL_SUBNET}" - fi -elif [[ -n "${EXTERNAL_SUBNET}" ]]; then - echo "EXTERNAL_SUBNET has been removed in favor of EXTERNAL_SUBNET_V4 and EXTERNAL_NETWORK_V6." - echo "Please update your configuration to drop the use of EXTERNAL_SUBNET." - exit 1 -fi - -SERVICE_SUBNET=${SERVICE_SUBNET:-""} -SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-""} -SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-""} -if [[ -n "${SERVICE_SUBNET}" ]] && [[ -z "${SERVICE_SUBNET_V4}" ]] && [[ -z "${SERVICE_SUBNET_V6}" ]]; then - # Backwards compatibility. If the old var was specified, and neither of the new - # vars are set, automatically adapt it to the right new var. - if [[ "${SERVICE_SUBNET}" =~ .*:.* ]]; then - export SERVICE_SUBNET_V6="${SERVICE_SUBNET}" - else - export SERVICE_SUBNET_V4="${SERVICE_SUBNET}" - fi -elif [[ -n "${SERVICE_SUBNET}" ]]; then - echo "SERVICE_SUBNET has been removed in favor of SERVICE_SUBNET_V4 and SERVICE_SUBNET_V6." - echo "Please update your configuration to drop the use of SERVICE_SUBNET." - exit 1 -fi - -CLUSTER_SUBNET=${CLUSTER_SUBNET:-""} -CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-""} -CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-""} -CLUSTER_HOST_PREFIX=${CLUSTER_HOST_PREFIX:-""} -CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-""} -CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-""} -if [[ -n "${CLUSTER_SUBNET}" ]] && [[ -z "${CLUSTER_SUBNET_V4}" ]] && [[ -z "${CLUSTER_SUBNET_V6}" ]]; then - # Backwards compatibility. If the old var was specified, and neither of the new - # vars are set, automatically adapt it to the right new var. - if [[ "${CLUSTER_SUBNET}" =~ .*:.* ]]; then - export CLUSTER_SUBNET_V6="${CLUSTER_SUBNET}" - export CLUSTER_HOST_PREFIX_V6="${CLUSTER_HOST_PREFIX_V6:-${CLUSTER_HOST_PREFIX}}" - else - export CLUSTER_SUBNET_V4="${CLUSTER_SUBNET}" - export CLUSTER_HOST_PREFIX_V4="${CLUSTER_HOST_PREFIX_V4:-${CLUSTER_HOST_PREFIX}}" - fi -elif [[ -n "${CLUSTER_SUBNET}" ]]; then - echo "CLUSTER_SUBNET has been removed in favor of CLUSTER_SUBNET_V4 and CLUSTER_SUBNET_V6." - echo "Please update your configuration to drop the use of CLUSTER_SUBNET." - exit 1 -fi - - -if [[ "$IP_STACK" = "v4" ]] -then - export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"172.22.0.0/24"} - export EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-"192.168.111.0/24"} - export EXTERNAL_SUBNET_V6="" - export CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-"10.128.0.0/14"} - export CLUSTER_SUBNET_V6="" - export CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-"23"} - export CLUSTER_HOST_PREFIX_V6="" - export SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-"172.30.0.0/16"} - export SERVICE_SUBNET_V6="" - export NETWORK_TYPE=${NETWORK_TYPE:-"OpenShiftSDN"} -elif [[ "$IP_STACK" = "v6" ]]; then - export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"fd00:1101::0/64"} - export EXTERNAL_SUBNET_V4="" - export EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-"fd2e:6f44:5dd8:c956::/120"} - export CLUSTER_SUBNET_V4="" - export CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-"fd01::/48"} - export CLUSTER_HOST_PREFIX_V4="" - export CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-"64"} - export SERVICE_SUBNET_V4="" - export SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-"fd02::/112"} - export NETWORK_TYPE=${NETWORK_TYPE:-"OVNKubernetes"} - export MIRROR_IMAGES=true -elif [[ "$IP_STACK" = "v4v6" ]]; then - export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"fd00:1101::0/64"} - export EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-"192.168.111.0/24"} - export EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-"fd2e:6f44:5dd8:c956::/120"} - export CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-"10.128.0.0/14"} - export CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-"fd01::/48"} - export CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-"23"} - export CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-"64"} - export SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-"172.30.0.0/16"} - export SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-"fd02::/112"} - export NETWORK_TYPE=${NETWORK_TYPE:-"OVNKubernetes"} - export MIRROR_IMAGES=true -else - echo "Unexpected setting for IP_STACK: '${IP_STACK}'" - exit 1 -fi - -if [[ "${IP_STACK}" = "v6" ]]; then - export DNS_VIP=${DNS_VIP:-$(python -c "import ipaddress; print(ipaddress.ip_network(u\"$EXTERNAL_SUBNET_V6\")[2])")} -else - export DNS_VIP=${DNS_VIP:-$(python -c "import ipaddress; print(ipaddress.ip_network(u\"$EXTERNAL_SUBNET_V4\")[2])")} -fi - -# The DNS name for the registry that this cluster should use. -export LOCAL_REGISTRY_DNS_NAME=${LOCAL_REGISTRY_DNS_NAME:-"virthost.${CLUSTER_NAME}.${BASE_DOMAIN}"} -# All DNS names for the registry, to be included in the certificate. -export ALL_REGISTRY_DNS_NAMES=${ALL_REGISTRY_DNS_NAMES:-${LOCAL_REGISTRY_DNS_NAME}} - -# Provisioning network information -export CLUSTER_PRO_IF=${CLUSTER_PRO_IF:-enp1s0} -export PROVISIONING_NETMASK=${PROVISIONING_NETMASK:-$(ipcalc --netmask $PROVISIONING_NETWORK | cut -d= -f2)} - # Hypervisor details export REMOTE_LIBVIRT=${REMOTE_LIBVIRT:-0} export PROVISIONING_HOST_USER=${PROVISIONING_HOST_USER:-$USER} -# ipcalc on CentOS 7 doesn't support the 'minaddr' option, so use python -# instead to get the first address in the network: -export PROVISIONING_HOST_IP=${PROVISIONING_HOST_IP:-$(python -c "import ipaddress; print(next(ipaddress.ip_network(u\"$PROVISIONING_NETWORK\").hosts()))")} -if [[ "${IP_STACK}" = "v6" ]]; then - export PROVISIONING_HOST_EXTERNAL_IP=${PROVISIONING_HOST_EXTERNAL_IP:-$(python -c "import ipaddress; print(next(ipaddress.ip_network(u\"$EXTERNAL_SUBNET_V6\").hosts()))")} -else - export PROVISIONING_HOST_EXTERNAL_IP=${PROVISIONING_HOST_EXTERNAL_IP:-$(python -c "import ipaddress; print(next(ipaddress.ip_network(u\"$EXTERNAL_SUBNET_V4\").hosts()))")} -fi -export MIRROR_IP=${MIRROR_IP:-$PROVISIONING_HOST_IP} - # The dev-scripts working directory export WORKING_DIR=${WORKING_DIR:-"/opt/dev-scripts"} OCP_DIR=${OCP_DIR:-ocp/${CLUSTER_NAME}} +# The DNS name for the registry that this cluster should use. +export LOCAL_REGISTRY_DNS_NAME=${LOCAL_REGISTRY_DNS_NAME:-"virthost.${CLUSTER_NAME}.${BASE_DOMAIN}"} +# All DNS names for the registry, to be included in the certificate. +export ALL_REGISTRY_DNS_NAMES=${ALL_REGISTRY_DNS_NAMES:-${LOCAL_REGISTRY_DNS_NAME}} + # variables for local registry configuration export LOCAL_REGISTRY_PORT=${LOCAL_REGISTRY_PORT:-"5000"} export REGISTRY_USER=${REGISTRY_USER:-ocp-user} @@ -239,6 +121,10 @@ else export BMC_DRIVER=${BMC_DRIVER:-mixed} fi +if [[ "$PROVISIONING_NETWORK_PROFILE" == "Disabled" ]]; then + export BMC_DRIVER="redfish-virtualmedia" +fi + # Both utils.sh and 04_setup_ironic.sh use this log file, so set the # name one time. Users should not override this. export MIRROR_LOG_FILE=${REGISTRY_DIR}/${CLUSTER_NAME}-image_mirror-${OPENSHIFT_RELEASE_TAG}.log diff --git a/metal3-templater.go b/metal3-templater.go index 2a836901c..4d94d4b8d 100644 --- a/metal3-templater.go +++ b/metal3-templater.go @@ -7,6 +7,7 @@ import ( "net" "net/url" "os" + "strings" "text/template" ) @@ -27,8 +28,8 @@ type templater struct { func main() { var templateData templater - if len(os.Args) < 5 { - fmt.Printf("usage: TEMPLATE_FILE INTERFACE NETWORK IMAGE_URL\n") + if len(os.Args) < 7 { + fmt.Printf("usage: TEMPLATE_FILE INTERFACE NETWORK BOOTSTRAP_IP CLUSTER_IP IMAGE_URL\n") os.Exit(1) } @@ -52,22 +53,22 @@ func main() { templateData.ProvisioningDHCPRange = fmt.Sprintf("%s,%s", startIP, endIP) // BootstrapIP - bootstrapIP, _ := cidr.Host(&ipnet.IPNet, 2) - templateData.BootstrapIronicURL = fmt.Sprintf("http://%s", net.JoinHostPort(bootstrapIP.String(), "6385")) - templateData.BootstrapInspectorURL = fmt.Sprintf("http://%s", net.JoinHostPort(bootstrapIP.String(), "5050")) + bootstrapIP := os.Args[5] + templateData.BootstrapIronicURL = fmt.Sprintf("http://%s", net.JoinHostPort(bootstrapIP, "6385")) + templateData.BootstrapInspectorURL = fmt.Sprintf("http://%s", net.JoinHostPort(bootstrapIP, "5050")) // ProvisioningIP - ip, _ := cidr.Host(&ipnet.IPNet, 3) + ip := os.Args[6] size, _ := ipnet.IPNet.Mask.Size() templateData.ProvisioningIP = fmt.Sprintf("%s/%d", ip, size) - templateData.ClusterIronicURL = fmt.Sprintf("http://%s", net.JoinHostPort(ip.String(), "6385")) - templateData.ClusterInspectorURL = fmt.Sprintf("http://%s", net.JoinHostPort(ip.String(), "5050")) + templateData.ClusterIronicURL = fmt.Sprintf("http://%s", net.JoinHostPort(ip, "6385")) + templateData.ClusterInspectorURL = fmt.Sprintf("http://%s", net.JoinHostPort(ip, "5050")) // URL Host - if ip.To4() == nil { + if strings.Contains(ip, ":") { templateData.ClusterProvisioningURLHost = fmt.Sprintf("[%s]", ip) } else { - templateData.ClusterProvisioningURLHost = ip.String() + templateData.ClusterProvisioningURLHost = ip } t, err := template.New(templateFile).ParseFiles(templateFile) diff --git a/network.sh b/network.sh new file mode 100644 index 000000000..8705eaef4 --- /dev/null +++ b/network.sh @@ -0,0 +1,143 @@ +#!/bin/bash + +function nth_ip() { + network=$1 + idx=$2 + + python -c "from ansible.plugins.filter import ipaddr; print(ipaddr.nthhost('"$network"', $idx))" +} + + +export IP_STACK=${IP_STACK:-"v6"} + +EXTERNAL_SUBNET=${EXTERNAL_SUBNET:-""} +EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-""} +EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-""} +if [[ -n "${EXTERNAL_SUBNET}" ]] && [[ -z "${EXTERNAL_SUBNET_V4}" ]] && [[ -z "${EXTERNAL_SUBNET_V6}" ]]; then + # Backwards compatibility. If the old var was specified, and neither of the new + # vars are set, automatically adapt it to the right new var. + if [[ "${EXTERNAL_SUBNET}" =~ .*:.* ]]; then + export EXTERNAL_SUBNET_V6="${EXTERNAL_SUBNET}" + else + export EXTERNAL_SUBNET_V4="${EXTERNAL_SUBNET}" + fi +elif [[ -n "${EXTERNAL_SUBNET}" ]]; then + echo "EXTERNAL_SUBNET has been removed in favor of EXTERNAL_SUBNET_V4 and EXTERNAL_NETWORK_V6." + echo "Please update your configuration to drop the use of EXTERNAL_SUBNET." + exit 1 +fi + +SERVICE_SUBNET=${SERVICE_SUBNET:-""} +SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-""} +SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-""} +if [[ -n "${SERVICE_SUBNET}" ]] && [[ -z "${SERVICE_SUBNET_V4}" ]] && [[ -z "${SERVICE_SUBNET_V6}" ]]; then + # Backwards compatibility. If the old var was specified, and neither of the new + # vars are set, automatically adapt it to the right new var. + if [[ "${SERVICE_SUBNET}" =~ .*:.* ]]; then + export SERVICE_SUBNET_V6="${SERVICE_SUBNET}" + else + export SERVICE_SUBNET_V4="${SERVICE_SUBNET}" + fi +elif [[ -n "${SERVICE_SUBNET}" ]]; then + echo "SERVICE_SUBNET has been removed in favor of SERVICE_SUBNET_V4 and SERVICE_SUBNET_V6." + echo "Please update your configuration to drop the use of SERVICE_SUBNET." + exit 1 +fi + +CLUSTER_SUBNET=${CLUSTER_SUBNET:-""} +CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-""} +CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-""} +CLUSTER_HOST_PREFIX=${CLUSTER_HOST_PREFIX:-""} +CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-""} +CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-""} +if [[ -n "${CLUSTER_SUBNET}" ]] && [[ -z "${CLUSTER_SUBNET_V4}" ]] && [[ -z "${CLUSTER_SUBNET_V6}" ]]; then + # Backwards compatibility. If the old var was specified, and neither of the new + # vars are set, automatically adapt it to the right new var. + if [[ "${CLUSTER_SUBNET}" =~ .*:.* ]]; then + export CLUSTER_SUBNET_V6="${CLUSTER_SUBNET}" + export CLUSTER_HOST_PREFIX_V6="${CLUSTER_HOST_PREFIX_V6:-${CLUSTER_HOST_PREFIX}}" + else + export CLUSTER_SUBNET_V4="${CLUSTER_SUBNET}" + export CLUSTER_HOST_PREFIX_V4="${CLUSTER_HOST_PREFIX_V4:-${CLUSTER_HOST_PREFIX}}" + fi +elif [[ -n "${CLUSTER_SUBNET}" ]]; then + echo "CLUSTER_SUBNET has been removed in favor of CLUSTER_SUBNET_V4 and CLUSTER_SUBNET_V6." + echo "Please update your configuration to drop the use of CLUSTER_SUBNET." + exit 1 +fi + + +if [[ "$IP_STACK" = "v4" ]] +then + export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"172.22.0.0/24"} + export EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-"192.168.111.0/24"} + export EXTERNAL_SUBNET_V6="" + export CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-"10.128.0.0/14"} + export CLUSTER_SUBNET_V6="" + export CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-"23"} + export CLUSTER_HOST_PREFIX_V6="" + export SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-"172.30.0.0/16"} + export SERVICE_SUBNET_V6="" + export NETWORK_TYPE=${NETWORK_TYPE:-"OpenShiftSDN"} +elif [[ "$IP_STACK" = "v6" ]]; then + export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"fd00:1101::0/64"} + export EXTERNAL_SUBNET_V4="" + export EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-"fd2e:6f44:5dd8:c956::/120"} + export CLUSTER_SUBNET_V4="" + export CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-"fd01::/48"} + export CLUSTER_HOST_PREFIX_V4="" + export CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-"64"} + export SERVICE_SUBNET_V4="" + export SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-"fd02::/112"} + export NETWORK_TYPE=${NETWORK_TYPE:-"OVNKubernetes"} + export MIRROR_IMAGES=true +elif [[ "$IP_STACK" = "v4v6" ]]; then + export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"fd00:1101::0/64"} + export EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-"192.168.111.0/24"} + export EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-"fd2e:6f44:5dd8:c956::/120"} + export CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-"10.128.0.0/14"} + export CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-"fd01::/48"} + export CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-"23"} + export CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-"64"} + export SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-"172.30.0.0/16"} + export SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-"fd02::/112"} + export NETWORK_TYPE=${NETWORK_TYPE:-"OVNKubernetes"} + export MIRROR_IMAGES=true +else + echo "Unexpected setting for IP_STACK: '${IP_STACK}'" + exit 1 +fi + +if [[ "${IP_STACK}" = "v6" ]]; then + export DNS_VIP=${DNS_VIP:-$(nth_ip $EXTERNAL_SUBNET_V6 2)} +else + export DNS_VIP=${DNS_VIP:-$(nth_ip $EXTERNAL_SUBNET_V4 2)} +fi + +# Provisioning network information +export CLUSTER_PRO_IF=${CLUSTER_PRO_IF:-enp1s0} +export PROVISIONING_NETMASK=${PROVISIONING_NETMASK:-$(ipcalc --netmask $PROVISIONING_NETWORK | cut -d= -f2)} + +export PROVISIONING_HOST_IP=${PROVISIONING_HOST_IP:-$(nth_ip $PROVISIONING_NETWORK 1)} + +if [[ "${IP_STACK}" = "v6" ]]; then + export PROVISIONING_HOST_EXTERNAL_IP=${PROVISIONING_HOST_EXTERNAL_IP:-$(nth_ip $EXTERNAL_SUBNET_V6 1)} +else + export PROVISIONING_HOST_EXTERNAL_IP=${PROVISIONING_HOST_EXTERNAL_IP:-$(nth_ip $EXTERNAL_SUBNET_V4 1)} +fi +export MIRROR_IP=${MIRROR_IP:-$PROVISIONING_HOST_EXTERNAL_IP} + +if [[ "$PROVISIONING_NETWORK_PROFILE" == "Disabled" ]]; then + if [[ "${IP_STACK}" = "v6" ]]; then + export PROVISIONING_IP_SUBNET=$EXTERNAL_SUBNET_V6 + else + export PROVISIONING_IP_SUBNET=$EXTERNAL_SUBNET_V4 + fi + + # When the provisioning network is disabled, we use IP's on the external network for the provisioning IP's: + export BOOTSTRAP_PROVISIONING_IP=${BOOTSTRAP_PROVISIONING_IP:-$(nth_ip $PROVISIONING_IP_SUBNET 7)} + export CLUSTER_PROVISIONING_IP=${CLUSTER_PROVISIONING_IP:-$(nth_ip $PROVISIONING_IP_SUBNET 8)} +else + export BOOTSTRAP_PROVISIONING_IP=${BOOTSTRAP_PROVISIONING_IP:-$(nth_ip $PROVISIONING_NETWORK 2)} + export CLUSTER_PROVISIONING_IP=${CLUSTER_PROVISIONING_IP:-$(nth_ip $PROVISIONING_NETWORK 3)} +fi diff --git a/ocp_install_env.sh b/ocp_install_env.sh index 2f9b272ed..96ba23108 100644 --- a/ocp_install_env.sh +++ b/ocp_install_env.sh @@ -75,10 +75,20 @@ function build_installer() { cp "$OPENSHIFT_INSTALL_PATH/data/data/rhcos.json" "$OCP_DIR" } -# FIXME(stbenjam): This is not available in 4.3 (yet) function baremetal_network_configuration() { - if [[ "$OPENSHIFT_VERSION" != "4.3" ]]; then + if [[ "$OPENSHIFT_VERSION" == "4.3" ]]; then + return + fi + + if [[ "$PROVISIONING_NETWORK_PROFILE" == "Disabled" ]]; then cat < ${OCP_DIR}/deploy/metal3-config.yaml + go run metal3-templater.go metal3-config.yaml.template "$CLUSTER_PRO_IF" "$PROVISIONING_NETWORK" "$MACHINE_OS_IMAGE_URL" "$BOOTSTRAP_PROVISIONING_IP" "$CLUSTER_PROVISIONING_IP" > ${OCP_DIR}/deploy/metal3-config.yaml cp ${OCP_DIR}/deploy/metal3-config.yaml assets/generated/98_metal3-config.yaml else echo "OpenShift Version is > 4.3; skipping config map" fi # clouds.yaml - go run metal3-templater.go clouds.yaml.template "$CLUSTER_PRO_IF" "$PROVISIONING_NETWORK" "$MACHINE_OS_IMAGE_URL" > clouds.yaml + go run metal3-templater.go clouds.yaml.template "$CLUSTER_PRO_IF" "$PROVISIONING_NETWORK" "$MACHINE_OS_IMAGE_URL" "$BOOTSTRAP_PROVISIONING_IP" "$CLUSTER_PROVISIONING_IP" > clouds.yaml # For compatibility with metal3-dev-env openstackclient.sh # which mounts a config dir into the ironic-client container mkdir -p _clouds_yaml @@ -389,7 +389,6 @@ function swtich_to_internal_dns() { fi } - _tmpfiles= function removetmp(){ [ -n "$_tmpfiles" ] && rm -rf $_tmpfiles || true diff --git a/vm_setup_vars.yml b/vm_setup_vars.yml index 25aa4a173..5726d6d8c 100644 --- a/vm_setup_vars.yml +++ b/vm_setup_vars.yml @@ -37,10 +37,12 @@ dns_extrahosts: hostnames: - "virthost" -networks: - - name: "{{ provisioning_network_name }}" - bridge: "{{ provisioning_network_name }}" +provisioning_network: + - name: "{{ provisioning_network_name }}" + bridge: "{{ provisioning_network_name }}" forward_mode: bridge + +external_network: - name: "{{ baremetal_network_name }}" bridge: "{{ baremetal_network_name }}" forward_mode: "{{ 'bridge' if lookup('env', 'MANAGE_BR_BRIDGE') == 'n' else 'nat' }}" @@ -63,3 +65,5 @@ networks: forwarders: - domain: "apps.{{ cluster_domain }}" addr: "127.0.0.1" + +networks: "{{ (provisioning_network if lookup('env', 'PROVISIONING_NETWORK_PROFILE') != 'Disabled' else []) + external_network }}"