Skip to content

Instantly share code, notes, and snippets.

@fmount
Last active May 8, 2023 13:52
Show Gist options
  • Save fmount/d84f83e5f2373d3038b226a73cdf6a1d to your computer and use it in GitHub Desktop.
Save fmount/d84f83e5f2373d3038b226a73cdf6a1d to your computer and use it in GitHub Desktop.
Standalone OSP and Ceph
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
$tripleo_standalone = <<-'SCRIPT'
set -euxo pipefail
# grow root partition and FS
echo ", +" | sudo sfdisk -N 1 /dev/vda --no-reread
sudo partprobe
sudo resize2fs /dev/vda1
export GATEWAY=192.168.121.1
export IP=192.168.24.2
export VIP=192.168.24.3
export VAGRANT_IP=$(ip a show dev eth0 | grep -oE '192.168.121.[0-9]+' | head -n1)
export NETMASK=24
export INTERFACE=eth1
export HOME=/home/vagrant
export NTP_SERVER=clock.corp.redhat.com
touch $HOME/standalone.log
cat << EOF > $HOME/standalone_parameters.yaml
parameter_defaults:
CloudName: $IP
# ControlPlaneStaticRoutes: []
ControlPlaneStaticRoutes:
- ip_netmask: 0.0.0.0/0
next_hop: $GATEWAY
default: true
DeploymentUser: $USER
DnsServers:
- 192.168.121.1
DockerInsecureRegistryAddress:
- $IP:8787
NeutronPublicInterface: $INTERFACE
NtpServer: $NTP_SERVER
CloudDomain: localdomain
NeutronDnsDomain: localdomain
NeutronBridgeMappings: datacentre:br-ctlplane
NeutronPhysicalBridge: br-ctlplane
StandaloneEnableRoutedNetworks: false
StandaloneHomeDir: $HOME
InterfaceLocalMtu: 1500
NovaComputeLibvirtType: qemu
EOF
sudo hostnamectl set-hostname standalone.localdomain
sudo hostnamectl set-hostname standalone.localdomain --transient
sudo dnf update -y
sudo dnf install -y vim git curl util-linux lvm2 tmux wget
sudo dnf remove -y epel-release
url=https://trunk.rdoproject.org/centos9/component/tripleo/current/
rpm_name=$(curl $url | grep python3-tripleo-repos | sed -e 's/<[^>]*>//g' | awk 'BEGIN { FS = ".rpm" } ; { print $1 }')
rpm=$rpm_name.rpm
sudo dnf install -y $url$rpm
sudo -E tripleo-repos -b wallaby current-tripleo-dev ceph --stream
sudo dnf repolist
sudo dnf update -y
sudo dnf install -y podman
sudo dnf install -y python3-tripleoclient
openstack tripleo container image prepare default \
--output-env-file $HOME/containers-prepare-parameters.yaml
cat << EOF > $HOME/external-ceph.yaml
resource_registry:
OS::TripleO::Services::CephExternal: /usr/share/openstack-tripleo-heat-templates/deployment/cephadm/ceph-client.yaml
parameter_defaults:
# NOTE: These example parameters are required when using CephExternal
CephClusterFSID: 'a03abd88-83cb-4d6d-9ceb-9c832e61c918'
CephClientKey: 'AQCG/yNk+aC2EhAAZUl6KfFT5HOBgu5cy4kZPA=='
CephExternalMonHost: '192.168.126.11'
ExternalCeph: true
# the following parameters enable Ceph backends for Cinder, Glance, Gnocchi and Nova
NovaEnableRbdBackend: true
CinderEnableRbdBackend: true
CinderBackupBackend: ceph
GlanceBackend: rbd
# Uncomment below if enabling legacy telemetry
# GnocchiBackend: rbd
# If the Ceph pools which host VMs, Volumes and Images do not match these
# names OR the client keyring to use is not named 'openstack', edit the
# following as needed.
NovaRbdPoolName: vms
CinderRbdPoolName: volumes
CinderBackupRbdPoolName: backups
GlanceRbdPoolName: images
# Uncomment below if enabling legacy telemetry
# GnocchiRbdPoolName: metrics
CephClientUserName: openstack
# finally we disable the Cinder LVM backend
CinderEnableIscsiBackend: false
EOF
cat << EOF > $HOME/standalone.sh
set -euxo pipefail
if podman ps | grep keystone; then
echo "Looks like OpenStack is already deployed, not re-deploying."
exit 0
fi
sudo openstack tripleo deploy \
--templates \
--local-ip=$IP/24 \
--control-virtual-ip=$VIP \
-e /usr/share/openstack-tripleo-heat-templates/environments/standalone/standalone-tripleo.yaml \
-r /usr/share/openstack-tripleo-heat-templates/roles/Standalone.yaml \
-e "$HOME/containers-prepare-parameters.yaml" \
-e "$HOME/standalone_parameters.yaml" \
-e "$HOME/external-ceph.yaml" \
-e /usr/share/openstack-tripleo-heat-templates/environments/low-memory-usage.yaml \
--output-dir $HOME
export OS_CLOUD=standalone
openstack endpoint list
EOF
sudo chown -R vagrant:vagrant /home/vagrant
sudo chmod +x $HOME/standalone.sh
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box_check_update = false
config.vm.provider :libvirt do |libvirt|
libvirt.default_prefix = 'director_'
libvirt.uri = 'qemu:///system'
end
config.vm.define :standalone do |vm_conf|
vm_conf.vm.box = "centos_stream_9"
vm_conf.vm.hostname = "standalone"
vm_conf.vm.provider :libvirt do |libvirt|
libvirt.memory = 32768
libvirt.cpus = 8
libvirt.machine_virtual_size = 50
end
vm_conf.vm.network :private_network,
:type => "dhcp",
:ip => "192.168.126.20"
vm_conf.vm.provision "shell", inline: $tripleo_standalone
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment