diff --git a/README.md b/README.md index 4c3bd3d..d929535 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ Terraform for the following configuration: -* OpenStack virtualised instances +* OpenStack virtualised lab instances +* An OpenStack virtualised container registry instance * Cinder volumes for instance storage * Floating IPs for networking @@ -12,24 +13,26 @@ OpenStack infrastructure. ## Prerequisites -* A Neutron network the instances can attach to, with router +* A Neutron network the instances can attach to, with a router * Plenty of resource quota +* Terraform installed (see instructions + [here](https://developer.hashicorp.com/terraform/install)) ## Software Components -[Kayobe](https://docs.openstack.org/kayobe/latest/) enables deployment of +[Kayobe](https://docs.openstack.org/kayobe/latest/) enables the deployment of containerised OpenStack to bare metal. # Instructions for deployment -After cloning this repo, source the regular OpenStack rc file with necessary -vars for accessing the *A Universe From Nothing* lab project. +After cloning this repo, source the regular OpenStack rc file with the +necessary vars for accessing the *A Universe From Nothing* lab project. -There are a various variables available for configuration. These can be seen +There are various variables available for configuration. These can be seen in `vars.tf`, and can be set in `terraform.tfvars` (see sample file `terraform.tfvars.sample`). -Next up is the `terraform` bit assuming it is already installed: +Create the resources using Terraform: terraform init terraform plan @@ -37,7 +40,7 @@ Next up is the `terraform` bit assuming it is already installed: To reprovision a lab machine: - terraform taint openstack_compute_instance_v2.# + terraform taint openstack_compute_instance_v2.lab[#] terraform apply -auto-approve where `#` is the lab index which can be obtained from the web UI. @@ -54,7 +57,7 @@ SSH in to your lab instance by running and entering the provided password: ssh lab@ -o PreferredAuthentications=password -The default password is the id of the lab instance. As such, it is recommeded +The default password is the id of the lab instance. As such, it is recommended that you run `passwd` immediately to change the default password. ## Nested virtualisation @@ -75,7 +78,7 @@ When complete, it should report an elapsed time as follows: [INFO] 22 minutes and 3 seconds elapsed. -## Inspect the bifrost container inside your seed VM: +## Inspect the Bifrost container inside your seed VM: ssh stack@192.138.33.5 docker ps @@ -85,7 +88,7 @@ When complete, it should report an elapsed time as follows: Look at the steps involved in deploying Kayobe control plane: - < a-universe-from-seed.sh + less a-universe-from-seed.sh # Wrapping up diff --git a/a-seed-from-nothing.sh b/a-seed-from-nothing.sh index f786a88..abdea88 100644 --- a/a-seed-from-nothing.sh +++ b/a-seed-from-nothing.sh @@ -3,9 +3,6 @@ # Reset SECONDS SECONDS=0 -# Cloud User: cloud-user (CentOS) or ubuntu? -CLOUD_USER=cloud-user - ENABLE_OVN=true # Registry IP @@ -14,19 +11,20 @@ registry_ip=$1 echo "[INFO] Given docker registry IP: $registry_ip" # Disable the firewall. -if [[ "${CLOUD_USER}" = "ubuntu" ]] -then +if type apt; then + grep -q $HOSTNAME /etc/hosts || (echo "$(ip r | grep -o '^default via.*src [0-9.]*' | awk '{print $NF}') $HOSTNAME" | sudo tee -a /etc/hosts) dpkg -l ufw && sudo systemctl is-enabled ufw && sudo systemctl stop ufw && sudo systemctl disable ufw else rpm -q firewalld && sudo systemctl is-enabled firewalld && sudo systemctl stop firewalld && sudo systemctl disable firewalld -fi -# Disable SELinux. -sudo setenforce 0 + # Disable SELinux. + sudo setenforce 0 +fi # Useful packages -if [[ "${CLOUD_USER}" = "ubuntu" ]] -then +if type apt; then + # Avoid the interactive dialog prompting for service restart: set policy to leave services unchanged + echo "\$nrconf{restart} = 'l';" | sudo tee /etc/needrestart/conf.d/90-aufn.conf sudo apt update sudo apt install -y git tmux lvm2 iptables else @@ -42,8 +40,7 @@ EOF sudo sysctl --load /etc/sysctl.d/70-ipv6.conf # CentOS Stream 8 requires network-scripts. Rocky Linux 9 and onwards use NetworkManager. -if [[ "${CLOUD_USER}" = "cloud-user" ]] -then +if type dnf; then case $(grep -o "[89]\.[0-9]" /etc/redhat-release) in "8.*") sudo dnf install -y network-scripts @@ -60,6 +57,18 @@ then exit -1 ;; esac +elif type apt; then + # Prepare for disabling of Netplan and enabling of systemd-networkd. + # Netplan has an interaction with systemd and cloud-init to populate + # systemd-networkd files, but ephemerally. If /etc/systemd/network is + # empty and netplan config files are present in /run, copy them over. + persistent_netcfg=$(ls /etc/systemd/network) + ephemeral_netcfg=$(ls /run/systemd/network) + if [[ -z "$persistent_netcfg" && ! -z "$ephemeral_netcfg" ]] + then + echo "Creating persistent versions of Netplan ephemeral config" + sudo cp /run/systemd/network/* /etc/systemd/network + fi fi # Exit on error @@ -68,6 +77,7 @@ fi set -e # Ensure an ssh key is generated +CLOUD_USER=$(ls /home | grep -v lab | grep -v stack | head -1) # NOTE: you might think ~${CLOUD_USER} would work but apparently not CLOUD_USER_DIR=/home/${CLOUD_USER} keyfile="$HOME/.ssh/id_rsa" @@ -86,43 +96,38 @@ then sudo chown ${CLOUD_USER}.${CLOUD_USER} ${CLOUD_USER_DIR}/.ssh/authorized_keys fi -# Clone Kayobe. +# Clone Beokay. cd $HOME -[[ -d kayobe ]] || git clone https://opendev.org/openstack/kayobe.git -b stable/yoga -cd kayobe +git clone https://github.com/stackhpc/beokay.git -b master + +# Use Beokay to bootstrap your control host. +[[ -d deployment ]] || beokay/beokay.py create --base-path ~/deployment --kayobe-repo https://opendev.org/openstack/kayobe.git --kayobe-branch stable/2023.1 --kayobe-config-repo https://github.com/stackhpc/a-universe-from-nothing.git --kayobe-config-branch stable/2023.1 # Bump the provisioning time - it can be lengthy on virtualised storage -sed -i.bak 's%^[# ]*wait_active_timeout:.*% wait_active_timeout: 5000%' ~/kayobe/ansible/overcloud-provision.yml +sed -i.bak 's%^[# ]*wait_active_timeout:.*% wait_active_timeout: 5000%' ~/deployment/src/kayobe/ansible/overcloud-provision.yml # Clone the Tenks repository. +cd ~/deployment/src/ [[ -d tenks ]] || git clone https://opendev.org/openstack/tenks.git - -# Clone this Kayobe configuration. -mkdir -p config/src -cd config/src/ -[[ -d kayobe-config ]] || git clone https://github.com/stackhpc/a-universe-from-nothing.git -b stable/yoga kayobe-config +cd # Set default registry name to the one we just created -sed -i.bak 's/^docker_registry.*/docker_registry: '$registry_ip':4000/' kayobe-config/etc/kayobe/docker.yml +sed -i.bak 's/^docker_registry:.*/docker_registry: '$registry_ip':4000/' ~/deployment/src/kayobe-config/etc/kayobe/docker.yml # Configure host networking (bridge, routes & firewall) -./kayobe-config/configure-local-networking.sh - -# Install kayobe. -cd ~/kayobe -./dev/install-dev.sh +~/deployment/src/kayobe-config/configure-local-networking.sh # Enable OVN flags if $ENABLE_OVN then - cat <