diff --git a/devsetup/Makefile b/devsetup/Makefile index 1e7472a..b4a4593 100644 --- a/devsetup/Makefile +++ b/devsetup/Makefile @@ -6,7 +6,26 @@ CRC_DEFAULT_NETWORK_IP ?= 192.168.122.10 EDPM_COMPUTE_SUFFIX ?= 0 # EDPM_COMPUTE_ADDITIONAL_NETWORKS: JSON string - list of additional networks # Examples: -# EDPM_COMPUTE_ADDITIONAL_NETWORKS='[{"type": "network", "name": "crc-bmaas"}]' +# cat << EOF +# [ +# { +# "type": "network", +# "name": "crc-bmaas", +# "standalone_config": { +# "type": "linux_bridge", +# "name": "baremetal", +# "mtu": 1500, +# "ip_subnet": "172.20.1.0/24", +# "allocation_pools": [ +# { +# "start": "172.20.1.4", +# "end": "172.20.1.250" +# } +# ] +# } +# } +# ] +# EOF # EDPM_COMPUTE_ADDITIONAL_NETWORKS=$(jq -c addtional_nets.json) EDPM_COMPUTE_ADDITIONAL_NETWORKS ?= '[]' EDPM_TOTAL_NODES ?= 1 @@ -38,6 +57,8 @@ BM_NODE_COUNT ?=1 BM_ROOT_PASSWORD_SECRET ?= BMH_NAMESPACE ?=openstack +STANDALONE_COMPUTE_DRIVER ?= libvirt + CLEANUP_DIR_CMD ?= rm -Rf define vars @@ -137,7 +158,7 @@ edpm_compute: ## Create EDPM compute VM $(eval $(call vars)) scripts/gen-ansibleee-ssh-key.sh if [ ${EDPM_TOTAL_NODES} -eq 1 ]; then \ - scripts/gen-edpm-compute-node.sh ${EDPM_COMPUTE_SUFFIX} '${EDPM_COMPUTE_ADDITIONAL_NETWORKS}' ; \ + scripts/gen-edpm-compute-node.sh ${EDPM_COMPUTE_SUFFIX} '${EDPM_COMPUTE_ADDITIONAL_NETWORKS}'; \ else \ for INDEX in $(shell seq 0 $$((${EDPM_TOTAL_NODES} -1))) ; do \ scripts/gen-edpm-compute-node.sh $$INDEX '${EDPM_COMPUTE_ADDITIONAL_NETWORKS}' ; \ @@ -177,7 +198,7 @@ standalone: export STANDALONE=true standalone: export INTERFACE_MTU=${NETWORK_MTU} standalone: edpm_compute ## Create standalone VM $(eval $(call vars)) - scripts/standalone.sh ${EDPM_COMPUTE_SUFFIX} + scripts/standalone.sh ${EDPM_COMPUTE_SUFFIX} ${STANDALONE_COMPUTE_DRIVER} '${EDPM_COMPUTE_ADDITIONAL_NETWORKS}' .PHONY: standalone_cleanup standalone_cleanup: export STANDALONE=true diff --git a/devsetup/scripts/common.sh b/devsetup/scripts/common.sh new file mode 100644 index 0000000..08e9310 --- /dev/null +++ b/devsetup/scripts/common.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Copyright 2023 Red Hat Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +#--- +## Jinja2 template render function +# Parameter #1 is the Jinja2 template file +# Parameter #2 is the YAML/JSON file with Jinja2 variable definitions +#--- +function jinja2_render { + local j2_template_file + local j2_vars + j2_template_file=$1 + j2_vars_file=$2 + + /usr/bin/python3 -c " +import yaml +import jinja2 + +with open('$j2_vars_file', 'r') as f: + vars = yaml.safe_load(f.read()) + +with open('$j2_template_file', 'r') as f: + template = f.read() + +j2_template = jinja2.Template(template) + +print(j2_template.render(**vars)) +" +} diff --git a/devsetup/scripts/standalone.sh b/devsetup/scripts/standalone.sh index 1d7c616..9583bd4 100755 --- a/devsetup/scripts/standalone.sh +++ b/devsetup/scripts/standalone.sh @@ -14,9 +14,15 @@ # License for the specific language governing permissions and limitations # under the License. set -ex + +MY_TMP_DIR="$(mktemp -d)" +trap 'rm -rf -- "$MY_TMP_DIR"' EXIT + export VIRSH_DEFAULT_CONNECT_URI=qemu:///system SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" EDPM_COMPUTE_SUFFIX=${1:-"0"} +COMPUTE_DRIVER=${2:-"libvirt"} +EDPM_COMPUTE_ADDITIONAL_NETWORKS=${3:-'[]'} EDPM_COMPUTE_NAME=${EDPM_COMPUTE_NAME:-"edpm-compute-${EDPM_COMPUTE_SUFFIX}"} EDPM_COMPUTE_NETWORK=${EDPM_COMPUTE_NETWORK:-default} EDPM_COMPUTE_NETWORK_IP=$(virsh net-dumpxml ${EDPM_COMPUTE_NETWORK} | xmllint - --xpath 'string(/network/ip/@address)') @@ -26,16 +32,18 @@ GATEWAY=${GATEWAY:-"${EDPM_COMPUTE_NETWORK_IP}"} OUTPUT_DIR=${OUTPUT_DIR:-"${SCRIPTPATH}/../../out/edpm/"} SSH_KEY_FILE=${SSH_KEY_FILE:-"${OUTPUT_DIR}/ansibleee-ssh-key-id_rsa"} SSH_OPT="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $SSH_KEY_FILE" -REPO_SETUP_CMDS=${REPO_SETUP_CMDS:-"/tmp/standalone_repos"} -CMDS_FILE=${CMDS_FILE:-"/tmp/standalone_cmds"} +REPO_SETUP_CMDS=${REPO_SETUP_CMDS:-"${MY_TMP_DIR}/standalone_repos"} +CMDS_FILE=${CMDS_FILE:-"${MY_TMP_DIR}/standalone_cmds"} SKIP_TRIPLEO_REPOS=${SKIP_TRIPLEO_REPOS:="false"} -CLEANUP_DIR_CMD=${CLEANUP_DIR_CMD:-"rm -Rf"} if [[ ! -f $SSH_KEY_FILE ]]; then echo "$SSH_KEY_FILE is missing" exit 1 fi +source ${SCRIPTPATH}/common.sh + + # Clock synchronization is important for both Ceph and OpenStack services, so both ceph deploy and tripleo deploy commands will make use of chrony to ensure the clock is properly in sync. # We'll use the NTP_SERVER environmental variable to define the NTP server to use. # If we are running alls these commands in a system inside the Red Hat network we should use the clock.corp.redhat.com server: @@ -44,7 +52,7 @@ fi # export NTP_SERVER=pool.ntp.org if [[ ! -f $REPO_SETUP_CMDS ]]; then -cat < $REPO_SETUP_CMDS + cat < $REPO_SETUP_CMDS set -ex sudo dnf remove -y epel-release sudo dnf update -y @@ -65,7 +73,8 @@ else HOST_PRIMARY_RESOLV_CONF_ENTRY=${HOST_PRIMARY_RESOLV_CONF_ENTRY:-$GATEWAY} fi -cat < $CMDS_FILE +if [[ ! -f $CMDS_FILE ]]; then + cat < $CMDS_FILE sudo dnf install -y podman python3-tripleoclient util-linux lvm2 cephadm # Pin Podman to work around a Podman regression where env variables @@ -81,6 +90,7 @@ export INTERFACE_MTU=${INTERFACE_MTU:-1500} export NTP_SERVER=${NTP_SERVER:-"clock.corp.redhat.com"} export EDPM_COMPUTE_CEPH_ENABLED=${EDPM_COMPUTE_CEPH_ENABLED:-true} export CEPH_ARGS="${CEPH_ARGS:--e \$HOME/deployed_ceph.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/cephadm/cephadm-rbd-only.yaml}" +export COMPUTE_DRIVER=${COMPUTE_DRIVER:-"libvirt"} export IP=${IP} export GATEWAY=${GATEWAY} @@ -94,22 +104,67 @@ else sed -i 's|quay.io/tripleowallaby$|quay.io/tripleowallabycentos9|' \$HOME/containers-prepare-parameters.yaml fi -/tmp/network.sh +# Use os-net-config to add VLAN interfaces which connect edpm-compute-0 to the isolated networks configured by install_yamls. +sudo mkdir -p /etc/os-net-config + +cat << __EOF__ | sudo tee /etc/cloud/cloud.cfg.d/99-edpm-disable-network-config.cfg +network: + config: disabled +__EOF__ + +sudo systemctl enable network +sudo cp /tmp/net_config.yaml /etc/os-net-config/config.yaml +sudo os-net-config -c /etc/os-net-config/config.yaml + + +#--- +## Copying files +#--- +# Use /tmp/net_config.yaml as the network config template for Standalone +# so that tripleo deploy don't change the config applied above. +sudo cp /tmp/net_config.yaml \$HOME/standalone_net_config.j2 +sudo cp /tmp/network_data.yaml \$HOME/network_data.yaml +sudo cp /tmp/deployed_network.yaml \$HOME/deployed_network.yaml +sudo cp /tmp/Standalone.yaml \$HOME/Standalone.yaml +#---- + [[ "\$EDPM_COMPUTE_CEPH_ENABLED" == "true" ]] && /tmp/ceph.sh /tmp/openstack.sh EOF +fi while [[ $(ssh -o BatchMode=yes -o ConnectTimeout=5 $SSH_OPT root@$IP echo ok) != "ok" ]]; do true done +# Render Jinja2 files +J2_VARS_FILE=$(mktemp --suffix=".yaml" --tmpdir="${MY_TMP_DIR}") +cat << EOF > ${J2_VARS_FILE} +--- +additional_networks: ${EDPM_COMPUTE_ADDITIONAL_NETWORKS} +ctlplane_cidr: 24 +ctlplane_ip: ${IP} +ctlplane_subnet: ${IP%.*}.0/24 +ctlplane_vip: ${IP%.*}.99 +ip_address_suffix: ${IP_ADRESS_SUFFIX} +interface_mtu: ${INTERFACE_MTU:-1500} +gateway_ip: ${GATEWAY} +dns_server: ${HOST_PRIMARY_RESOLV_CONF_ENTRY} +compute_driver: ${COMPUTE_DRIVER} +EOF + +jinja2_render standalone/network_data.j2 "${J2_VARS_FILE}" > ${MY_TMP_DIR}/network_data.yaml +jinja2_render standalone/deployed_network.j2 "${J2_VARS_FILE}" > ${MY_TMP_DIR}/deployed_network.yaml +jinja2_render standalone/net_config.j2 "${J2_VARS_FILE}" > ${MY_TMP_DIR}/net_config.yaml +jinja2_render standalone/role.j2 "${J2_VARS_FILE}" > ${MY_TMP_DIR}/Standalone.yaml + # Copying files scp $SSH_OPT $REPO_SETUP_CMDS root@$IP:/tmp/repo-setup.sh scp $SSH_OPT $CMDS_FILE root@$IP:/tmp/standalone-deploy.sh -scp $SSH_OPT standalone/standalone.j2 root@$IP:/tmp/standalone.j2 -scp $SSH_OPT standalone/network_data.yaml root@$IP:/tmp/network_data.yaml -scp $SSH_OPT standalone/deployed_network.yaml root@$IP:/tmp/deployed_network.yaml -scp $SSH_OPT standalone/network.sh root@$IP:/tmp/network.sh +scp $SSH_OPT ${MY_TMP_DIR}/net_config.yaml root@$IP:/tmp/net_config.yaml +scp $SSH_OPT ${MY_TMP_DIR}/network_data.yaml root@$IP:/tmp/network_data.yaml +scp $SSH_OPT ${MY_TMP_DIR}/deployed_network.yaml root@$IP:/tmp/deployed_network.yaml +scp $SSH_OPT ${MY_TMP_DIR}/Standalone.yaml root@$IP:/tmp/Standalone.yaml scp $SSH_OPT standalone/ceph.sh root@$IP:/tmp/ceph.sh scp $SSH_OPT standalone/openstack.sh root@$IP:/tmp/openstack.sh [ -f $HOME/.ssh/id_ecdsa.pub ] || \ @@ -128,6 +183,3 @@ if [[ -z ${SKIP_TRIPLEO_REPOS} || ${SKIP_TRIPLEO_REPOS} == "false" ]]; then fi ssh $SSH_OPT root@$IP "bash /tmp/standalone-deploy.sh" ssh $SSH_OPT root@$IP "rm -f /tmp/standalone-deploy.sh" - -${CLEANUP_DIR_CMD} $CMDS_FILE -${CLEANUP_DIR_CMD} $REPO_SETUP_CMDS diff --git a/devsetup/standalone/deployed_network.yaml b/devsetup/standalone/deployed_network.j2 similarity index 62% rename from devsetup/standalone/deployed_network.yaml rename to devsetup/standalone/deployed_network.j2 index 48483e8..f3fa02b 100644 --- a/devsetup/standalone/deployed_network.yaml +++ b/devsetup/standalone/deployed_network.j2 @@ -11,36 +11,43 @@ parameter_defaults: NodePortMap: standalone: ctlplane: - ip_address: CTLPLANE_IP - ip_subnet: CTLPLANE_SUBNET.1/24 - ip_address_uri: CTLPLANE_IP + ip_address: {{ ctlplane_ip }} + ip_subnet: {{ ctlplane_subnet }} + ip_address_uri: {{ ctlplane_ip }} storage: - ip_address: 172.18.0.100 + ip_address: 172.18.0.{{ ip_address_suffix }} ip_subnet: 172.18.0.1/24 - ip_address_uri: 172.18.0.100 + ip_address_uri: 172.18.0.{{ ip_address_suffix }} storage_mgmt: - ip_address: 172.20.0.100 + ip_address: 172.20.0.{{ ip_address_suffix }} ip_subnet: 172.20.0.1/24 - ip_address_uri: 172.20.0.100 + ip_address_uri: 172.20.0.{{ ip_address_suffix }} internal_api: - ip_address: 172.17.0.100 + ip_address: 172.17.0.{{ ip_address_suffix }} ip_subnet: 172.17.0.1/24 - ip_address_uri: 172.17.0.100 + ip_address_uri: 172.17.0.{{ ip_address_suffix }} tenant: - ip_address: 172.19.0.100 + ip_address: 172.19.0.{{ ip_address_suffix }} ip_subnet: 172.19.0.1/24 - ip_address_uri: 172.19.0.100 + ip_address_uri: 172.19.0.{{ ip_address_suffix }} external: - ip_address: 172.21.0.100 + ip_address: 172.21.0.{{ ip_address_suffix }} ip_subnet: 172.21.0.1/24 - ip_address_uri: 172.21.0.100 + ip_address_uri: 172.21.0.{{ ip_address_suffix }} + {%- for network in additional_networks if network.standalone_config %} + {%- set net = network.standalone_config %} + {{ net.name.lower() }}: + ip_address: {{ net.ip_subnet.split('/')[0].split('.')[:-1] | join('.') + '.' + ip_address_suffix | string }} + ip_subnet: {{ net.ip_subnet }} + ip_address_uri: {{ net.ip_subnet.split('/')[0].split('.')[:-1] | join('.') + '.' + ip_address_suffix | string }} + {%- endfor %} ControlPlaneVipData: fixed_ips: - - ip_address: CTLPLANE_VIP + - ip_address: {{ ctlplane_vip }} name: control_virtual_ip network: tags: - - CTLPLANE_SUBNET.0/24 + - {{ ctlplane_subnet }} subnets: - ip_version: 4 VipPortMap: @@ -64,6 +71,13 @@ parameter_defaults: ip_address: 172.21.0.2 ip_address_uri: 172.21.0.2 ip_subnet: 172.21.0.2/24 +{%- for network in additional_networks if network.standalone_config and network.standalone_config.vip %} +{%- set net = network.standalone_config %} + {{ net.name.lower() }}: + ip_address: {{ net.ip_subnet.split('/')[0].split('.')[:-1] | join('.') + '.2' }} + ip_address_uri: {{ net.ip_subnet.split('/')[0].split('.')[:-1] | join('.') + '.2' }} + ip_subnet: {{ net.ip_subnet }} +{%- endfor %} DeployedNetworkEnvironment: net_cidr_map: storage: @@ -76,12 +90,21 @@ parameter_defaults: - 172.19.0.0/24 external: - 172.21.0.0/24 +{%- for network in additional_networks if network.standalone_config %} +{%- set net = network.standalone_config %} + {{ net.name.lower() }}: + - {{ net.ip_subnet }} +{%- endfor %} net_ip_version_map: storage: 4 storage_mgmt: 4 internal_api: 4 tenant: 4 external: 4 +{%- for network in additional_networks if network.standalone_config %} +{%- set net = network.standalone_config %} + {{ net.name.lower() }}: 4 +{%- endfor %} net_attributes_map: storage: network: @@ -173,3 +196,23 @@ parameter_defaults: host_routes: [] ip_version: 4 name: external_subnet +{%- for network in additional_networks if network.standalone_config %} +{%- set net = network.standalone_config %} + {{ net.name.lower() }}: + network: + dns_domain: {{ net.name.lower() }}.mydomain.tld. + mtu: {{ net.mtu | default(1500) }} + name: {{ net.name.lower() }} + tags: + - tripleo_network_name={{ net.name }} + - tripleo_net_idx=0 + - tripleo_vip={{ net.vip | string | lower }} + subnets: + {{ net.name.lower() }}_subnet: + cidr: {{ net.ip_subnet }} + dns_nameservers: {{ net.dns_nameservers | default([]) }} + gateway_ip: {{ net.gateway_ip | default('null') }} + host_routes: {{ net.host_routes | default([]) }} + ip_version: 4 + name: {{ net.name.lower() }}_subnet +{%- endfor %} diff --git a/devsetup/standalone/net_config.j2 b/devsetup/standalone/net_config.j2 new file mode 100644 index 0000000..3550afb --- /dev/null +++ b/devsetup/standalone/net_config.j2 @@ -0,0 +1,78 @@ +network_config: +- type: ovs_bridge + name: br-ctlplane + mtu: {{ interface_mtu }} + use_dhcp: false + dns_servers: + {%- if dns_server %} + - {{ dns_server }} + {%- endif %} + - {{ gateway_ip }} + domain: [] + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_cidr }} + - ip_netmask: {{ ctlplane_ip }}/32 + - ip_netmask: {{ ctlplane_vip }}/32 + routes: + - ip_netmask: 0.0.0.0/0 + next_hop: {{ gateway_ip }} + members: + - type: interface + name: nic1 + mtu: {{ interface_mtu }} + # force the MAC address of the bridge to this interface + primary: true + # external + - type: vlan + mtu: {{ interface_mtu }} + vlan_id: 44 + addresses: + - ip_netmask: 172.21.0.{{ ip_address_suffix }}/24 + - ip_netmask: 172.21.0.2/32 + routes: [] + # internal + - type: vlan + mtu: {{ interface_mtu }} + vlan_id: 20 + addresses: + - ip_netmask: 172.17.0.{{ ip_address_suffix }}/24 + - ip_netmask: 172.17.0.2/32 + routes: [] + # storage + - type: vlan + mtu: {{ interface_mtu }} + vlan_id: 21 + addresses: + - ip_netmask: 172.18.0.{{ ip_address_suffix }}/24 + - ip_netmask: 172.18.0.2/32 + routes: [] + # storage_mgmt + - type: vlan + mtu: {{ interface_mtu }} + vlan_id: 23 + addresses: + - ip_netmask: 172.20.0.{{ ip_address_suffix }}/24 + - ip_netmask: 172.20.0.2/32 + routes: [] + # tenant + - type: vlan + mtu: {{ interface_mtu }} + vlan_id: 22 + addresses: + - ip_netmask: 172.19.0.{{ ip_address_suffix }}/24 + routes: [] +{%- for network in additional_networks if network.standalone_config %} +{%- set net = network.standalone_config %} +- type: {{ net.type }} + name: br-{{ net.name.lower() }} + use_dhcp: false + addresses: + - ip_netmask: {{ net.ip_subnet.split('/')[0].split('.')[:-1] | join('.') + '.' + ip_address_suffix | string }}/{{ net.ip_subnet.split('/')[1] }} + routes: {{ net.host_routes | default([]) }} + members: + - type: interface + name: nic{{loop.index + 1}} + mtu: {{ net.mtu | default(1500) }} + # force the MAC address of the bridge to this interface + primary: true +{%- endfor %} diff --git a/devsetup/standalone/network.sh b/devsetup/standalone/network.sh deleted file mode 100755 index eaaec90..0000000 --- a/devsetup/standalone/network.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -# -# Copyright 2023 Red Hat Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -set -ex - -# Use os-net-config to add VLAN interfaces which connect edpm-compute-0 to the isolated networks configured by install_yamls. - -export GATEWAY=${GATEWAY:-192.168.122.1} -export CTLPLANE_IP=${IP:-192.168.122.100} -export INTERNAL_IP=$(sed -e 's/192.168.12[0-9]/172.17.0/' <<<"$CTLPLANE_IP") -export STORAGE_IP=$(sed -e 's/192.168.12[0-9]/172.18.0/' <<<"$CTLPLANE_IP") -export STORAGE_MGMT_IP=$(sed -e 's/192.168.12[0-9]/172.20.0/' <<<"$CTLPLANE_IP") -export TENANT_IP=$(sed -e 's/192.168.12[0-9]/172.19.0/' <<<"$CTLPLANE_IP") -export EXTERNAL_IP=$(sed -e 's/192.168.12[0-9]/172.21.0/' <<<"$CTLPLANE_IP") -export INTERFACE_MTU=${INTERFACE_MTU:-1500} - -sudo mkdir -p /etc/os-net-config - -cat << EOF | sudo tee /etc/os-net-config/config.yaml -network_config: -- type: ovs_bridge - name: br-ctlplane - mtu: ${INTERFACE_MTU} - use_dhcp: false - dns_servers: - - $HOST_PRIMARY_RESOLV_CONF_ENTRY - - $GATEWAY - domain: [] - addresses: - - ip_netmask: $CTLPLANE_IP/24 - routes: - - ip_netmask: 0.0.0.0/0 - next_hop: $GATEWAY - members: - - type: interface - name: nic1 - mtu: ${INTERFACE_MTU} - # force the MAC address of the bridge to this interface - primary: true - - # external - - type: vlan - mtu: ${INTERFACE_MTU} - vlan_id: 44 - addresses: - - ip_netmask: $EXTERNAL_IP/24 - routes: [] - - # internal - - type: vlan - mtu: ${INTERFACE_MTU} - vlan_id: 20 - addresses: - - ip_netmask: $INTERNAL_IP/24 - routes: [] - - # storage - - type: vlan - mtu: ${INTERFACE_MTU} - vlan_id: 21 - addresses: - - ip_netmask: $STORAGE_IP/24 - routes: [] - - # storage_mgmt - - type: vlan - mtu: ${INTERFACE_MTU} - vlan_id: 23 - addresses: - - ip_netmask: $STORAGE_MGMT_IP/24 - routes: [] - - # tenant - - type: vlan - mtu: ${INTERFACE_MTU} - vlan_id: 22 - addresses: - - ip_netmask: $TENANT_IP/24 - routes: [] -EOF - -cat << EOF | sudo tee /etc/cloud/cloud.cfg.d/99-edpm-disable-network-config.cfg -network: - config: disabled -EOF - -sudo systemctl enable network -sudo os-net-config -c /etc/os-net-config/config.yaml - -# The isolated networks from os-net-config config file above will be lost when openstack tripleo deploy is run -# because the default os-net-config template only has the Neutron public interface as a member. -# To prevent this, copy the standalone.j2 template file (which retains the VLANs above) into tripleo-ansible's tripleo_network_config role. - -sudo cp /tmp/standalone.j2 /usr/share/ansible/roles/tripleo_network_config/templates/standalone.j2 - -# Assign VIPs to the networks created when os-net-config was run. The tenant network on vlan22 does not require a VIP. - -sudo ip addr add 172.17.0.2/32 dev vlan20 -sudo ip addr add 172.18.0.2/32 dev vlan21 -sudo ip addr add 172.20.0.2/32 dev vlan23 -sudo ip addr add 172.21.0.2/32 dev vlan44 diff --git a/devsetup/standalone/network_data.yaml b/devsetup/standalone/network_data.j2 similarity index 70% rename from devsetup/standalone/network_data.yaml rename to devsetup/standalone/network_data.j2 index a28a29a..18cb3a9 100644 --- a/devsetup/standalone/network_data.yaml +++ b/devsetup/standalone/network_data.j2 @@ -58,3 +58,22 @@ external_subnet: ip_subnet: '172.21.0.0/24' allocation_pools: [{'start': '172.21.0.4', 'end': '172.21.0.250'}] + +{% for network in additional_networks if network.standalone_config -%} +{%- set net = network.standalone_config -%} +- name: {{ net.name }} + mtu: {{ net.mtu | default(1500) }} + vip: {{ net.vip | default('false') }} + name_lower: {{ net.name.lower() }} +{%- if net.vlan | default(false) %} + vlan: {{ net.vlan }} +{%- endif %} + dns_domain: {{ net.name.lower() }}.mydomain.tld. + subnets: + {{ net.name.lower() }}_subnet: + ip_subnet: '{{ net.ip_subnet }}' + allocation_pools: +{%- for pool in net.allocation_pools %} + - {'start': '{{ pool.start }}', 'end': '{{ pool.end }}'} +{%- endfor %} +{% endfor -%} diff --git a/devsetup/standalone/openstack.sh b/devsetup/standalone/openstack.sh index 4695dc7..30a3532 100755 --- a/devsetup/standalone/openstack.sh +++ b/devsetup/standalone/openstack.sh @@ -16,6 +16,7 @@ set -ex EDPM_COMPUTE_CEPH_ENABLED=${EDPM_COMPUTE_CEPH_ENABLED:-true} +COMPUTE_DRIVER=${COMPUTE_DRIVER:-"libvirt"} INTERFACE_MTU=${INTERFACE_MTU:-1500} # Use the files created in the previous steps including the network_data.yaml file and thw deployed_network.yaml file. @@ -23,29 +24,17 @@ INTERFACE_MTU=${INTERFACE_MTU:-1500} export NEUTRON_INTERFACE=eth0 export CTLPLANE_IP=${IP:-192.168.122.100} -export CTLPLANE_VIP=$(sed -e 's/[0-9][0-9][0-9]$/99/' <<<"$CTLPLANE_IP") - +export CTLPLANE_VIP=${CTLPLANE_IP%.*}.99 export CIDR=24 export GATEWAY=${GATEWAY:-192.168.122.1} export BRIDGE="br-ctlplane" -export SUBNET=$(sed -e 's/\.[0-9]*$//' <<<"$CTLPLANE_IP") -sed -i -e "s/CTLPLANE_IP/$CTLPLANE_IP/" /tmp/deployed_network.yaml -sed -i -e "s/CTLPLANE_SUBNET/$SUBNET/" /tmp/deployed_network.yaml -sed -i -e "s/CTLPLANE_VIP/$CTLPLANE_VIP/" /tmp/deployed_network.yaml # Create standalone_parameters.yaml file and deploy standalone OpenStack using the following commands. cat < standalone_parameters.yaml parameter_defaults: CloudName: $CTLPLANE_IP - ControlPlaneStaticRoutes: - - ip_netmask: 0.0.0.0/0 - next_hop: $GATEWAY - default: true Debug: true DeploymentUser: $USER - DnsServers: - - $HOST_PRIMARY_RESOLV_CONF_ENTRY - - $GATEWAY NtpServer: $NTP_SERVER # needed for vip & pacemaker KernelIpNonLocalBind: 1 @@ -67,26 +56,32 @@ parameter_defaults: OctaviaGenerateCerts: true OctaviaLogOffload: true OctaviaForwardAllLogs: true + StandaloneNetworkConfigTemplate: $HOME/standalone_net_config.j2 EOF +CMD="openstack tripleo deploy" + +CMD_ARGS+=" --templates /usr/share/openstack-tripleo-heat-templates" +CMD_ARGS+=" --local-ip=$CTLPLANE_IP/$CIDR" +CMD_ARGS+=" --control-virtual-ip=$CTLPLANE_VIP" +CMD_ARGS+=" --output-dir $HOME" +CMD_ARGS+=" --standalone-role Standalone" +CMD_ARGS+=" -r $HOME/Standalone.yaml" +CMD_ARGS+=" -n $HOME/network_data.yaml" + +ENV_ARGS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/standalone/standalone-tripleo.yaml" +ENV_ARGS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/low-memory-usage.yaml" +ENV_ARGS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/deployed-network-environment.yaml" +if [ "$COMPUTE_DRIVER" = "ironic" ]; then + ENV_ARGS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/services/ironic-overcloud.yaml" + ENV_ARGS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/services/ironic-inspector.yaml" +fi +ENV_ARGS+=" -e $HOME/standalone_parameters.yaml" if [ "$EDPM_COMPUTE_CEPH_ENABLED" = "true" ] ; then CEPH_ARGS=${CEPH_ARGS:-"-e ~/deployed_ceph.yaml -e /usr/share/openstack-tripleo-heat-templates/environments/cephadm/cephadm-rbd-only.yaml"} -else - CEPH_ARGS="" + ENV_ARGS+=" ${CEPH_ARGS}" fi +ENV_ARGS+=" -e $HOME/containers-prepare-parameters.yaml" +ENV_ARGS+=" -e $HOME/deployed_network.yaml" -sudo openstack tripleo deploy \ - --templates /usr/share/openstack-tripleo-heat-templates \ - --standalone-role Standalone \ - -e /usr/share/openstack-tripleo-heat-templates/environments/standalone/standalone-tripleo.yaml \ - -e /usr/share/openstack-tripleo-heat-templates/environments/low-memory-usage.yaml \ - -e ~/containers-prepare-parameters.yaml \ - -e standalone_parameters.yaml $CEPH_ARGS \ - -e /usr/share/openstack-tripleo-heat-templates/environments/deployed-network-environment.yaml \ - -e /tmp/deployed_network.yaml \ - -e /usr/share/openstack-tripleo-heat-templates/environments/services/octavia.yaml \ - -r /usr/share/openstack-tripleo-heat-templates/roles/Standalone.yaml \ - -n /tmp/network_data.yaml \ - --local-ip=$CTLPLANE_IP/$CIDR \ - --control-virtual-ip=$CTLPLANE_VIP \ - --output-dir $HOME +sudo ${CMD} ${CMD_ARGS} ${ENV_ARGS} diff --git a/devsetup/standalone/role.j2 b/devsetup/standalone/role.j2 new file mode 100644 index 0000000..a0a518e --- /dev/null +++ b/devsetup/standalone/role.j2 @@ -0,0 +1,186 @@ +- name: Standalone + description: | + A standalone role that a minimal set of services. This can be used for + testing in a single node configuration with the + 'openstack tripleo deploy --standalone' command or via an Undercloud using + 'openstack overcloud deploy'. + CountDefault: 1 + tags: + - primary + - controller + - standalone + default_route_networks: [] + networks: + External: + subnet: external_subnet + InternalApi: + subnet: internal_api_subnet + Storage: + subnet: storage_subnet + StorageMgmt: + subnet: storage_mgmt_subnet + StorageNFS: + subnet: storage_nfs_subnet + Tenant: + subnet: tenant_subnet +{%- for network in additional_networks if network.standalone_config %} +{%- set net = network.standalone_config %} + {{ net.name }}: + subnet: {{ net.name.lower() }}_subnet +{%- endfor %} + ServicesDefault: + - OS::TripleO::Services::Aide + - OS::TripleO::Services::AodhApi + - OS::TripleO::Services::AodhEvaluator + - OS::TripleO::Services::AodhListener + - OS::TripleO::Services::AodhNotifier + - OS::TripleO::Services::AuditD + - OS::TripleO::Services::BarbicanApi + - OS::TripleO::Services::BarbicanBackendDogtag + - OS::TripleO::Services::BarbicanBackendKmip + - OS::TripleO::Services::BarbicanBackendPkcs11Crypto + - OS::TripleO::Services::BarbicanBackendSimpleCrypto + - OS::TripleO::Services::CACerts + - OS::TripleO::Services::CeilometerAgentCentral + - OS::TripleO::Services::CeilometerAgentNotification + - OS::TripleO::Services::CephClient + - OS::TripleO::Services::CephExternal + - OS::TripleO::Services::CephGrafana + - OS::TripleO::Services::CephMds + - OS::TripleO::Services::CephMgr + - OS::TripleO::Services::CephMon + - OS::TripleO::Services::CephNfs + - OS::TripleO::Services::CephRbdMirror + - OS::TripleO::Services::CephRgw + - OS::TripleO::Services::CephOSD + - OS::TripleO::Services::CinderApi + - OS::TripleO::Services::CinderBackendDellEMCPowerFlex + - OS::TripleO::Services::CinderBackendDellEMCPowermax + - OS::TripleO::Services::CinderBackendDellEMCPowerStore + - OS::TripleO::Services::CinderBackendDellEMCSc + - OS::TripleO::Services::CinderBackendDellEMCUnity + - OS::TripleO::Services::CinderBackendDellEMCVMAXISCSI + - OS::TripleO::Services::CinderBackendDellEMCVNX + - OS::TripleO::Services::CinderBackendDellEMCVxFlexOS + - OS::TripleO::Services::CinderBackendDellEMCXtremio + - OS::TripleO::Services::CinderBackendDellSc + - OS::TripleO::Services::CinderBackendNVMeOF + - OS::TripleO::Services::CinderBackendPure + - OS::TripleO::Services::CinderBackendNetApp + - OS::TripleO::Services::CinderBackendScaleIO + - OS::TripleO::Services::CinderBackup + - OS::TripleO::Services::CinderHPELeftHandISCSI + - OS::TripleO::Services::CinderScheduler + - OS::TripleO::Services::CinderVolume + - OS::TripleO::Services::Clustercheck + - OS::TripleO::Services::Collectd + - OS::TripleO::Services::ComputeCeilometerAgent + - OS::TripleO::Services::CeilometerAgentIpmi + - OS::TripleO::Services::ContainerImagePrepare + - OS::TripleO::Services::ContainersLogrotateCrond + - OS::TripleO::Services::DesignateApi + - OS::TripleO::Services::DesignateCentral + - OS::TripleO::Services::DesignateMDNS + - OS::TripleO::Services::DesignateProducer + - OS::TripleO::Services::DesignateSink + - OS::TripleO::Services::DesignateBind + - OS::TripleO::Services::DesignateWorker + - OS::TripleO::Services::DockerRegistry + - OS::TripleO::Services::Etcd + - OS::TripleO::Services::ExternalSwiftProxy + - OS::TripleO::Services::Frr + - OS::TripleO::Services::GlanceApi + - OS::TripleO::Services::GlanceApiInternal + - OS::TripleO::Services::GnocchiApi + - OS::TripleO::Services::GnocchiMetricd + - OS::TripleO::Services::GnocchiStatsd + - OS::TripleO::Services::HAproxy + - OS::TripleO::Services::HeatApi + - OS::TripleO::Services::HeatApiCfn + - OS::TripleO::Services::HeatApiCloudwatch + - OS::TripleO::Services::HeatEngine + - OS::TripleO::Services::Horizon + - OS::TripleO::Services::IpaClient + - OS::TripleO::Services::Ipsec + - OS::TripleO::Services::IronicApi + - OS::TripleO::Services::IronicConductor + - OS::TripleO::Services::IronicInspector + - OS::TripleO::Services::IronicNeutronAgent + - OS::TripleO::Services::IronicPxe + - OS::TripleO::Services::Iscsid + - OS::TripleO::Services::Kernel + - OS::TripleO::Services::Keystone + - OS::TripleO::Services::LoginDefs + - OS::TripleO::Services::ManilaApi + - OS::TripleO::Services::ManilaBackendCephFs + - OS::TripleO::Services::ManilaBackendIsilon + - OS::TripleO::Services::ManilaBackendNetapp + - OS::TripleO::Services::ManilaBackendPowerMax + - OS::TripleO::Services::ManilaBackendUnity + - OS::TripleO::Services::ManilaBackendVMAX + - OS::TripleO::Services::ManilaBackendVNX + - OS::TripleO::Services::ManilaScheduler + - OS::TripleO::Services::ManilaShare + - OS::TripleO::Services::MasqueradeNetworks + - OS::TripleO::Services::Memcached + - OS::TripleO::Services::MetricsQdr + - OS::TripleO::Services::Multipathd + - OS::TripleO::Services::MySQL + - OS::TripleO::Services::MySQLClient + - OS::TripleO::Services::NeutronApi + - OS::TripleO::Services::NeutronBgpVpnApi + - OS::TripleO::Services::NeutronBgpVpnBagpipe + - OS::TripleO::Services::NeutronCorePlugin + - OS::TripleO::Services::NeutronDhcpAgent + - OS::TripleO::Services::NeutronL2gwAgent + - OS::TripleO::Services::NeutronL2gwApi + - OS::TripleO::Services::NeutronL3Agent + - OS::TripleO::Services::NeutronLinuxbridgeAgent + - OS::TripleO::Services::NeutronMetadataAgent + - OS::TripleO::Services::NeutronOvsAgent + - OS::TripleO::Services::NeutronSfcApi + - OS::TripleO::Services::NeutronVppAgent + - OS::TripleO::Services::NovaApi + - OS::TripleO::Services::NovaConductor + - OS::TripleO::Services::NovaIronic + - OS::TripleO::Services::NovaMetadata + - OS::TripleO::Services::NovaScheduler +{%- if compute_driver | default('libvirt') == 'libvirt' %} + - OS::TripleO::Services::NovaCompute + - OS::TripleO::Services::NovaLibvirt + - OS::TripleO::Services::NovaMigrationTarget +{%- endif %} + - OS::TripleO::Services::NovaVncProxy + - OS::TripleO::Services::OVNController + - OS::TripleO::Services::OVNDBs + - OS::TripleO::Services::OVNMetadataAgent + - OS::TripleO::Services::OctaviaApi + - OS::TripleO::Services::OctaviaDeploymentConfig + - OS::TripleO::Services::OctaviaHealthManager + - OS::TripleO::Services::OctaviaHousekeeping + - OS::TripleO::Services::OctaviaWorker + - OS::TripleO::Services::OpenStackClients + - OS::TripleO::Services::OsloMessagingNotify + - OS::TripleO::Services::OsloMessagingRpc + - OS::TripleO::Services::Pacemaker + - OS::TripleO::Services::PlacementApi + - OS::TripleO::Services::Podman + - OS::TripleO::Services::Redis + - OS::TripleO::Services::Rhsm + - OS::TripleO::Services::Rsyslog + - OS::TripleO::Services::RsyslogSidecar + - OS::TripleO::Services::Securetty + - OS::TripleO::Services::Snmp + - OS::TripleO::Services::Sshd + - OS::TripleO::Services::SwiftDispersion + - OS::TripleO::Services::SwiftProxy + - OS::TripleO::Services::SwiftRingBuilder + - OS::TripleO::Services::SwiftStorage + - OS::TripleO::Services::Timesync + - OS::TripleO::Services::Timezone + - OS::TripleO::Services::Tmpwatch + - OS::TripleO::Services::TripleoFirewall + - OS::TripleO::Services::TripleoPackages + - OS::TripleO::Services::Unbound + - OS::TripleO::Services::Tuned + - OS::TripleO::Services::Vpp diff --git a/devsetup/standalone/standalone.j2 b/devsetup/standalone/standalone.j2 deleted file mode 100644 index caa7a91..0000000 --- a/devsetup/standalone/standalone.j2 +++ /dev/null @@ -1,67 +0,0 @@ ---- -{% set control_virtual_ip = deployed_server_port_map.control_virtual_ip.fixed_ips[0].ip_address %} -{% set public_virtual_ip = deployed_server_port_map.public_virtual_ip.fixed_ips[0].ip_address %} -{% if ':' in control_virtual_ip %} -{% set control_virtual_cidr = 128 %} -{% else %} -{% set control_virtual_cidr = 32 %} -{% endif %} -{% if ':' in public_virtual_ip %} -{% set public_virtual_cidr = 128 %} -{% else %} -{% set public_virtual_cidr = 32 %} -{% endif %} -network_config: -- type: ovs_bridge - name: br-ctlplane - use_dhcp: false - mtu: {{ local_mtu }} - ovs_extra: - - br-set-external-id br-ctlplane bridge-id br-ctlplane - addresses: - - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }} - - ip_netmask: {{ control_virtual_ip}}/{{ control_virtual_cidr }} - - ip_netmask: {{ public_virtual_ip}}/{{ public_virtual_cidr }} - routes: {{ ctlplane_host_routes }} - dns_servers: {{ ctlplane_dns_nameservers }} - domain: {{ dns_search_domains }} - members: - - type: interface - name: {{ neutron_public_interface_name }} - primary: true - mtu: {{ local_mtu }} - - type: vlan - mtu: 1500 - vlan_id: 20 - addresses: - - ip_netmask: - 172.17.0.100/24 - routes: [] - - type: vlan - mtu: 1500 - vlan_id: 21 - addresses: - - ip_netmask: - 172.18.0.100/24 - routes: [] - - type: vlan - mtu: 1500 - vlan_id: 22 - addresses: - - ip_netmask: - 172.19.0.100/24 - routes: [] - - type: vlan - mtu: 1500 - vlan_id: 44 - addresses: - - ip_netmask: - 172.21.0.100/24 - routes: [] - - type: vlan - mtu: 1500 - vlan_id: 23 - addresses: - - ip_netmask: - 172.20.0.100/24 - routes: []