Files
2023-10-25 21:23:52 +03:00

3.3 KiB

RBD Test

Example of use

git clone https://gitlab.resds.ru/vlasov.dv/rbd-test.git
cd rbd-test
chmod +x create-vm.sh
./create-vm.sh --bootstrap-env
vi env
sudo ./create-vm.sh -e ./env

Usage of ./create-vm.sh:

usage: 
  ./create-vm.sh required_args [optional_args] OR
  ./create-vm.sh misc_args

Create a new virtual machine from a specified yaml config

misc_args:
  --bootstrap-env         ENV_PATH       create template env file and exit

required_args:
  -n, --name              NAME          name of a virtual machine
  -o, --os-variant        OS_VARIANT    operating system
  -m, --memory            MEMORY        RAM size
  -c, --vcpus             VCPUS         Amount of of cores
  -i, --image             IMAGE         URL or path to an ISO image
  -s, --size              SIZE          Size of an OS drive (example: 8G)
  -b, --bridge            BRIDGE        bridge name (LinuxBridge only)
  -a, --ip-address        IP            ip address of eth0
  -p, --prefix            PREFIX        network prefix
  -g, --gateway           GATEWAY       ip address of network gateway
  -d, --dns               DNS           ip address of dns server
  --ceph-user             CEPH_USER     ceph auth user with rights on pool
  --rbd-pool              RBD_POOL      ceph pool name
  --rbd-name              RBD           name of rbd in a pool
  --rbd-size              RBD_SIZE      size of RBD (default: 8G)

optional_args:
  -h, --help                            show this help message and exit
  -e, --env                             export args from env file
  -r, --rm-if-exist                     if vm exist, remove it first
                                          default: false
  -R, --rm-rbd-if-exist                 create brand new RBD 
                                          default: false
  -P, --pubkey            PUBKEY        place public key into autorized_keys of
                                          all defined in config.yaml users
                                          default: /home/\$USER/.ssh/id_rsa.pub
  -v, --vnc-password      VNC_PASSWORD  vnc console password
                                          default: PASSWD1!
  -C, --cloud-init        CLOUD_INIT    Path to a cloud-init config - will be
                                        created if not provided

env example:
    NAME=Ubuntu22.04
    OS_VARIANT=ubuntu22.04
    MEMORY=2048
    VCPUS=2
    IMAGE=https://cloud-images.ubuntu.com/jammy/20231010/jammy-server-cloudimg-amd64.img
    SIZE=8G
    BRIDGE=virbr0
    IP=192.168.122.2
    PREFIX=24
    GATEWAY=192.168.122.1
    DNS=8.8.8.8
    RM=true
    RM_RBD=true
    PUBKEY=/home/cloudadmin/.ssh/id_rsa.pub
    VNC_PASSWORD=PASSWD1!
    CEPH_USER=admin
    RBD_POOL=pool-ssd
    RBD=ubuntu2204_test
    RBD_SIZE=16G

cloud-init example:
    #cloud-config
    package_upgrade: false
    runcmd:
    - touch /test.txt
    packages:
    - vim
    - htop
    users:
    - name: ubuntu
    ssh-authorized-keys:
        - {{PUBKEY}}
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    ssh_pwauth: true
    lock-passwd: false
    chpasswd: {expire: False}
    groups: sudo
    shell: /bin/bash
    - name: adminuser
    ssh-authorized-keys:
        - {{PUBKEY}}
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    ssh_pwauth: true
    lock-passwd: false
    chpasswd: {expire: False}
    groups: sudo
    shell: /bin/bash