tripleo-quickstart-extras/roles/overcloud-prep-network/templates/overcloud-prep-network.sh.j2

51 lines
1.2 KiB
Django/Jinja

#!/bin/bash
set -eux
### --start_docs
## Prepare network for deploying the overcloud
## ==================================================
## Prepare Your Environment
## ------------------------
## * Source in the undercloud credentials.
## ::
source {{ working_dir }}/stackrc
{% if network_isolation == true and ipv6 == false %}
## Setup Networking
## ----------------
## * Enable NAT for "external" network.
## ::
RULE="-s {{undercloud_external_network_cidr}} ! -d {{undercloud_external_network_cidr}} -j MASQUERADE"
if ! sudo iptables -t nat -C BOOTSTACK_MASQ $RULE; then
sudo iptables -t nat -A BOOTSTACK_MASQ $RULE
sudo sh -c 'iptables-save > /etc/sysconfig/iptables'
fi
{% for name, network in (undercloud_networks|default({})).items() if name == 'external' %}
sudo bash -c 'cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-vlan{{ network.tag }}
DEVICE=vlan{{ network.tag }}
ONBOOT=yes
DEVICETYPE={{ network.device_type }}
TYPE={{ network.type }}
BOOTPROTO=static
IPADDR={{ network.address }}
NETMASK={{ network.netmask }}
OVS_BRIDGE={{ network.ovs_bridge }}
OVS_OPTIONS={{ network.ovs_options }}
EOF'
sudo ifup ifcfg-vlan{{ network.tag }}
{% endfor %}
{%endif%}
### --stop_docs