lima-vm
lima-vm
Taskfile.yaml
version: '3'
vars:
CPUS: 8
RAM: 16
LIMA_INSTANCE: devstack
SSH_PUBKEY:
sh: cat ~/.ssh/id_ed25519.pub
tasks:
default:
desc: List tasks
silent: true
cmds:
- task --list
list:
desc: VM list
cmds:
- pkgx limactl list
up:
desc: VM up
vars:
TEMPLATE: template.yaml
CMD: cd /opt/stack/devstack && ./stack.sh
cmds:
- pkgx gomplate --datasource environment=./{{.LIMA_INSTANCE}}.environment?type=application/x-env
--datasource provisioner=./{{.LIMA_INSTANCE}}.provisioner?type=text/plain
--file {{.LIMA_INSTANCE}}.yaml
--out {{.TEMPLATE}}
--chmod 644
- limactl create --name {{.LIMA_INSTANCE}} --tty=false {{.TEMPLATE}}
- limactl start {{.LIMA_INSTANCE}}
- limactl shell {{.LIMA_INSTANCE}}
sudo -u stack -i bash -c "{{.CMD}}"
down:
desc: VM down
cmds:
- pkgx limactl delete -f {{.LIMA_INSTANCE}}
setup-ssh:
desc: setup ssh
vars:
CMD: cd /opt/stack && mkdir .ssh && echo '{{.SSH_PUBKEY}}' > .ssh/authorized_keys
cmds:
- limactl shell {{.LIMA_INSTANCE}}
sudo -u stack -i bash -c "{{.CMD}}"
horizon:
desc: get devstack ip
silent: true
vars:
IP:
sh: limactl shell {{.LIMA_INSTANCE}} ip route get 8.8.8.8 | cut -d' ' -f7
cmds:
- open -a safari http://{{.IP}}
devstack.environment
UBUNTU_VERSION=24.04
HOST_NAME=devstack
HOST_IP=192.168.5.15
DEVSTACK_PASSWORD=password
DEVSTACK_BRANCH='stable/2024.2'
DEVSTACK_HOME='/opt/stack'
FLOATING_RANGE='192.168.33.224/27'
FIXED_RANGE='10.0.0.0/24'
devstack.provisioner
% cat devstack.provisioner
apt-get -qqy update || yum update -qy
apt-get install -qqy git net-tools sudo || yum install -qy git net-tools sudo
hostnamectl set-hostname "${HOST_NAME}"
echo "${HOST_IP} ${HOST_NAME}" >> /etc/hosts
useradd -s /bin/bash -d "${DEVSTACK_HOME}" -m stack
chmod +x ${DEVSTACK_HOME}
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
cd ${DEVSTACK_HOME}
git clone -b "${DEVSTACK_BRANCH}" https://opendev.org/openstack/devstack
cd devstack
#
# fix package name on ubuntu 24.04
#
sed -i -e 's/qemu-efi/qemu-efi-aarch64/' ./lib/nova_plugins/functions-libvirt
cat > local.conf <<EOF
[[local|localrc]]
HOST_IP=${HOST_IP}
FLOATING_RANGE=${FLOATING_RANGE}
FIXED_RANGE=${FIXED_RANGE}
ADMIN_PASSWORD=${DEVSTACK_PASSWORD}
DATABASE_PASSWORD=${DEVSTACK_PASSWORD}
RABBIT_PASSWORD=${DEVSTACK_PASSWORD}
SERVICE_PASSWORD=${DEVSTACK_PASSWORD}
DEST=${DEVSTACK_HOME}
LOGFILE=${DEVSTACK_HOME}/logs/stach.sh.log
USE_SSL=true
ENABLED_SERVICES+=,tls-proxy
EOF
chown -R stack:stack "${DEVSTACK_HOME}"
devstack.yaml
{{ $e := ds "environment" -}}
{{ $p := ds "provisioner" -}}
{{ $v := $e.UBUNTU_VERSION -}}
minimumLimaVersion: "1.0.0"
images:
- location: "https://cloud-images.ubuntu.com/releases/{{ $v }}/release/ubuntu-{{ $v }}-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/{{ $v }}/release/ubuntu-{{ $v }}-server-cloudimg-arm64.img"
arch: "aarch64"
mounts:
- location: "~"
- location: "/tmp/lima"
writable: true
cpus: 8
memory: 16GiB
vmType: vz
nestedVirtualization: true
networks:
- vzNAT: true
containerd:
user: false
system: false
provision:
- mode: system
script: |
#!/bin/bash
set -a
DEBIAN_FRONTEND=noninteractive
{{- range $key, $val := $e }}
{{ $key }}={{ $val -}}
{{ end }}
set +a
{{ $p | indent 4 }}