Deploying and Redeploying OpenStack on a Physical Server
OpenStack deploys can be time-consuming, especially if you need to restore your server to an old state. Fortunately, with Snapper, you can make frequent deploys easier.
Join the DZone community and get the full member experience.Join For Free
OpenStack can be deployed for multiple purposes, such as learning, training, exploring certain features, developing or enhancing projects, integrating it with other systems, running Test or Production workloads, etc.
We often need to deploy and redeploy OpenStack on the same physical server for:
Problems in deployment
Change in hypervisor
OpenStack deployment training
The challenge with redeployment is that we need to trace back all the packages installed as part of OpenStack and uninstall all of them. It is a tedious and cumbersome process. The other option is to reinstall the OS, but that is a time-consuming effort. An optimal way to do that activity over and over again is to restore the physical server to the old state using Snapper. This blog outlines the procedure for installing Snapper, creating a Snapshot of your physical server — similar to a virtual image — deploying OpenStack, and restoring the physical server to the old state for redeployment.
OpenStack is a leading open-source software platform for cloud computing, mostly deployed as an infrastructure-as-a-service (IaaS). The software platform consists of interrelated components that control diverse, multi-vendor hardware pools of processing, storage, and networking resources throughout a Data Center
Snapper is a Linux command line tool to create and manage snapshots of your filesystems. It allows you to create read-only snapshots of physical machines that can be used to restore the state of the server during a disaster situation.
Steps for Deploying OpenStack With Snapper and Restoring to the Original State
The block diagram below outlines the various layers involved in the setup:
- A BTRFS file system.
- OS: Ubuntu14.04,16.04
- Snapper Version 0.1.8
- Resource requirement: 4GB RAM, 20GB HDD
Note: Snapper has full support in the Open SUSE platform
Step1: Installing Snapper
Install Snapper using the command:
apt-get install snapper -y
Step 2: Prepare Your Script for Creating Config and Mount Point
Create the script below with the name snapperconfigandmountpoint.sh.
#Snapper with btrfs filesystem in ubuntu 14.04 ARGS=$(getopt -o a:b -l "configname:,mountpoint:" -- "$@"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--mountpoint) shift; if [ -n "$1" ]; then mountpoint=$1; shift; fi ;; --) shift; break; ;; esac done #creating a config file echo $configname echo $mountpoint snapper -c $configname create-config $mountpoint snapper list-configs
Step 3: Run the Script
Run the script using the command below. Use the same configname and mount point until the end.
bash snapperconfigandmountpoint.sh –configname –mountpoint
Step 4: Prepare the Snapshot Script
Create the script below with the name Snapshotcreation.sh.
ARGS=$(getopt -o a:b -l "configname:,snapshotname:" -- "$@"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--snapshotname) shift; if [ -n "$1" ]; then snapshotname=$1; shift; fi ;; --) shift; break; ;; esac done echo $configname echo $snapshotname snapper --config $configname create --description "$snapshotname " snapper --config $configname list
Step 5: Run the Script to Create a Snapshot Using Snapper
Run the script using the command:
bash snapshotcreation.sh –configname –snapshotname
The execution will create a snapshot and list the created snapshots. Create a snapshot name of your choice, but ensure that you use the same config name used earlier.
Step 6: Deploy OpenStack
Deploy OpenStack Mitaka by following the instructions available here.
Step 7: Prepare a Script to Restore Your Snapshot
Create the following script with the name Restore.sh to restore the physical server to an older state:
ARGS=$(getopt -o a:b:c -l "configname:,state_to_revert:,state_to_modify:," -- "$@"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--state_to_revert) shift; if [ -n "$1" ]; then state_to_revert=$1; shift; fi ;; -c|--state_to_modify) shift; if [ -n "$1" ]; then state_to_modify=$1; shift; fi ;; --) shift; break; ;; esac done echo $configname echo $state_to_revert echo $state_to_modify snapper -c $configname -v undochange $state_to_revert..$state_to_modify
Step 8: Run script to restore older snapshot using Snapper
Run the script using the command below, specifying the config name and Snapshot number to which we need to restore.
bash restore.sh –configname –state_to_revert –state_to_modify
bash restoretest.sh –configname snapconfig –state_to_revert 1 –state_to_modify 2
If everything works correctly, you will able to deploy OpenStack, restore your server to its original state, and redeploy again and again.
Published at DZone with permission of Rathinasabapathy Arumugam, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.