### Packstack Installation Log Output Source: https://openstack.goffinet.org/03-04-openstack-rdo-packstack Example output from the Packstack utility during an all-in-one installation, showing the progress and completion status of various OpenStack components. ```text Welcome to the Packstack setup utility The installation log file is available at: /var/tmp/packstack/20190309-213243-nLQIP0/openstack-setup.log Packstack changed given value to required value /root/.ssh/id_rsa.pub Installing: Clean Up [ DONE ] Discovering ip protocol version [ DONE ] Setting up ssh keys [ DONE ] Preparing servers [ DONE ] Pre installing Puppet and discovering hosts' details [ DONE ] Preparing pre-install entries [ DONE ] Setting up CACERT [ DONE ] Preparing AMQP entries [ DONE ] Preparing MariaDB entries [ DONE ] Fixing Keystone LDAP config parameters to be undef if empty[ DONE ] Preparing Keystone entries [ DONE ] Preparing Glance entries [ DONE ] Checking if the Cinder server has a cinder-volumes vg[ DONE ] Preparing Cinder entries [ DONE ] Preparing Nova API entries [ DONE ] Creating ssh keys for Nova migration [ DONE ] Gathering ssh host keys for Nova migration [ DONE ] Preparing Nova Compute entries [ DONE ] Preparing Nova Scheduler entries [ DONE ] Preparing Nova VNC Proxy entries [ DONE ] Preparing OpenStack Network-related Nova entries [ DONE ] Preparing Nova Common entries [ DONE ] Preparing Neutron LBaaS Agent entries [ DONE ] Preparing Neutron API entries [ DONE ] Preparing Neutron L3 entries [ DONE ] Preparing Neutron L2 Agent entries [ DONE ] Preparing Neutron DHCP Agent entries [ DONE ] Preparing Neutron Metering Agent entries [ DONE ] Checking if NetworkManager is enabled and running [ DONE ] Preparing OpenStack Client entries [ DONE ] Preparing Horizon entries [ DONE ] Preparing Swift builder entries [ DONE ] Preparing Swift proxy entries [ DONE ] Preparing Swift storage entries [ DONE ] Preparing Gnocchi entries [ DONE ] Preparing Redis entries [ DONE ] Preparing Ceilometer entries [ DONE ] Preparing Aodh entries [ DONE ] Preparing Puppet manifests [ DONE ] Copying Puppet modules and manifests [ DONE ] Applying 192.168.1.140_controller.pp 192.168.1.140_controller.pp: [ DONE ] Applying 192.168.1.140_network.pp 192.168.1.140_network.pp: [ DONE ] Applying 192.168.1.140_compute.pp 192.168.1.140_compute.pp: [ DONE ] Applying Puppet manifests [ DONE ] Finalizing [ DONE ] **** Installation completed successfully ****** Additional information: * A new answerfile was created in: /root/packstack-answers-20190309-213244.txt * Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components. * File /root/keystonerc_admin has been created on OpenStack client host 192.168.1.140. To use the command line tools you need to source the file. * To access the OpenStack Dashboard browse to http://192.168.1.140/dashboard . Please, find your login credentials stored in the keystonerc_admin in your home directory. * Because of the kernel update the host 192.168.1.140 requires reboot. * The installation log file is available at: /var/tmp/packstack/20190309-213243-nLQIP0/openstack-setup.log * The generated manifests are available at: /var/tmp/packstack/20190309-213243-nLQIP0/manifests ``` -------------------------------- ### Script Usage Example Source: https://openstack.goffinet.org/03-01-openstack-training-labs Demonstrates how to call the start-stop-cluster.sh script with provider and action arguments. Use 'vbox start' to start VirtualBox VMs or 'vbox stop' to stop them. ```bash ~/start-stop-cluster.sh vbox start ~/start-stop-cluster.sh vbox stop ``` -------------------------------- ### Start QEMU/KVM Node Source: https://openstack.goffinet.org/03-01-openstack-training-labs Command to start a QEMU/KVM virtual machine named 'controller'. ```bash sudo virsh start controller ``` -------------------------------- ### Shell Script for OpenStack Prerequisites Setup Source: https://openstack.goffinet.org/99-notes This script automates the server preparation for OpenStack installation on VirtualBox. It handles partition mounting, system upgrades, dependency installation, VirtualBox setup, and user creation. Ensure you have the necessary permissions and environment before execution. ```bash #!/bin/bash mount_sda_partition () { echo "---- Mount /dev/sda1 partition on /opt ----" #mkfs -t ext4 /dev/sda1 cat << EOF >> /etc/systemd/system/opt.mount [Unit] Description=Mount SDA Volume at boot [Mount] What=UUID="$( blkid | grep /dev/sda1 | cut -d' ' -f2 | cut -d\" -f2 )" Where=/opt Type=ext4 Options=defaults [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl start opt.mount systemctl enable opt.mount } host_setup () { echo "---- Non-interactive Ubuntu system upgrade and pre-reqs installation ----" # https://superuser.com/questions/1332341/console-setup-causes-apt-get-update-to-hang echo "console-setup console-setup/charmap47 select UTF-8" > encoding.conf debconf-set-selections encoding.conf rm encoding.conf apt-get update DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install git ansible language-pack-en sudo update-locale LANG=en_US.UTF-8 echo "---- Install virtualbox ----" wget https://gist.githubusercontent.com/goffinet/6f606829a1b9400adb0165d49455b55d/raw/990161aed57b158e0f2c86f0df1b01a75e7b7b6a/scaleway-linux-headers.yml && ansible-playbook scaleway-linux-headers.yml DEBIAN_FRONTEND=noninteractive apt-get -qq install virtualbox-dkms virtualbox echo "---- Create a stack user ----" useradd -s /bin/bash -d /home/stack -m -k /etc/skel stack echo "stack ALL=(ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/stack } mount_sda_partition host_setup ``` -------------------------------- ### YAML List Example Source: https://openstack.goffinet.org/10-00-orchestration-openstack-iac Demonstrates how to define a list in YAML. Each list item starts with a hyphen and a space. ```yaml --- # A list of tasty fruits fruits: - Apple - Orange - Strawberry - Mango ... ``` -------------------------------- ### Start VirtualBox VMs Source: https://openstack.goffinet.org/06-00-extension-openstack Use vboxmanage to start controller and compute1 virtual machines in headless mode. ```bash vboxmanage startvm "controller" --type headless Waiting for VM "controller" to power on... VM "controller" has been successfully started. ``` ```bash vboxmanage startvm "compute1" --type headless Waiting for VM "compute1" to power on... VM "compute1" has been successfully started. ``` -------------------------------- ### Install Libvirt and KVM Packages Source: https://openstack.goffinet.org/03-01-openstack-training-labs Installs essential packages for KVM virtualization, including QEMU, libvirt, virtinst, and related tools. It also adds the current user to the 'libvirt' group and installs Python dependencies. ```bash sudo apt-get update sudo apt-get -y upgrade sudo apt-get -y install qemu-kvm libvirt-bin virtinst virt-viewer libguestfs-tools virt-manager uuid-runtime python-pip pkg-config libvirt-dev genisoimage netcat python-dev libyaml-dev libosinfo-bin virt-top sudo usermod -aG libvirt `id -un` ``` -------------------------------- ### Install VirtualBox Source: https://openstack.goffinet.org/03-01-openstack-training-labs Installs VirtualBox on your system. It first updates the package list and upgrades existing packages, then installs VirtualBox. ```bash sudo apt-get update sudo apt-get -y upgrade sudo apt-get -y install virtualbox ``` -------------------------------- ### Install OpenStack client tools Source: https://openstack.goffinet.org/03-03-conjuring-up-openstack-with-novalxd Installs the OpenStack client tools using snap with classic confinement, enabling command-line management of the OpenStack cloud. ```bash sudo snap install openstackclients --classic ``` -------------------------------- ### Example OS::Nova::Server Resource Source: https://openstack.goffinet.org/10-00-orchestration-openstack-iac An example of defining an OS::Nova::Server resource with specified flavor and image. ```yaml resources: my_instance: type: OS::Nova::Server properties: flavor: m1.small image: F18-x86_64-cfntools ``` -------------------------------- ### Start KVM VMs Source: https://openstack.goffinet.org/06-00-extension-openstack Use virsh to start compute1 and controller virtual machines. ```bash virsh start compute1 virsh start controller ``` -------------------------------- ### Start KVM VM Source: https://openstack.goffinet.org/06-00-extension-openstack Start a KVM virtual machine using the virsh command. This will boot the VM and make it available on the network. ```bash virsh start compute2 ``` -------------------------------- ### Example Multiple Resource Dependencies Source: https://openstack.goffinet.org/10-00-orchestration-openstack-iac Shows how to specify multiple dependencies for a resource using a list in `depends_on`. ```yaml resources: server1: type: OS::Nova::Server depends_on: [ server2, server3 ] server2: type: OS::Nova::Server server3: type: OS::Nova::Server ``` -------------------------------- ### Install conjure-up Source: https://openstack.goffinet.org/03-03-conjuring-up-openstack-with-novalxd Installs conjure-up, a tool for deploying applications on Ubuntu, using snap with classic confinement. ```bash sudo snap install conjure-up --classic ``` -------------------------------- ### Start VirtualBox VM Source: https://openstack.goffinet.org/06-00-extension-openstack Initiate the startup of a VirtualBox VM in headless mode, meaning without a graphical user interface. ```bash vboxmanage startvm "compute2" --type headless ``` -------------------------------- ### Stacktrain Setup Script Source: https://openstack.goffinet.org/99-notes This bash script automates the setup of the Stacktrain environment for OpenStack training labs. It downloads necessary archives, configures environment variables, and sets up controller and compute node configurations. It also handles prerequisites like iptables-converter and creates a default storage pool for libvirt. ```bash #!/bin/bash package=$1 case ${package} in pike) archive="labs-stable-pike.tgz" ;; queens) archive="labs-stable-queens.tgz" ;; rocky) archive="labs-stable-rocky.tgz" ;; stein) archive="labs-master.tgz" ;; *) head -n15 $0 && exit ;; esac echo "---- Get the training-labs scripts ----" wget http://tarballs.openstack.org/training-labs/dist/${archive} tar xvfz ${archive} echo "---- Configure directory path as env variables ----" cat << EOF >> ~/.bashrc OS_LAB=$HOME OS_ST=$HOME/labs OS_BASH=$HOME/labs/osbash EOF export OS_LAB=$HOME export OS_ST=$HOME/labs export OS_BASH=$HOME/labs/osbash echo "---- Configure the controller and the compute1 components ----" mv $OS_ST/config/config.controller $OS_ST/config/config.controller.bak cat << EOF >> $OS_ST/config/config.controller VM_SSH_PORT=2230 VM_WWW_PORT=8888 NET_IF_0=dhcp NET_IF_1="static 10.0.0.11 1" NET_IF_2="manual 203.0.113.0" VM_MEM=6144 VM_CPUS=2 EOF mv $OS_ST/config/config.compute1 $OS_ST/config/config.compute1.bak cat << EOF >> $OS_ST/config/config.compute1 VM_SSH_PORT=2232 NET_IF_0=dhcp NET_IF_1="static 10.0.0.31 1" NET_IF_2="manual 203.0.113.0" SECOND_DISK_SIZE=128000 VM_MEM=8192 VM_CPUS=4 EOF cat << EOF | sudo tee --append /etc/hosts 10.0.0.11 controller 10.0.0.31 compute1 EOF if [ ${package} == "pike" ] ; then echo "---- Enable Heat service installation ----" cp $OS_ST/config/scripts.ubuntu_cluster $OS_ST/config/scripts.ubuntu_cluster.bak sed -i '/heat_controller/s/#//' $OS_ST/config/scripts.ubuntu_cluster fi if [ $(virsh --version > /dev/null ; echo $?) == '0' ] ; then echo "---- install last prereq ----" sudo apt update sudo apt -qq install iptables-converter echo "---- Default Storage Pool creation ----" sudo virsh pool-destroy default sudo virsh pool-undefine default mkdir -p /home/stack/labs/pool sudo virsh pool-define-as default dir - - - - "/home/stack/labs/pool" sudo virsh pool-start default sudo virsh pool-autostart default echo "---- Populate env vars ----" cat << EOF >> ~/.bashrc VIRSH_DEFAULT_CONNECT_URI='qemu:///system' PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin EOF export PATH=$PATH:/sbin:/usr/sbin/ echo "---- install last prereq ----" sudo apt update sudo apt -qq install iptables-converter echo "---- Default Storage Pool creation ----" sudo virsh pool-destroy default sudo virsh pool-undefine default mkdir -p /home/stack/labs/pool sudo virsh pool-define-as default dir - - - - "/home/stack/labs/pool" sudo virsh pool-start default sudo virsh pool-autostart default echo "---- Populate env vars ----" cat << EOF >> ~/.bashrc VIRSH_DEFAULT_CONNECT_URI='qemu:///system' PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin EOF export PATH=$PATH:/sbin:/usr/sbin/ fi ``` -------------------------------- ### Install LXD via Snap Source: https://openstack.goffinet.org/03-03-conjuring-up-openstack-with-novalxd Installs the LXD system container manager using snap. This is a prerequisite for managing containers. ```bash sudo snap install lxd ``` -------------------------------- ### Example Resource Dependency Source: https://openstack.goffinet.org/10-00-orchestration-openstack-iac Demonstrates defining resource dependencies using `depends_on` in HOT. ```yaml resources: server1: type: OS::Nova::Server depends_on: server2 server2: type: OS::Nova::Server ``` -------------------------------- ### Install and configure training-labs scripts Source: https://openstack.goffinet.org/03-01-openstack-training-labs This script installs training-labs scripts based on the specified OpenStack release and configures environment variables and component settings. It handles downloading archives, setting up paths, and configuring controller and compute nodes. Ensure you have wget installed. ```bash #!/bin/bash #st_setup.sh package=$1 case ${package} in pike) archive="labs-stable-pike.tgz" ;; queens) archive="labs-stable-queens.tgz" ;; rocky) archive="labs-stable-rocky.tgz" ;; stein) archive="labs-master.tgz" ;; *) head -n15 $0 && exit ;; esac echo "---- Get the training-labs scripts ----" wget http://tarballs.openstack.org/training-labs/dist/${archive} tar xvfz ${archive} echo "---- Configure directory path as env variables ----" cat << EOF >> ~/.bashrc OS_LAB=$HOME OS_ST=$HOME/labs OS_BASH=$HOME/labs/osbash EOF export OS_LAB=$HOME export OS_ST=$HOME/labs export OS_BASH=$HOME/labs/osbash echo "---- Configure the controller and the compute1 components ----" mv $OS_ST/config/config.controller $OS_ST/config/config.controller.bak cat << EOF >> $OS_ST/config/config.controller VM_SSH_PORT=2230 VM_WWW_PORT=8888 NET_IF_0=dhcp NET_IF_1="static 10.0.0.11 1" NET_IF_2="manual 203.0.113.0" VM_MEM=6144 VM_CPUS=2 EOF mv $OS_ST/config/config.compute1 $OS_ST/config/config.compute1.bak cat << EOF >> $OS_ST/config/config.compute1 VM_SSH_PORT=2232 NET_IF_0=dhcp NET_IF_1="static 10.0.0.31 1" NET_IF_2="manual 203.0.113.0" SECOND_DISK_SIZE=128000 VM_MEM=8192 VM_CPUS=4 EOF cat << EOF | sudo tee --append /etc/hosts 10.0.0.11 controller 10.0.0.31 compute1 EOF if [ ${package} == "pike" ] ; then echo "---- Enable Heat service installation ----" cp $OS_ST/config/scripts.ubuntu_cluster $OS_ST/config/scripts.ubuntu_cluster.bak sed -i '/heat_controller/s/#//' $OS_ST/config/scripts.ubuntu_cluster fi if [ $(virsh --version > /dev/null ; echo $?) == '0' ] ; then echo "---- install last prereq ----" sudo apt update sudo apt -qq install iptables-converter echo "---- Default Storage Pool creation ----" sudo virsh pool-destroy default sudo virsh pool-undefine default mkdir -p /home/stack/labs/pool sudo virsh pool-define-as default dir - - - - "/home/stack/labs/pool" sudo virsh pool-start default sudo virsh pool-autostart default echo "---- Populate env vars ----" cat << EOF >> ~/.bashrc VIRSH_DEFAULT_CONNECT_URI='qemu:///system' PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin EOF export PATH=$PATH:/sbin:/usr/sbin/ echo "---- install last prereq ----" sudo apt update sudo apt -qq install iptables-converter echo "---- Default Storage Pool creation ----" sudo virsh pool-destroy default sudo virsh pool-undefine default mkdir -p /home/stack/labs/pool sudo virsh pool-define-as default dir - - - - "/home/stack/labs/pool" sudo virsh pool-start default sudo virsh pool-autostart default echo "---- Populate env vars ----" cat << EOF >> ~/.bashrc VIRSH_DEFAULT_CONNECT_URI='qemu:///system' PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin EOF export PATH=$PATH:/sbin:/usr/sbin/ fi ``` -------------------------------- ### Enter stack user session Source: https://openstack.goffinet.org/03-01-openstack-training-labs Switch to the 'stack' user to perform lab setup operations. ```bash sudo su - stack ``` -------------------------------- ### YAML Arbitrary Example Source: https://openstack.goffinet.org/10-00-orchestration-openstack-iac An example combining various YAML features including multi-line strings. ```yaml --- # An employee record name: Martin D'vloper job: Developer skill: Elite employed: True foods: - Apple - Orange - Strawberry - Mango languages: perl: Elite python: Elite pascal: Lame education: | 4 GCSEs 3 A-Levels BSc in the Internet of Things ``` -------------------------------- ### Install jq JSON Parser Source: https://openstack.goffinet.org/05-00-administration-openstack-1 Installs the `jq` utility, a lightweight and flexible command-line JSON processor, using apt package manager. ```bash osbash@controller:~$ sudo apt -y install jq ``` -------------------------------- ### Run DevStack Installation Source: https://openstack.goffinet.org/03-02-openstack-lab-devstack Execute the `stack.sh` script to install and configure OpenStack services based on your `local.conf` settings. This process can take a significant amount of time. ```bash ./stack.sh ``` -------------------------------- ### Run Packstack All-in-One Installation Source: https://openstack.goffinet.org/03-04-openstack-rdo-packstack Executes the Packstack utility to perform an all-in-one OpenStack installation. This command initiates the deployment process. ```bash sudo packstack --allinone ``` -------------------------------- ### Basic HOT Template Example Source: https://openstack.goffinet.org/10-00-orchestration-openstack-iac A simple Heat Orchestration Template deploying a single compute instance with key name, image, and flavor. ```yaml heat_template_version: 2015-04-30 description: Simple template to deploy a single compute instance resources: my_instance: type: OS::Nova::Server properties: key_name: my_key image: ubuntu-trusty-x86_64 flavor: m1.small ``` -------------------------------- ### Example HOT Template with Parameters Source: https://openstack.goffinet.org/10-00-orchestration-openstack-iac A simple HOT template demonstrating the definition of parameters for key name, image ID, and instance flavor. ```yaml heat_template_version: 2015-04-30 description: Simple template to deploy a single compute instance parameters: key_name: type: string label: Key Name description: Name of key-pair to be used for compute instance image_id: type: string label: Image ID description: Image to be used for compute instance flavor: type: string label: Instance Type description: Type of instance (flavor) to be used resources: my_instance: type: OS::Nova::Server properties: key_name: { get_param: key_name } image: { get_param: image_id } flavor: { get_param: flavor } ``` -------------------------------- ### Execute stacktrain setup script for a specific release Source: https://openstack.goffinet.org/03-01-openstack-training-labs Run the stacktrain setup script, passing the OpenStack release name as an argument. This command is used to test specific versions like 'spike' or 'pike'. ```bash bash st_setup.sh spike ``` ```bash bash st_setup.sh pike ``` -------------------------------- ### Swift Subcommand: download Source: https://openstack.goffinet.org/11-00-stockage-objet-openstack Guide on using the `download` subcommand to retrieve objects from Swift containers. ```APIDOC ## GET /objects/{container_name}/{object_name} ### Description Downloads objects from containers. ### Method GET ### Endpoint `/{container_name}/{object_name}` ### Parameters #### Path Parameters - **container_name** (string) - The name of the container. - **object_name** (string) - The name of the object to download. ### Examples ```bash swift download swift download ``` ``` -------------------------------- ### Create Cluster Start/Stop Script Source: https://openstack.goffinet.org/03-01-openstack-training-labs A bash script to manage the starting and stopping of cluster nodes for KVM/QEMU or VirtualBox providers. Includes usage instructions and argument validation. ```bash cat <<'EOM' > ~/start-stop-cluster.sh #!/bin/bash ########################################### # program: start-stop-cluster.sh # # Author: Diarmuid O'Briain # # Copyright ©2017 C2S Consulting # # License: www.gnu.org/licenses/gpl.txt # ########################################### PROVIDER='' if [[ `echo "$0" | grep './'` ]]; then command=`echo "$0"|awk -F '/' '{print $2}'` else command=$0 fi # Help function function usage { echo -e "usage: $command help, -h, -help, --help\n" echo -e "PROVIDER:: kvm | vbox\n" echo -e "kvm = Kernel based Virtual Machine/Quick Emulator (KVM/QEMU)\n" echo -e "vbox = Oracle VirtualBox\n" echo -e "Start or Stop the Virtual Machines in the cluster\n" exit } # Arguments from the command line if [[ $# -lt 1 ]]; then # Deal with too few arguments echo -e "\nNot enough arguments\n" usage elif [[ $# -gt 2 ]]; then # Deal with too many arguments echo -e "\nToo many arguments\n" usage elif [[ $1 =~ (-h|-help|--help|help) ]]; then # Deal with request for help usage elif [[ $1 =~ (kvm|vbox) ]] && [[ $2 =~ (start|stop) ]]; then # Deal with legit option PROVIDER=$1 ACTION=$2 echo -e "\nSelected provider is: $PROVIDER and the cluster will $ACTION\n" else echo -e "\nNot an acceptable option\n" usage fi # Action nodes if [[ $PROVIDER =~ 'kvm' ]] && [[ $ACTION =~ 'start' ]]; then echo -e "Powering up KVM/QEMU nodes\n" if ! [[ $(virsh net-list | egrep 'labs-mgmt|labs-provider'; echo $?) ]];then virsh -c 'qemu:///system' net-start 'labs-mgmt' virsh -c 'qemu:///system' net-start 'labs-provider' fi sleep 5 virsh -c 'qemu:///system' start 'controller' virsh -c 'qemu:///system' start 'compute1' elif [[ $PROVIDER =~ 'kvm' ]] && [[ $ACTION =~ 'stop' ]]; then echo -e "Powering down KVM/QEMU nodes\n" virsh -c 'qemu:///system' shutdown 'controller' virsh -c 'qemu:///system' shutdown 'compute1' sleep 5 elif [[ $PROVIDER =~ 'vbox' ]] && [[ $ACTION =~ 'start' ]]; then echo -e "Powering up VirtualBox nodes\n" vboxmanage startvm 'controller' --type headless vboxmanage startvm 'compute1' --type headless echo elif [[ $PROVIDER =~ 'vbox' ]] && [[ $ACTION =~ 'stop' ]]; then echo -e "Powering off VirtualBox nodes\n" vboxmanage controlvm 'controller' poweroff vboxmanage controlvm 'compute1' poweroff echo fi ``` -------------------------------- ### Openstack Training Labs Project Structure Source: https://openstack.goffinet.org/03-01-openstack-training-labs Overview of the directory structure for the stacktrain project, which automates Openstack installation. Key directories include 'autostart' for startup scripts, 'config' for configurations, 'img' for images, 'lib' for libraries, 'log' for logs, 'scripts' for VM scripts, and 'wbatch' for Windows batch files. ```text autostart : Les scripts shell osbash/wbatch (`*.sh`) dans ce dossier sont automatiquement exécutés et puis retirés au démarrage. config : Contient les fichiers de configuration pour tous les scripts. C'est l'endroit de configuration. img : Emplacement par défaut des images. lib : Librairies utilisées par les scripts. log: Contient tous les logs osbash/wbatch exécutés. `log/stacktrain.log` scripts: Tous les scripts qui seront exécutés dans les VMs. wbatch : Fichiers batch Windows générés par osbash. ``` -------------------------------- ### Get QEMU/KVM Node Information (controller) Source: https://openstack.goffinet.org/03-01-openstack-training-labs Retrieves detailed information about the 'controller' virtual machine, including its ID, state, CPU usage, memory allocation, and security model. Requires root privileges. ```bash stack@stacktrain05:~/labs$ sudo virsh dominfo controller Id: 6 Name: controller UUID: 7f21ec82-7aba-4627-9612-f42c4b5d4500 OS Type: hvm State: running CPU(s): 2 CPU time: 926.2s Max memory: 6291456 KiB Used memory: 6291456 KiB Persistent: yes Autostart: disable Managed save: no Security model: apparmor Security DOI: 0 Security label: libvirt-7f21ec82-7aba-4627-9612-f42c4b5d4500 (enforcing) ``` ```bash stack@stacktrain05:~/labs$ sudo virsh snapshot-list controller Name Creation Time State ------------------------------------------------------------ controller_-_cluster_installed 2019-03-06 22:02:37 +0000 shutoff ``` -------------------------------- ### Get QEMU/KVM Node Information (compute1) Source: https://openstack.goffinet.org/03-01-openstack-training-labs Retrieves detailed information about the 'compute1' virtual machine, including its ID, state, CPU usage, memory allocation, and security model. Requires root privileges. ```bash stack@stacktrain05:~/labs$ sudo virsh dominfo compute1 Id: 7 Name: compute1 UUID: 0118dad7-90ca-405a-bbf2-c2c09c61046c OS Type: hvm State: running CPU(s): 4 CPU time: 379.7s Max memory: 8388608 KiB Used memory: 8388608 KiB Persistent: yes Autostart: disable Managed save: no Security model: apparmor Security DOI: 0 Security label: libvirt-0118dad7-90ca-405a-bbf2-c2c09c61046c (enforcing) ``` ```bash stack@stacktrain05:~/labs$ sudo virsh snapshot-list compute1 Name Creation Time State ------------------------------------------------------------ compute-_cluster_installed 2019-03-06 22:02:37 +0000 shutoff ``` -------------------------------- ### Stacktrain Deployment Model Source: https://openstack.goffinet.org/03-01-openstack-training-labs Describes the two-stage deployment process of the stacktrain script (`st.py`). It first builds a base image and then installs and configures a controller and a compute node for immediate use. This process is functional on Ubuntu 18.04 with VirtualBox 5.2.18. ```python st.py ``` -------------------------------- ### OpenStack Server Create Help Source: https://openstack.goffinet.org/05-00-administration-openstack-1 Displays the help message for the `openstack server create` command, outlining all available options and parameters for launching an instance. ```bash openstack server create --help usage: openstack server create [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN] [--max-width ] [--fit-width] [--print-empty] [--noindent] [--prefix PREFIX] (--image | --volume ) --flavor [--security-group ] [--key-name ] [--property ] [--file ] [--user-data ] [--availability-zone ] [--block-device-mapping ] [--nic ] [--network ] [--port ] [--hint ] [--config-drive |True] [--min ] [--max ] [--wait] ``` -------------------------------- ### Basic DevStack Local Configuration Source: https://openstack.goffinet.org/03-02-openstack-lab-devstack Configure network ranges, interface, and passwords for a basic DevStack setup. This `local.conf` file is essential for customizing the installation. ```ini [[local|localrc]] FLOATING_RANGE=192.168.1.224/27 FIXED_RANGE=10.11.12.0/24 FIXED_NETWORK_SIZE=256 FLAT_INTERFACE=eth0 ADMIN_PASSWORD=supersecret DATABASE_PASSWORD=iheartdatabases RABBIT_PASSWORD=flopsymopsy SERVICE_PASSWORD=iheartksl ``` -------------------------------- ### Ansible Playbook Tasks for OpenStack Provisioning Source: https://openstack.goffinet.org/03-00-openstack-environnements-lab Lists tasks for provisioning a Scaleway server for OpenStack, including initial setup, package installation, and virtualization software deployment. ```yaml #ansible-playbook stacktrain.yml --list-tasks #playbook: stacktrain.yml play #1 (all): SCALEWAY PROVISIONNING TAGS: [start] tasks: Scaleway provisionning TAGS: [start] play #2 (all): MOUNT /dev/sda1 ON /opt TAGS: [mount] tasks: mount the additional block device TAGS: [mount] play #3 (all): UPGRADE AND INSTALL NEEDED SOFTWARES TAGS: [requs] tasks: Ensure en_US.UTF-8 locale exists TAGS: [requs] upgrade all packages TAGS: [requs] ensure dependencies are installed TAGS: [requs] play #4 (all): REBOOT SCALEWAY SERVER TAGS: [reboot] tasks: restart scaleway TAGS: [reboot] play #5 (all): FINISH INSTALLATION TAGS: [post] tasks: install missing linux kernel headers TAGS: [post] install virtualbox TAGS: [post] install kvm TAGS: [post] Send SSH Key TAGS: [post] ``` -------------------------------- ### List QEMU/KVM Snapshots Source: https://openstack.goffinet.org/03-01-openstack-training-labs Lists all available snapshots for a QEMU/KVM virtual machine, showing their names, creation times, and states. ```bash sudo virsh snapshot-list controller ``` ```text Name Creation Time State ------------------------------------------------------------ controller_-_cluster_installed 2019-03-06 22:02:37 +0000 shutoff ``` -------------------------------- ### Install OpenStack Packstack Source: https://openstack.goffinet.org/03-04-openstack-rdo-packstack Installs the necessary CentOS OpenStack Rocky repository and the openstack-packstack package. Updates the system before installation. ```bash sudo yum install -y centos-release-openstack-rocky sudo yum update -y sudo yum install -y openstack-packstack ``` -------------------------------- ### Execute Project Initialization Script Source: https://openstack.goffinet.org/09-00-reseaux-openstack Run the project initialization script with a specified project name argument. ```bash bash -x /project_init.sh webapp ``` -------------------------------- ### Initialize DevStack Environment Source: https://openstack.goffinet.org/09-00-reseaux-openstack Navigate to the devstack directory and source the openrc file to set up administrative credentials for OpenStack. ```bash cd cd devstack . openrc admin admin ``` -------------------------------- ### Take VirtualBox Snapshot Source: https://openstack.goffinet.org/03-01-openstack-training-labs Creates a new snapshot for a VirtualBox virtual machine. Provide a name and an optional description for the snapshot. ```bash vboxmanage snapshot "controller" take "snap01-controller" --description "Initial controller snapshot" ``` -------------------------------- ### Create a Container with Swift CLI Source: https://openstack.goffinet.org/11-00-stockage-objet-openstack Use the `swift post` command to create a new container. This is the first step before uploading any files. ```bash stack@st-vbx-1:~/devstack$ swift post TestContainer ``` -------------------------------- ### List Created OpenStack Flavors Source: https://openstack.goffinet.org/04-00-infrastructure-openstack Lists the instance flavors after creation, showing 'm1.nano' and 'm1.small' with their respective resource allocations. ```bash osbash@controller:~$ openstack flavor list +----+----------+------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+----------+------+------+-----------+-------+-----------+ | 0 | m1.nano | 64 | 1 | 0 | 1 | True | | 1 | m1.small | 2048 | 1 | 0 | 1 | True | +----+----------+------+------+-----------+-------+-----------+ ``` -------------------------------- ### Configure Router with External Gateway and Route Source: https://openstack.goffinet.org/09-00-reseaux-openstack Creates a router named 'router1', sets an external gateway to 'provider', attaches the 'PRIV-SUBNET', and configures a default route to a specified gateway IP. ```bash openstack router create router1 openstack router set --external-gateway=provider router1 openstack router add subnet router1 PRIV-SUBNET openstack router set router1 --route destination=0.0.0.0/0,gateway=203.0.113.1 ``` -------------------------------- ### Clone DevStack Repository Source: https://openstack.goffinet.org/03-02-openstack-lab-devstack Clone the DevStack repository to your local machine to begin the installation process. Navigate into the cloned directory. ```bash git clone https://git.openstack.org/openstack-dev/devstack cd devstack ``` -------------------------------- ### Comprehensive OpenStack Instance Launch Script Source: https://openstack.goffinet.org/05-00-administration-openstack-1 This script automates the creation of flavors, keypairs, security group rules, and launching an instance with a volume. It includes functions to set environment variables and check for existing resources. ```bash cat <<'EOM' > ~/instance_launch.sh #!/bin/bash KEYNAME='mykey-test' VOLNAME='1GB-vol-test' FLAVOUR='m1.nano' IMAGE='cirros' SSH_HOSTS_FILE='/home/osbash/.ssh/id_rsa' INSTANCE="$IMAGE-test" set_admin_vars () { echo; echo "Setting admin-openrc variables" export OS_USERNAME=admin export OS_PASSWORD=demo_user_pass export OS_PROJECT_NAME=admin export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_AUTH_URL=http://10.0.0.11:35357/v3 export OS_IDENTITY_API_VERSION=3 export OS_IMAGE_API_VERSION=2 } create_flavor () { echo; echo "Creating flavour $FLAVOUR" if grep -qvw "$FLAVOUR" <<< $(openstack flavor list -f value | awk '{print $2}') ; then openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 $FLAVOUR else echo "The flavor exists already" ; fi } set_demo_vars () { echo; echo "Setting demo-openrc variables" export OS_USERNAME=demo export OS_PASSWORD=demo_user_pass export OS_PROJECT_NAME=demo export OS_AUTH_URL=http://10.0.0.11:5000/v3 } create_keypair () { echo; echo "Creating keypair $KEYNAME and ~/$KEYNAME.pem file" if [ ! -e "$SSH_HOSTS_FILE" ]; then touch $SSH_HOSTS_FILE openstack keypair create --public-key $SSH_HOSTS_FILE $KEYNAME > ~/$KEYNAME.pem echo; echo "Restricting ~/$KEYNAME.pem access rights" chmod 600 ~/$KEYNAME.pem else echo "The key pair exists already" ; fi } set_security_group () { echo; echo "Adding port 22 (SSH) and ICMP to default security group" if grep -qvw 'tcp 0.0.0.0/0 22:22' <<< $(openstack security group rule list default -f value) ; then openstack security group rule create --proto tcp --dst-port 22 default else echo "The SSH rule exists already" ; fi if grep -qvw 'icmp 0.0.0.0/0' <<< $(openstack security group rule list default -f value) ; then openstack security group rule create --proto icmp default else echo "The ICMP rule exists already" ; fi } get_nic_uuid () { NIC=$(openstack network list | grep provider | awk '{print $2}') echo; echo "Extracting provider network UUID: $NIC" } launch_instance () { echo; echo "Creating and launching instance $INSTANCE with:" echo -e "\n\tFlavour: $FLAVOUR" echo -e "\tImage: $IMAGE" echo -e "\tNetwork UUID=$NIC" echo -e "\tSecurity group: default" echo -e "\tKey name: $KEYNAME\n" openstack server create \ --flavor $FLAVOUR \ --image $IMAGE \ --nic net-id=$NIC \ --security-group default \ --key-name $KEYNAME \ $INSTANCE } waiting_active () { echo -e "\nWaiting for instance $INSTANCE to become ACTIVE\n" while [ "$(openstack server list | grep $INSTANCE | awk '{print $6}')" != 'ACTIVE' ]; do printf ". " sleep 2 done } final_message () { echo; echo "Creating volume $VOLNAME" openstack volume create --size 1 $VOLNAME echo; echo "Adding volume $VOLNAME to VM instance $INSTANCE" openstack server add volume $INSTANCE $VOLNAME openstack volume list echo; echo } set_admin_vars create_flavor set_demo_vars create_keypair set_security_group get_nic_uuid launch_instance waiting_active final_message #END EOM ``` -------------------------------- ### YAML Dictionary Example Source: https://openstack.goffinet.org/10-00-orchestration-openstack-iac Shows a basic YAML dictionary structure where key-value pairs are defined using a colon and a space. ```yaml # An employee record martin: name: Martin D'vloper job: Developer skill: Elite ``` -------------------------------- ### Verify KVM VM Running State Source: https://openstack.goffinet.org/06-00-extension-openstack Check the status of KVM virtual machines to confirm that the newly started VM is running. ```bash virsh list --all Id Name State ---------------------------------------------------- 9 compute2 running - compute1 shut off - controller shut off ``` -------------------------------- ### OpenStack Image List JSON Output Source: https://openstack.goffinet.org/05-00-administration-openstack-1 Example JSON output from listing OpenStack images, showing status, ID, and name for each image. ```json [ { "Status": "active", "ID": "9173ec36-6beb-4361-9446-021cf5dc8b9c", "Name": "cirros" } ] ``` -------------------------------- ### List Block Devices Source: https://openstack.goffinet.org/05-00-administration-openstack-1 Use `lsblk` to list block devices, their sizes, and mount points on the compute node. This helps in understanding the storage layout. ```bash osbash@compute1:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 9.8G 0 disk |-sda1 8:1 0 8.8G 0 part / |-sda2 8:2 0 1K 0 part `-sda5 8:5 0 975M 0 part [SWAP] sdb 8:16 0 125G 0 disk |-cinder--volumes-cinder--volumes--pool_tmeta 252:0 0 120M 0 lvm | `-cinder--volumes-cinder--volumes--pool-tpool 252:2 0 118.8G 0 lvm | |-cinder--volumes-cinder--volumes--pool 252:3 0 118.8G 0 lvm | `-cinder--volumes-volume--636110b5--9cf5--49cd--818a--92660148c247 252:4 0 1G 0 lvm `-cinder--volumes-cinder--volumes--pool_tdata 252:1 0 118.8G 0 lvm `-cinder--volumes-cinder--volumes--pool-tpool 252:2 0 118.8G 0 lvm |-cinder--volumes-cinder--volumes--pool 252:3 0 118.8G 0 lvm `-cinder--volumes-volume--636110b5--9cf5--49cd--818a--92660148c247 252:4 0 1G 0 lvm ``` -------------------------------- ### Login with New OpenRC File Script Source: https://openstack.goffinet.org/07-00-administration-openstack-2 This script creates a project, user, and role, then assigns the role to the user and project, preparing for login with a new openrc file. ```bash client="dev" openstack project create --description "$client Project" $client openstack user create --password ${client}_password $client openstack role create $client openstack role add --user $client --project $client $client ``` -------------------------------- ### Get KVM VM IP Address Source: https://openstack.goffinet.org/06-00-extension-openstack Retrieve the IP address assigned to a KVM VM by the default DHCP server. This is useful for connecting to the VM. ```bash virsh net-dhcp-leases default Expiry Time MAC address Protocol IP address Hostname Client ID or DUID ------------------------------------------------------------------------------------------------------------------- 2019-03-10 11:40:43 52:54:00:f3:f7:0f ipv4 192.168.122.221/24 compute1 - ```